CMakeTestCompilerCommon.cmake 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. function(PrintTestCompilerStatus LANG)
  4. # ARGN shouldn't be needed now, but it is there to preserve backward
  5. # compatibility in case this function is called from project code or
  6. # custom toolchains (they shouldn't, but we can easily support it)
  7. message(CHECK_START "Check for working ${LANG} compiler: ${CMAKE_${LANG}_COMPILER}${ARGN}")
  8. endfunction()
  9. function(PrintTestCompilerResult TYPE MSG)
  10. message(${TYPE} "${MSG}")
  11. endfunction()
  12. # if required set the target type if not already explicitly set
  13. macro(__TestCompiler_setTryCompileTargetType)
  14. if(NOT CMAKE_TRY_COMPILE_TARGET_TYPE)
  15. if("${CMAKE_GENERATOR}" MATCHES "Green Hills MULTI")
  16. #prefer static libraries to avoid linking issues
  17. set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
  18. set(__CMAKE_TEST_COMPILER_TARGET_TYPE_RESTORE 1)
  19. endif()
  20. endif()
  21. endmacro()
  22. # restore the original value
  23. # -- not necessary if __TestCompiler_setTryCompileTargetType() was used in function scope
  24. macro(__TestCompiler_restoreTryCompileTargetType)
  25. if(__CMAKE_TEST_COMPILER_TARGET_TYPE_RESTORE)
  26. unset(CMAKE_TRY_COMPILE_TARGET_TYPE)
  27. unset(__CMAKE_TEST_COMPILER_TARGET_TYPE_RESTORE)
  28. endif()
  29. endmacro()