diff options
author | Brad King <brad.king@kitware.com> | 2012-08-23 15:20:48 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2012-08-30 13:42:40 (GMT) |
commit | 485a940e4c2b07f08e70b6e04733feb724bb6f3f (patch) | |
tree | b9d56a7526ba4a951d6c8e83f9c83053cb44c809 | |
parent | 32db033b2713d40899865a06f03d83373078eaa3 (diff) | |
download | CMake-485a940e4c2b07f08e70b6e04733feb724bb6f3f.zip CMake-485a940e4c2b07f08e70b6e04733feb724bb6f3f.tar.gz CMake-485a940e4c2b07f08e70b6e04733feb724bb6f3f.tar.bz2 |
VS: Simplify MSVC version reporting
Teach Windows-cl.cmake to use CMAKE_(C|CXX)_COMPILER_VERSION to set the
"MSVC##" and MSVC_VERSION variables. It no longer needs the IDE generator
to dictate the version or to detect the version by running the
command-line tool for NMake and Ninja generators. Drop configuration of
CMakeCPlatform.cmake and CMakeCXXPlatform.cmake from Windows-cl.cmake.in
because all the results it saved are now cheap to compute every time.
-rw-r--r-- | Modules/CMakeTestCCompiler.cmake | 5 | ||||
-rw-r--r-- | Modules/CMakeTestCXXCompiler.cmake | 5 | ||||
-rw-r--r-- | Modules/CMakeTestNMakeCLVersion.c | 2 | ||||
-rw-r--r-- | Modules/Platform/Windows-cl.cmake | 127 | ||||
-rw-r--r-- | Modules/Platform/Windows-cl.cmake.in | 13 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio10Generator.cxx | 1 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio11Generator.cxx | 1 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio6Generator.cxx | 1 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio71Generator.cxx | 1 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio7Generator.cxx | 1 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio8Generator.cxx | 1 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio9Generator.cxx | 1 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudioGenerator.cxx | 6 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudioGenerator.h | 1 |
14 files changed, 42 insertions, 124 deletions
diff --git a/Modules/CMakeTestCCompiler.cmake b/Modules/CMakeTestCCompiler.cmake index 14291a7..c8f4d49 100644 --- a/Modules/CMakeTestCCompiler.cmake +++ b/Modules/CMakeTestCCompiler.cmake @@ -44,11 +44,6 @@ if(NOT CMAKE_C_COMPILER_WORKS) file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the C compiler works failed with " "the following output:\n${__CMAKE_C_COMPILER_OUTPUT}\n\n") - # if the compiler is broken make sure to remove the platform file - # since Windows-cl configures both c/cxx files both need to be removed - # when c or c++ fails - file(REMOVE ${CMAKE_PLATFORM_ROOT_BIN}/CMakeCPlatform.cmake ) - file(REMOVE ${CMAKE_PLATFORM_ROOT_BIN}/CMakeCXXPlatform.cmake ) message(FATAL_ERROR "The C compiler \"${CMAKE_C_COMPILER}\" " "is not able to compile a simple test program.\nIt fails " "with the following output:\n ${__CMAKE_C_COMPILER_OUTPUT}\n\n" diff --git a/Modules/CMakeTestCXXCompiler.cmake b/Modules/CMakeTestCXXCompiler.cmake index 5ed826b..3aa2075 100644 --- a/Modules/CMakeTestCXXCompiler.cmake +++ b/Modules/CMakeTestCXXCompiler.cmake @@ -34,11 +34,6 @@ endif() if(NOT CMAKE_CXX_COMPILER_WORKS) PrintTestCompilerStatus("CXX" " -- broken") - # if the compiler is broken make sure to remove the platform file - # since Windows-cl configures both c/cxx files both need to be removed - # when c or c++ fails - file(REMOVE ${CMAKE_PLATFORM_ROOT_BIN}/CMakeCPlatform.cmake ) - file(REMOVE ${CMAKE_PLATFORM_ROOT_BIN}/CMakeCXXPlatform.cmake ) file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the CXX compiler works failed with " "the following output:\n${__CMAKE_CXX_COMPILER_OUTPUT}\n\n") diff --git a/Modules/CMakeTestNMakeCLVersion.c b/Modules/CMakeTestNMakeCLVersion.c deleted file mode 100644 index 3cece2a..0000000 --- a/Modules/CMakeTestNMakeCLVersion.c +++ /dev/null @@ -1,2 +0,0 @@ -VERSION=_MSC_VER - diff --git a/Modules/Platform/Windows-cl.cmake b/Modules/Platform/Windows-cl.cmake index 265f555..293f19c 100644 --- a/Modules/Platform/Windows-cl.cmake +++ b/Modules/Platform/Windows-cl.cmake @@ -1,8 +1,3 @@ -# try to load any previously computed information for C on this platform -include( ${CMAKE_PLATFORM_ROOT_BIN}/CMakeCPlatform.cmake OPTIONAL) -# try to load any previously computed information for CXX on this platform -include( ${CMAKE_PLATFORM_ROOT_BIN}/CMakeCXXPlatform.cmake OPTIONAL) - set(WIN32 1) include(Platform/cl) @@ -19,81 +14,54 @@ if(NOT CMAKE_NO_BUILD_TYPE AND CMAKE_GENERATOR MATCHES "Visual Studio") "Semicolon separated list of supported configuration types, only supports Debug, Release, MinSizeRel, and RelWithDebInfo, anything else will be ignored.") mark_as_advanced(CMAKE_CONFIGURATION_TYPES) endif() -# does the compiler support pdbtype and is it the newer compiler -if(CMAKE_GENERATOR MATCHES "Visual Studio 8") - set(CMAKE_COMPILER_2005 1) -endif() # make sure to enable languages after setting configuration types enable_language(RC) set(CMAKE_COMPILE_RESOURCE "rc <FLAGS> /fo<OBJECT> <SOURCE>") -# for nmake we need to compute some information about the compiler -# that is being used. -# 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. -set(MSVC_IDE 1) -if(CMAKE_GENERATOR MATCHES "Makefiles" OR CMAKE_GENERATOR MATCHES "Ninja") +if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") set(MSVC_IDE 0) - if(NOT CMAKE_VC_COMPILER_TESTS_RUN) - set(CMAKE_VC_COMPILER_TESTS 1) - set(testNmakeCLVersionFile - "${CMAKE_ROOT}/Modules/CMakeTestNMakeCLVersion.c") - string(REGEX REPLACE "/" "\\\\" testNmakeCLVersionFile "${testNmakeCLVersionFile}") - message(STATUS "Check for CL compiler version") - set(CMAKE_TEST_COMPILER ${CMAKE_C_COMPILER}) - if (NOT CMAKE_C_COMPILER) - set(CMAKE_TEST_COMPILER ${CMAKE_CXX_COMPILER}) - endif() - exec_program(${CMAKE_TEST_COMPILER} - ARGS /nologo -EP \"${testNmakeCLVersionFile}\" - OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT - RETURN_VALUE CMAKE_COMPILER_RETURN - ) - if(NOT CMAKE_COMPILER_RETURN) - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining the version of compiler passed with the following output:\n" - "${CMAKE_COMPILER_OUTPUT}\n\n") - string(REGEX REPLACE "\n" " " compilerVersion "${CMAKE_COMPILER_OUTPUT}") - string(REGEX REPLACE ".*VERSION=(.*)" "\\1" - compilerVersion "${compilerVersion}") - message(STATUS "Check for CL compiler version - ${compilerVersion}") - set(MSVC60) - set(MSVC70) - set(MSVC71) - set(MSVC80) - set(CMAKE_COMPILER_2005) - if("${compilerVersion}" LESS 1300) - set(MSVC60 1) - set(CMAKE_COMPILER_SUPPORTS_PDBTYPE 1) - endif() - if("${compilerVersion}" EQUAL 1300) - set(MSVC70 1) - set(CMAKE_COMPILER_SUPPORTS_PDBTYPE 0) - endif() - if("${compilerVersion}" EQUAL 1310) - set(MSVC71 1) - set(CMAKE_COMPILER_SUPPORTS_PDBTYPE 0) - endif() - if("${compilerVersion}" EQUAL 1400) - set(MSVC80 1) - set(CMAKE_COMPILER_2005 1) - endif() - if("${compilerVersion}" EQUAL 1500) - set(MSVC90 1) - endif() - if("${compilerVersion}" EQUAL 1600) - set(MSVC10 1) - endif() - set(MSVC_VERSION "${compilerVersion}") - else() - message(STATUS "Check for CL compiler version - failed") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining the version of compiler failed with the following output:\n" - "${CMAKE_COMPILER_OUTPUT}\n\n") - endif() +else() + set(MSVC_IDE 1) +endif() + +if(NOT MSVC_VERSION) + if(CMAKE_C_COMPILER_VERSION) + set(_compiler_version ${CMAKE_C_COMPILER_VERSION}) + else() + set(_compiler_version ${CMAKE_CXX_COMPILER_VERSION}) + endif() + if("${_compiler_version}" MATCHES "^([0-9]+)\\.([0-9]+)") + math(EXPR MSVC_VERSION "${CMAKE_MATCH_1}*100 + ${CMAKE_MATCH_2}") + else() + message(FATAL_ERROR "MSVC compiler version not detected properly: ${_compiler_version}") + endif() + + set(MSVC10) + set(MSVC11) + set(MSVC60) + set(MSVC70) + set(MSVC71) + set(MSVC80) + set(MSVC90) + set(CMAKE_COMPILER_2005) + set(CMAKE_COMPILER_SUPPORTS_PDBTYPE) + if(NOT "${_compiler_version}" VERSION_LESS 17) + set(MSVC11 1) + elseif(NOT "${_compiler_version}" VERSION_LESS 16) + set(MSVC10 1) + elseif(NOT "${_compiler_version}" VERSION_LESS 15) + set(MSVC90 1) + elseif(NOT "${_compiler_version}" VERSION_LESS 14) + set(MSVC80 1) + set(CMAKE_COMPILER_2005 1) + elseif(NOT "${_compiler_version}" VERSION_LESS 13.10) + set(MSVC71 1) + elseif(NOT "${_compiler_version}" VERSION_LESS 13) + set(MSVC70 1) + else() + set(MSVC60 1) + set(CMAKE_COMPILER_SUPPORTS_PDBTYPE 1) endif() endif() @@ -195,14 +163,3 @@ 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}) set (CMAKE_MODULE_LINKER_FLAGS_RELEASE_INIT ${CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT}) set (CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL_INIT ${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT}) - -# save computed information for this platform -if(NOT EXISTS "${CMAKE_PLATFORM_ROOT_BIN}/CMakeCPlatform.cmake") - configure_file(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake.in - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCPlatform.cmake IMMEDIATE) -endif() - -if(NOT EXISTS "${CMAKE_PLATFORM_ROOT_BIN}/CMakeCXXPlatform.cmake") - configure_file(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake.in - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCXXPlatform.cmake IMMEDIATE) -endif() diff --git a/Modules/Platform/Windows-cl.cmake.in b/Modules/Platform/Windows-cl.cmake.in deleted file mode 100644 index 1a65004..0000000 --- a/Modules/Platform/Windows-cl.cmake.in +++ /dev/null @@ -1,13 +0,0 @@ -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_CL_64 @CMAKE_CL_64@) -set(MSVC60 @MSVC60@) -set(MSVC70 @MSVC70@) -set(MSVC71 @MSVC71@) -set(MSVC80 @MSVC80@) -set(MSVC90 @MSVC90@) -set(MSVC10 @MSVC10@) -set(MSVC_IDE @MSVC_IDE@) -set(MSVC_VERSION @MSVC_VERSION@) -set(WIN32 1) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 39c9ae1..d188980 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -19,7 +19,6 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator() { - this->VersionId = "MSVC10"; this->FindMakeProgramFile = "CMakeVS10FindMake.cmake"; std::string vc10Express; this->ExpressEdition = cmSystemTools::ReadRegistryValue( diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index ab1187d..7bb4d0c 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -16,7 +16,6 @@ //---------------------------------------------------------------------------- cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator() { - this->VersionId = "MSVC11"; this->FindMakeProgramFile = "CMakeVS11FindMake.cmake"; this->ExpressEdition = false; // TODO: VS 11 Express support this->PlatformToolset = "v110"; diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index ca06b66..e8ca788 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -32,7 +32,6 @@ std::string GetVS6TargetName(const std::string& targetName) cmGlobalVisualStudio6Generator::cmGlobalVisualStudio6Generator() { - this->VersionId = "MSVC60"; this->FindMakeProgramFile = "CMakeVS6FindMake.cmake"; } diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index d99fa03..ab2308f 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -18,7 +18,6 @@ //---------------------------------------------------------------------------- cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator() { - this->VersionId = "MSVC71"; this->FindMakeProgramFile = "CMakeVS71FindMake.cmake"; this->ProjectConfigurationSectionName = "ProjectConfiguration"; } diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 0567d55..b6eea5d 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -18,7 +18,6 @@ cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator() { - this->VersionId = "MSVC70"; this->FindMakeProgramFile = "CMakeVS7FindMake.cmake"; } diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index f469188..2e3b530 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -19,7 +19,6 @@ //---------------------------------------------------------------------------- cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator() { - this->VersionId = "MSVC80"; this->FindMakeProgramFile = "CMakeVS8FindMake.cmake"; this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms"; } diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index 531395b..70af50d 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -19,7 +19,6 @@ cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator() { - this->VersionId = "MSVC90"; this->FindMakeProgramFile = "CMakeVS9FindMake.cmake"; } diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index feb3ac9..0968b77 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -22,7 +22,6 @@ cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator() { this->ArchitectureId = "X86"; - this->VersionId = 0; } //---------------------------------------------------------------------------- @@ -495,11 +494,6 @@ void cmGlobalVisualStudioGenerator::AddPlatformDefinitions(cmMakefile* mf) { mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", this->ArchitectureId); mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", this->ArchitectureId); - - if (this->VersionId) - { - mf->AddDefinition(this->VersionId, "1"); - } } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index a042dc0..cebf7d7 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -99,7 +99,6 @@ protected: typedef std::map<cmTarget*, cmStdString> UtilityDependsMap; UtilityDependsMap UtilityDepends; const char* ArchitectureId; - const char* VersionId; private: void ComputeTargetObjects(cmGeneratorTarget* gt) const; |