diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in index 1ed00bf05..a767e8f7a 100644 --- a/Modules/CMakeCCompiler.cmake.in +++ b/Modules/CMakeCCompiler.cmake.in @@ -10,11 +10,7 @@ IF(CMAKE_COMPILER_IS_CYGWIN) SET(UNIX 1) ENDIF(CMAKE_COMPILER_IS_CYGWIN) -SET(CMAKE_VC_COMPILER_TESTS_RUN 1) -SET(CMAKE_COMPILER_SUPPORTS_PDBTYPE @CMAKE_COMPILER_SUPPORTS_PDBTYPE@) -SET(CMAKE_COMPILER_2005 @CMAKE_COMPILER_2005@) -SET(CMAKE_USING_VC_FREE_TOOLS @CMAKE_USING_VC_FREE_TOOLS@) - +SET(CMAKE_C_COMPILER_ENV_VAR "CC") IF(CMAKE_COMPILER_IS_MINGW) SET(MINGW 1) diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index 965bde472..46e20a7db 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -1,13 +1,7 @@ SET(CMAKE_CXX_COMPILER "@CMAKE_CXX_COMPILER@") SET(CMAKE_COMPILER_IS_GNUCXX @CMAKE_COMPILER_IS_GNUCXX@) SET(CMAKE_CXX_COMPILER_LOADED 1) -SET(CMAKE_COMPILER_IS_GNUCC_RUN 1) - -SET(CMAKE_VC_COMPILER_TESTS_RUN 1) -SET(CMAKE_COMPILER_SUPPORTS_PDBTYPE @CMAKE_COMPILER_SUPPORTS_PDBTYPE@) -SET(CMAKE_COMPILER_2005 @CMAKE_COMPILER_2005@) -SET(CMAKE_USING_VC_FREE_TOOLS @CMAKE_USING_VC_FREE_TOOLS@) - +SET(CMAKE_COMPILER_IS_GNUCXX_RUN 1) SET(CMAKE_CXX_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC) SET(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm) @@ -17,3 +11,4 @@ IF(UNIX) ELSE(UNIX) SET(CMAKE_CXX_OUTPUT_EXTENSION .obj) ENDIF(UNIX) +SET(CMAKE_CXX_COMPILER_ENV_VAR "CXX") diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 30d0d47fe..4317ecfbf 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -86,4 +86,5 @@ ENDIF(NOT CMAKE_COMPILER_IS_GNUCC_RUN) CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeCCompiler.cmake.in ${CMAKE_BINARY_DIR}/CMakeCCompiler.cmake IMMEDIATE) MARK_AS_ADVANCED(CMAKE_AR) + SET(CMAKE_C_COMPILER_ENV_VAR "CC") diff --git a/Modules/CMakeFortranCompiler.cmake.in b/Modules/CMakeFortranCompiler.cmake.in index 057e0fd29..f52677637 100644 --- a/Modules/CMakeFortranCompiler.cmake.in +++ b/Modules/CMakeFortranCompiler.cmake.in @@ -22,3 +22,4 @@ IF(UNIX) ELSE(UNIX) SET(CMAKE_Fortran_OUTPUT_EXTENSION .obj) ENDIF(UNIX) +SET(CMAKE_Fortran_COMPILER_ENV_VAR "FC") diff --git a/Modules/CMakeJavaCompiler.cmake.in b/Modules/CMakeJavaCompiler.cmake.in index 0c3eaf6da..574265216 100644 --- a/Modules/CMakeJavaCompiler.cmake.in +++ b/Modules/CMakeJavaCompiler.cmake.in @@ -8,3 +8,4 @@ SET(CMAKE_Java_LINKER_PREFERENCE Prefered) SET(CMAKE_Java_OUTPUT_EXTENSION .class) SET(CMAKE_STATIC_LIBRARY_PREFIX_Java "") SET(CMAKE_STATIC_LIBRARY_SUFFIX_Java ".jar") +SET(CMAKE_Java_COMPILER_ENV_VAR "JAVA_COMPILER") diff --git a/Modules/CMakeRCCompiler.cmake.in b/Modules/CMakeRCCompiler.cmake.in index aa1509879..33f6d90a4 100644 --- a/Modules/CMakeRCCompiler.cmake.in +++ b/Modules/CMakeRCCompiler.cmake.in @@ -2,3 +2,4 @@ SET(CMAKE_RC_COMPILER "@CMAKE_RC_COMPILER@") SET(CMAKE_RC_COMPILER_LOADED 1) SET(CMAKE_RC_SOURCE_FILE_EXTENSIONS rc) SET(CMAKE_RC_OUTPUT_EXTENSION .res) +SET(CMAKE_RC_COMPILER_ENV_VAR "RC") diff --git a/Modules/CMakeTestCCompiler.cmake b/Modules/CMakeTestCCompiler.cmake index fc5791a54..af9420fe8 100644 --- a/Modules/CMakeTestCCompiler.cmake +++ b/Modules/CMakeTestCCompiler.cmake @@ -12,7 +12,8 @@ IF(NOT CMAKE_C_COMPILER_WORKS) "int main(){return 0;}\n") TRY_COMPILE(CMAKE_C_COMPILER_WORKS ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/CMakeTmp/testCCompiler.c - OUTPUT_VARIABLE OUTPUT) + OUTPUT_VARIABLE OUTPUT) + SET(C_TEST_WAS_RUN 1) ENDIF(NOT CMAKE_C_COMPILER_WORKS) IF(NOT CMAKE_C_COMPILER_WORKS) @@ -25,8 +26,11 @@ IF(NOT CMAKE_C_COMPILER_WORKS) "with the following output:\n ${OUTPUT}\n\n" "CMake will not be able to correctly generate this project.") ELSE(NOT CMAKE_C_COMPILER_WORKS) - MESSAGE(STATUS "Check for working C compiler: ${CMAKE_C_COMPILER} -- works") - FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeOutput.log - "Determining if the C compiler works passed with " - "the following output:\n${OUTPUT}\n\n") + IF(C_TEST_WAS_RUN) + MESSAGE(STATUS "Check for working C compiler: ${CMAKE_C_COMPILER} -- works") + FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeOutput.log + "Determining if the C compiler works passed with " + "the following output:\n${OUTPUT}\n\n") + ENDIF(C_TEST_WAS_RUN) + SET(CMAKE_C_COMPILER_WORKS 1 CACHE INTERNAL "") ENDIF(NOT CMAKE_C_COMPILER_WORKS) diff --git a/Modules/CMakeTestCXXCompiler.cmake b/Modules/CMakeTestCXXCompiler.cmake index 49bf695ab..4dff11d56 100644 --- a/Modules/CMakeTestCXXCompiler.cmake +++ b/Modules/CMakeTestCXXCompiler.cmake @@ -13,6 +13,7 @@ IF(NOT CMAKE_CXX_COMPILER_WORKS) TRY_COMPILE(CMAKE_CXX_COMPILER_WORKS ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/CMakeTmp/testCXXCompiler.cxx OUTPUT_VARIABLE OUTPUT) + SET(CXX_TEST_WAS_RUN 1) ENDIF(NOT CMAKE_CXX_COMPILER_WORKS) IF(NOT CMAKE_CXX_COMPILER_WORKS) @@ -25,8 +26,11 @@ IF(NOT CMAKE_CXX_COMPILER_WORKS) "with the following output:\n ${OUTPUT}\n\n" "CMake will not be able to correctly generate this project.") ELSE(NOT CMAKE_CXX_COMPILER_WORKS) - MESSAGE(STATUS "Check for working CXX compiler: ${CMAKE_CXX_COMPILER} -- works") - FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeOutput.log - "Determining if the CXX compiler works passed with " - "the following output:\n${OUTPUT}\n\n") + IF(CXX_TEST_WAS_RUN) + MESSAGE(STATUS "Check for working CXX compiler: ${CMAKE_CXX_COMPILER} -- works") + FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeOutput.log + "Determining if the CXX compiler works passed with " + "the following output:\n${OUTPUT}\n\n") + ENDIF(CXX_TEST_WAS_RUN) + SET(CMAKE_CXX_COMPILER_WORKS 1 CACHE INTERNAL "") ENDIF(NOT CMAKE_CXX_COMPILER_WORKS) diff --git a/Modules/Platform/Windows-cl.cmake b/Modules/Platform/Windows-cl.cmake index d864a1171..7522e2c4b 100644 --- a/Modules/Platform/Windows-cl.cmake +++ b/Modules/Platform/Windows-cl.cmake @@ -1,3 +1,6 @@ +# try to load any previously computed information for C on this platform +INCLUDE( ${CMAKE_BINARY_DIR}/CMakeCPlatform.cmake OPTIONAL) + SET(CMAKE_LIBRARY_PATH_FLAG "-LIBPATH:") SET(CMAKE_LINK_LIBRARY_FLAG "") SET(WIN32 1) @@ -55,14 +58,22 @@ IF(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR CMAKE_GENERATOR MATCHES "Visual MARK_AS_ADVANCED(CMAKE_CONFIGURATION_TYPES CMAKE_CXX_STACK_SIZE CMAKE_CXX_WARNING_LEVEL) ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR CMAKE_GENERATOR MATCHES "Visual Studio 8") # does the compiler support pdbtype and is it the newer compiler -SET(CMAKE_COMPILER_SUPPORTS_PDBTYPE 1) -SET(CMAKE_COMPILER_2005 0) IF(CMAKE_GENERATOR MATCHES "Visual Studio 8") SET(CMAKE_COMPILER_2005 1) ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 8") + +# for nmake we need to compute some information about the compiler +# that is being used. +# the compiler may be free command line, 6, 7, or 71, and +# each have properties that must be determined. +# to avoid running these tests with each cmake run, the +# test results are saved in CMakeCPlatform.cmake, a file +# that is automatically copied into try_compile directories +# by the global generator. IF(CMAKE_GENERATOR MATCHES "NMake Makefiles") IF(NOT CMAKE_VC_COMPILER_TESTS_RUN) SET(CMAKE_VC_COMPILER_TESTS 1) + MESSAGE("running CMAKE_VC_COMPILER_TESTS_RUN") EXEC_PROGRAM(${CMAKE_C_COMPILER} ARGS /nologo -EP \"${CMAKE_ROOT}/Modules/CMakeTestNMakeCLVersion.c\" OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT @@ -71,9 +82,13 @@ IF(CMAKE_GENERATOR MATCHES "NMake Makefiles") IF(NOT CMAKE_COMPILER_RETURN) IF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*VERSION=1[3-9][0-9][0-9].*" ) SET(CMAKE_COMPILER_SUPPORTS_PDBTYPE 0) + ELSE("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*VERSION=1[3-9][0-9][0-9].*" ) + SET(CMAKE_COMPILER_SUPPORTS_PDBTYPE 1) ENDIF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*VERSION=1[3-9][0-9][0-9].*" ) IF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*VERSION=1[4-9][0-9][0-9].*" ) SET(CMAKE_COMPILER_2005 1) + ELSE("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*VERSION=1[4-9][0-9][0-9].*" ) + SET(CMAKE_COMPILER_2005 0) ENDIF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*VERSION=1[4-9][0-9][0-9].*" ) ENDIF(NOT CMAKE_COMPILER_RETURN) # try to figure out if we are running the free command line @@ -91,7 +106,6 @@ IF(CMAKE_GENERATOR MATCHES "NMake Makefiles") ELSE(CMAKE_COMPILER_RETURN) SET(CMAKE_USING_VC_FREE_TOOLS 0) ENDIF(CMAKE_COMPILER_RETURN) - SET(CMAKE_VC_COMPILER_TESTS_RUN 1 CACHE INTERNAL "") ENDIF(NOT CMAKE_VC_COMPILER_TESTS_RUN) ENDIF(CMAKE_GENERATOR MATCHES "NMake Makefiles") @@ -164,3 +178,8 @@ SET (CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO_INIT ${CMAKE_EXE_LINKER_FLAGS_DEBU SET (CMAKE_MODULE_LINKER_FLAGS_INIT ${CMAKE_SHARED_LINKER_FLAGS_INIT}) SET (CMAKE_MODULE_LINKER_FLAGS_DEBUG_INIT ${CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT}) SET (CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO_INIT ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT}) + + +# save computed information for this platform +CONFIGURE_FILE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake.in + ${CMAKE_BINARY_DIR}/CMakeCPlatform.cmake IMMEDIATE) diff --git a/Modules/Platform/Windows-cl.cmake.in b/Modules/Platform/Windows-cl.cmake.in new file mode 100644 index 000000000..7c42a5450 --- /dev/null +++ b/Modules/Platform/Windows-cl.cmake.in @@ -0,0 +1,4 @@ +SET(CMAKE_VC_COMPILER_TESTS_RUN 1) +SET(CMAKE_COMPILER_SUPPORTS_PDBTYPE @CMAKE_COMPILER_SUPPORTS_PDBTYPE@) +SET(CMAKE_COMPILER_2005 @CMAKE_COMPILER_2005@) +SET(CMAKE_USING_VC_FREE_TOOLS @CMAKE_USING_VC_FREE_TOOLS@)