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