CMakeTestCompilerCommon.cmake 1.0 KB

123456789101112131415161718192021222324252627
  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 MSG)
  4. message(STATUS "Check for working ${LANG} compiler: ${CMAKE_${LANG}_COMPILER}${MSG}")
  5. endfunction()
  6. # if required set the target type if not already explicitly set
  7. macro(__TestCompiler_setTryCompileTargetType)
  8. if(NOT CMAKE_TRY_COMPILE_TARGET_TYPE)
  9. if("${CMAKE_GENERATOR}" MATCHES "Green Hills MULTI")
  10. #prefer static libraries to avoid linking issues
  11. set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
  12. set(__CMAKE_TEST_COMPILER_TARGET_TYPE_RESTORE 1)
  13. endif()
  14. endif()
  15. endmacro()
  16. # restore the original value
  17. # -- not necessary if __TestCompiler_setTryCompileTargetType() was used in function scope
  18. macro(__TestCompiler_restoreTryCompileTargetType)
  19. if(__CMAKE_TEST_COMPILER_TARGET_TYPE_RESTORE)
  20. unset(CMAKE_TRY_COMPILE_TARGET_TYPE)
  21. unset(__CMAKE_TEST_COMPILER_TARGET_TYPE_RESTORE)
  22. endif()
  23. endmacro()