diff options
-rw-r--r-- | Help/manual/cmake-variables.7.rst | 1 | ||||
-rw-r--r-- | Help/release/3.11.rst | 25 | ||||
-rw-r--r-- | Help/release/dev/msvc-toolset-version-variable.rst | 6 | ||||
-rw-r--r-- | Help/variable/MSVC_TOOLSET_VERSION.rst | 21 | ||||
-rw-r--r-- | Help/variable/MSVC_VERSION.rst | 3 | ||||
-rw-r--r-- | Modules/CheckIncludeFile.cmake | 3 | ||||
-rw-r--r-- | Modules/CheckIncludeFileCXX.cmake | 3 | ||||
-rw-r--r-- | Modules/CheckIncludeFiles.cmake | 3 | ||||
-rw-r--r-- | Modules/FindBoost.cmake | 33 | ||||
-rw-r--r-- | Modules/FindGTK2.cmake | 10 | ||||
-rw-r--r-- | Modules/FindIce.cmake | 20 | ||||
-rw-r--r-- | Modules/FindwxWidgets.cmake | 14 | ||||
-rw-r--r-- | Modules/InstallRequiredSystemLibraries.cmake | 105 | ||||
-rw-r--r-- | Modules/Platform/Windows-MSVC.cmake | 25 | ||||
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 178 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.h | 3 |
17 files changed, 222 insertions, 233 deletions
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 652dab8..c1b0316 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -239,6 +239,7 @@ Variables that Describe the System /variable/MSVC80 /variable/MSVC90 /variable/MSVC_IDE + /variable/MSVC_TOOLSET_VERSION /variable/MSVC_VERSION /variable/UNIX /variable/WIN32 diff --git a/Help/release/3.11.rst b/Help/release/3.11.rst index b57ac29..dbaa8af 100644 --- a/Help/release/3.11.rst +++ b/Help/release/3.11.rst @@ -127,15 +127,6 @@ Properties Modules ------- -* The :module:`CheckIncludeFile` module ``check_include_file`` macro - learned to honor the ``CMAKE_REQUIRED_LIBRARIES`` variable. - -* The :module:`CheckIncludeFileCXX` module ``check_include_file_cxx`` macro - learned to honor the ``CMAKE_REQUIRED_LIBRARIES`` variable. - -* The :module:`CheckIncludeFiles` module ``check_include_files`` macro - learned to honor the ``CMAKE_REQUIRED_LIBRARIES`` variable. - * The :module:`CheckIncludeFiles` module :command:`CHECK_INCLUDE_FILES` command gained a ``LANGUAGE`` option to specify whether to check using the ``C`` or ``CXX`` compiler. @@ -276,3 +267,19 @@ Other Changes values containing newlines are now truncated before writing to the file. In addition, a warning comment is written to the cache file, and a warning message is displayed to the user on the console. + +Updates +======= + +Changes made since CMake 3.11.0 include the following. + +3.11.1 +------ + +* The :module:`CheckIncludeFile` module ``check_include_file`` macro, + :module:`CheckIncludeFileCXX` module ``check_include_file_cxx`` macro, + and :module:`CheckIncludeFiles` module ``check_include_files`` macro + were taught to honor the ``CMAKE_REQUIRED_LIBRARIES`` variable in + CMake 3.11.0. This has been reverted due to changing behavior of + checks for existing projects. It may be restored in the future + with a policy for compatibility. diff --git a/Help/release/dev/msvc-toolset-version-variable.rst b/Help/release/dev/msvc-toolset-version-variable.rst new file mode 100644 index 0000000..28ba0b9 --- /dev/null +++ b/Help/release/dev/msvc-toolset-version-variable.rst @@ -0,0 +1,6 @@ +msvc-toolset-version-variable +----------------------------- + +* A :variable:`MSVC_TOOLSET_VERSION` variable was added to provide the + MSVC toolset version associated with the current MSVC compiler version + in :variable:`MSVC_VERSION`. diff --git a/Help/variable/MSVC_TOOLSET_VERSION.rst b/Help/variable/MSVC_TOOLSET_VERSION.rst new file mode 100644 index 0000000..77e1ea9 --- /dev/null +++ b/Help/variable/MSVC_TOOLSET_VERSION.rst @@ -0,0 +1,21 @@ +MSVC_TOOLSET_VERSION +-------------------- + +The toolset version of Microsoft Visual C/C++ being used if any. +If MSVC-like is being used, this variable is set based on the version +of the compiler as given by the :variable:`MSVC_VERSION` variable. + +Known toolset version numbers are:: + + 80 = VS 2005 (8.0) + 90 = VS 2008 (9.0) + 100 = VS 2010 (10.0) + 110 = VS 2012 (11.0) + 120 = VS 2013 (12.0) + 140 = VS 2015 (14.0) + 141 = VS 2017 (15.0) + +Compiler versions newer than those known to CMake will be reported +as the latest known toolset version. + +See also the :variable:`MSVC_VERSION` variable. diff --git a/Help/variable/MSVC_VERSION.rst b/Help/variable/MSVC_VERSION.rst index 5f70c02..4ef43d8 100644 --- a/Help/variable/MSVC_VERSION.rst +++ b/Help/variable/MSVC_VERSION.rst @@ -19,4 +19,5 @@ Known version numbers are:: 1900 = VS 14.0 (v140 toolset) 1910-1919 = VS 15.0 (v141 toolset) -See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable. +See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` and +:variable:`MSVC_TOOLSET_VERSION` variable. diff --git a/Modules/CheckIncludeFile.cmake b/Modules/CheckIncludeFile.cmake index 501fc9a..e5554c4 100644 --- a/Modules/CheckIncludeFile.cmake +++ b/Modules/CheckIncludeFile.cmake @@ -27,8 +27,6 @@ # list of macros to define (-DFOO=bar) # ``CMAKE_REQUIRED_INCLUDES`` # list of include directories -# ``CMAKE_REQUIRED_LIBRARIES`` -# list of libraries to link # ``CMAKE_REQUIRED_QUIET`` # execute quietly without messages # @@ -61,7 +59,6 @@ macro(CHECK_INCLUDE_FILE INCLUDE VARIABLE) ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.c COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} - LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILE_FLAGS} "${CHECK_INCLUDE_FILE_C_INCLUDE_DIRS}" diff --git a/Modules/CheckIncludeFileCXX.cmake b/Modules/CheckIncludeFileCXX.cmake index cdb25fb..7948bab 100644 --- a/Modules/CheckIncludeFileCXX.cmake +++ b/Modules/CheckIncludeFileCXX.cmake @@ -27,8 +27,6 @@ # list of macros to define (-DFOO=bar) # ``CMAKE_REQUIRED_INCLUDES`` # list of include directories -# ``CMAKE_REQUIRED_LIBRARIES`` -# list of libraries to link # ``CMAKE_REQUIRED_QUIET`` # execute quietly without messages # @@ -60,7 +58,6 @@ macro(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE) ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} - LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILE_FLAGS} "${CHECK_INCLUDE_FILE_CXX_INCLUDE_DIRS}" diff --git a/Modules/CheckIncludeFiles.cmake b/Modules/CheckIncludeFiles.cmake index 14db68c..59afdab 100644 --- a/Modules/CheckIncludeFiles.cmake +++ b/Modules/CheckIncludeFiles.cmake @@ -33,8 +33,6 @@ # list of macros to define (-DFOO=bar) # ``CMAKE_REQUIRED_INCLUDES`` # list of include directories -# ``CMAKE_REQUIRED_LIBRARIES`` -# list of libraries to link # ``CMAKE_REQUIRED_QUIET`` # execute quietly without messages # @@ -104,7 +102,6 @@ macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE) ${CMAKE_BINARY_DIR} ${src} COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} - LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILES_FLAGS} "${CHECK_INCLUDE_FILES_INCLUDE_DIRS}" diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 8d44aee..5b5002a 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -458,20 +458,10 @@ function(_Boost_GUESS_COMPILER_PREFIX _ret) elseif (GHSMULTI) set(_boost_COMPILER "-ghs") elseif("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC") - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10) + if(MSVC_TOOLSET_VERSION GREATER_EQUAL 141) set(_boost_COMPILER "-vc141;-vc140") - elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19) - set(_boost_COMPILER "-vc140") - elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18) - set(_boost_COMPILER "-vc120") - elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17) - set(_boost_COMPILER "-vc110") - elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16) - set(_boost_COMPILER "-vc100") - elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15) - set(_boost_COMPILER "-vc90") - elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14) - set(_boost_COMPILER "-vc80") + elseif(MSVC_TOOLSET_VERSION GREATER_EQUAL 80) + set(_boost_COMPILER "-vc${MSVC_TOOLSET_VERSION}") elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.10) set(_boost_COMPILER "-vc71") elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13) # Good luck! @@ -1009,21 +999,12 @@ function(_Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS component else() set(_arch_suffix 32) endif() - if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10) + if(MSVC_TOOLSET_VERSION GREATER_EQUAL 141) list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-14.1) list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-14.0) - elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19) - list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-14.0) - elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18) - list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-12.0) - elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17) - list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-11.0) - elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16) - list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-10.0) - elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15) - list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-9.0) - elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14) - list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-8.0) + elseif(MSVC_TOOLSET_VERSION GREATER_EQUAL 80) + math(EXPR _toolset_major_version "${MSVC_TOOLSET_VERSION} / 10") + list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-${_toolset_major_version}.0) endif() set(${componentlibvar} ${${componentlibvar}} PARENT_SCOPE) endif() diff --git a/Modules/FindGTK2.cmake b/Modules/FindGTK2.cmake index 8d0da51..15d1230 100644 --- a/Modules/FindGTK2.cmake +++ b/Modules/FindGTK2.cmake @@ -352,13 +352,9 @@ function(_GTK2_FIND_LIBRARY _var _lib _expand_vc _append_version) if(_expand_vc AND MSVC) # Add vc80/vc90/vc100 midfixes - if(MSVC_VERSION EQUAL 1400) - set(_library ${_library}-vc80) - elseif(MSVC_VERSION EQUAL 1500) - set(_library ${_library}-vc90) - elseif(MSVC_VERSION EQUAL 1600) - set(_library ${_library}-vc100) - elseif(MSVC_VERSION EQUAL 1700) + if(MSVC_TOOLSET_VERSION LESS 110) + set(_library ${_library}-vc${MSVC_TOOLSET_VERSION}) + else() # Up to gtkmm-win 2.22.0-2 there are no vc110 libraries but vc100 can be used set(_library ${_library}-vc100) endif() diff --git a/Modules/FindIce.cmake b/Modules/FindIce.cmake index b37f796..df76e5a 100644 --- a/Modules/FindIce.cmake +++ b/Modules/FindIce.cmake @@ -255,21 +255,15 @@ function(_Ice_FIND) unset(vcvers) if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10) + if(MSVC_TOOLSET_VERSION GREATER_EQUAL 141) set(vcvers "141;140") - elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19) - set(vcvers "140") - elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18) - set(vcvers "120") - elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17) - set(vcvers "110") - elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16) - set(vcvers "100") - elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15) - set(vcvers "90") + elseif(MSVC_TOOLSET_VERSION GREATER_EQUAL 100) + set(vcvers "${MSVC_TOOLSET_VERSION}") + elseif(MSVC_TOOLSET_VERSION GREATER_EQUAL 90) + set(vcvers "${MSVC_TOOLSET_VERSION}") set(vcyear "2008") - elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14) - set(vcvers "80") + elseif(MSVC_TOOLSET_VERSION GREATER_EQUAL 80) + set(vcvers "${MSVC_TOOLSET_VERSION}") set(vcyear "2005") else() # Unknown version set(vcvers Unknown) diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index 1cfc624..af997ea 100644 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake @@ -498,19 +498,7 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32") set(_WX_TOOL gcc) elseif(MSVC) set(_WX_TOOL vc) - if(NOT MSVC_VERSION LESS 1910) - set(_WX_TOOLVER 141) - elseif(NOT MSVC_VERSION LESS 1900) - set(_WX_TOOLVER 140) - elseif(NOT MSVC_VERSION LESS 1800) - set(_WX_TOOLVER 120) - elseif(NOT MSVC_VERSION LESS 1700) - set(_WX_TOOLVER 110) - elseif(NOT MSVC_VERSION LESS 1600) - set(_WX_TOOLVER 100) - elseif(NOT MSVC_VERSION LESS 1500) - set(_WX_TOOLVER 90) - endif() + set(_WX_TOOLVER ${MSVC_TOOLSET_VERSION}) if(CMAKE_SIZEOF_VOID_P EQUAL 8) set(_WX_ARCH _x64) endif() diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake index 797f9e4..50e9361 100644 --- a/Modules/InstallRequiredSystemLibraries.cmake +++ b/Modules/InstallRequiredSystemLibraries.cmake @@ -121,9 +121,7 @@ if(MSVC) ) endif() - if(MSVC_VERSION EQUAL 1400) - set(MSVC_REDIST_NAME VC80) - + if(MSVC_TOOLSET_VERSION EQUAL 80) # Find the runtime library redistribution directory. get_filename_component(msvc_install_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0;InstallDir]" ABSOLUTE) @@ -163,9 +161,7 @@ if(MSVC) endif() endif() - if(MSVC_VERSION EQUAL 1500) - set(MSVC_REDIST_NAME VC90) - + if(MSVC_TOOLSET_VERSION EQUAL 90) # Find the runtime library redistribution directory. get_filename_component(msvc_install_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\9.0;InstallDir]" ABSOLUTE) @@ -209,34 +205,31 @@ if(MSVC) endif() set(MSVC_REDIST_NAME "") - set(_MSVCRT_DLL_VERSION "") - set(_MSVCRT_IDE_VERSION "") + set(_MSVC_DLL_VERSION "") + set(_MSVC_IDE_VERSION "") if(MSVC_VERSION GREATER_EQUAL 2000) message(WARNING "MSVC ${MSVC_VERSION} not yet supported.") - elseif(MSVC_VERSION GREATER_EQUAL 1911) - set(MSVC_REDIST_NAME VC141) - set(_MSVCRT_DLL_VERSION 140) - set(_MSVCRT_IDE_VERSION 15) - elseif(MSVC_VERSION EQUAL 1910) - set(MSVC_REDIST_NAME VC150) - set(_MSVCRT_DLL_VERSION 140) - set(_MSVCRT_IDE_VERSION 15) - elseif(MSVC_VERSION EQUAL 1900) - set(MSVC_REDIST_NAME VC140) - set(_MSVCRT_DLL_VERSION 140) - set(_MSVCRT_IDE_VERSION 14) - elseif(MSVC_VERSION EQUAL 1800) - set(MSVC_REDIST_NAME VC120) - set(_MSVCRT_DLL_VERSION 120) - set(_MSVCRT_IDE_VERSION 12) - elseif(MSVC_VERSION EQUAL 1700) - set(MSVC_REDIST_NAME VC110) - set(_MSVCRT_DLL_VERSION 110) - set(_MSVCRT_IDE_VERSION 11) - elseif(MSVC_VERSION EQUAL 1600) - set(MSVC_REDIST_NAME VC100) - set(_MSVCRT_DLL_VERSION 100) - set(_MSVCRT_IDE_VERSION 10) + elseif(MSVC_TOOLSET_VERSION) + set(MSVC_REDIST_NAME VC${MSVC_TOOLSET_VERSION}) + if(MSVC_VERSION EQUAL 1910) + # VS2017 named this differently prior to update 3. + set(MSVC_REDIST_NAME VC150) + endif() + + math(EXPR _MSVC_DLL_VERSION "${MSVC_TOOLSET_VERSION} / 10 * 10") + + if(MSVC_TOOLSET_VERSION EQUAL 141) + set(_MSVC_IDE_VERSION 15) + else() + math(EXPR _MSVC_IDE_VERSION "${MSVC_TOOLSET_VERSION} / 10") + endif() + endif() + + set(_MSVCRT_DLL_VERSION "") + set(_MSVCRT_IDE_VERSION "") + if(_MSVC_IDE_VERSION GREATER_EQUAL 10) + set(_MSVCRT_DLL_VERSION "${_MSVC_DLL_VERSION}") + set(_MSVCRT_IDE_VERSION "${_MSVC_IDE_VERSION}") endif() if(_MSVCRT_DLL_VERSION) @@ -433,23 +426,9 @@ if(MSVC) set(_MFC_DLL_VERSION "") set(_MFC_IDE_VERSION "") - if(MSVC_VERSION GREATER_EQUAL 2000) - # Version not yet supported. - elseif(MSVC_VERSION GREATER_EQUAL 1910) - set(_MFC_DLL_VERSION 140) - set(_MFC_IDE_VERSION 15) - elseif(MSVC_VERSION EQUAL 1900) - set(_MFC_DLL_VERSION 140) - set(_MFC_IDE_VERSION 14) - elseif(MSVC_VERSION EQUAL 1800) - set(_MFC_DLL_VERSION 120) - set(_MFC_IDE_VERSION 12) - elseif(MSVC_VERSION EQUAL 1700) - set(_MFC_DLL_VERSION 110) - set(_MFC_IDE_VERSION 11) - elseif(MSVC_VERSION EQUAL 1600) - set(_MFC_DLL_VERSION 100) - set(_MFC_IDE_VERSION 10) + if(_MSVC_IDE_VERSION GREATER_EQUAL 10) + set(_MFC_DLL_VERSION ${_MSVC_DLL_VERSION}) + set(_MFC_IDE_VERSION ${_MSVC_IDE_VERSION}) endif() if(_MFC_DLL_VERSION) @@ -520,32 +499,8 @@ if(MSVC) # MSVC 8 was the first version with OpenMP # Furthermore, there is no debug version of this if(CMAKE_INSTALL_OPENMP_LIBRARIES AND _IRSL_HAVE_MSVC) - set(_MSOMP_DLL_VERSION "") - set(_MSOMP_IDE_VERSION "") - if(MSVC_VERSION GREATER_EQUAL 2000) - # Version not yet supported. - elseif(MSVC_VERSION GREATER_EQUAL 1910) - set(_MSOMP_DLL_VERSION 140) - set(_MSOMP_IDE_VERSION 15) - elseif(MSVC_VERSION EQUAL 1900) - set(_MSOMP_DLL_VERSION 140) - set(_MSOMP_IDE_VERSION 14) - elseif(MSVC_VERSION EQUAL 1800) - set(_MSOMP_DLL_VERSION 120) - set(_MSOMP_IDE_VERSION 12) - elseif(MSVC_VERSION EQUAL 1700) - set(_MSOMP_DLL_VERSION 110) - set(_MSOMP_IDE_VERSION 11) - elseif(MSVC_VERSION EQUAL 1600) - set(_MSOMP_DLL_VERSION 100) - set(_MSOMP_IDE_VERSION 10) - elseif(MSVC_VERSION EQUAL 1500) - set(_MSOMP_DLL_VERSION 90) - set(_MSOMP_IDE_VERSION 9) - elseif(MSVC_VERSION EQUAL 1400) - set(_MSOMP_DLL_VERSION 80) - set(_MSOMP_IDE_VERSION 8) - endif() + set(_MSOMP_DLL_VERSION ${_MSVC_DLL_VERSION}) + set(_MSOMP_IDE_VERSION ${_MSVC_IDE_VERSION}) if(_MSOMP_DLL_VERSION) set(v "${_MSOMP_DLL_VERSION}") diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index a1f54c0..ae180ed 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -71,6 +71,31 @@ if(NOT MSVC_VERSION) message(FATAL_ERROR "MSVC compiler version not detected properly: ${_compiler_version}") endif() + if(MSVC_VERSION GREATER_EQUAL 1910) + # VS 2017 or greater + set(MSVC_TOOLSET_VERSION 141) + elseif(MSVC_VERSION EQUAL 1900) + # VS 2015 + set(MSVC_TOOLSET_VERSION 140) + elseif(MSVC_VERSION EQUAL 1800) + # VS 2013 + set(MSVC_TOOLSET_VERSION 120) + elseif(MSVC_VERSION EQUAL 1700) + # VS 2012 + set(MSVC_TOOLSET_VERSION 110) + elseif(MSVC_VERSION EQUAL 1600) + # VS 2010 + set(MSVC_TOOLSET_VERSION 100) + elseif(MSVC_VERSION EQUAL 1500) + # VS 2008 + set(MSVC_TOOLSET_VERSION 90) + elseif(MSVC_VERSION EQUAL 1400) + # VS 2005 + set(MSVC_TOOLSET_VERSION 80) + else() + # We don't support MSVC_TOOLSET_VERSION for earlier compiler. + endif() + set(MSVC10) set(MSVC11) set(MSVC12) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 0f1a352..a173a1e 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 11) -set(CMake_VERSION_PATCH 20180404) +set(CMake_VERSION_PATCH 20180405) #set(CMake_VERSION_RC 1) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 4bd07ef..1817153 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -33,6 +33,7 @@ struct cmVisualStudio10TargetGenerator::Elem cmGeneratedFileStream& S; int Indent; bool HasElements = false; + const char* Tag = nullptr; Elem(cmGeneratedFileStream& s, int i) : S(s) @@ -46,25 +47,45 @@ struct cmVisualStudio10TargetGenerator::Elem { par.SetHasElements(); } + Elem(Elem& par, const char* tag) + : S(par.S) + , Indent(par.Indent + 1) + { + par.SetHasElements(); + this->StartElement(tag); + } void SetHasElements() { if (!HasElements) { - S << ">\n"; + this->S << ">\n"; HasElements = true; } } + cmGeneratedFileStream& WriteString(const char* line); + void StartElement(const char* tag) + { + this->Tag = tag; + this->WriteString("<") << tag; + } + template <typename T> + void WriteElem(const char* tag, const T& val) + { + this->WriteString("<") << tag << ">" << val << "</" << tag << ">\n"; + } + template <typename T> + void Attr(const char* an, const T& av) + { + this->S << " " << an << "=\"" << av << "\""; + } void WriteEndTag(const char* tag) { if (HasElements) { - S.fill(' '); - S.width(Indent * 2); - // write an empty string to get the fill level indent to print - S << ""; - S << "</" << tag << ">\n"; + this->WriteString("</") << tag << ">\n"; } else { - S << " />\n"; + this->S << " />\n"; } } + void EndElement() { this->WriteEndTag(this->Tag); } }; class cmVS10GeneratorOptions : public cmVisualStudioGeneratorOptions @@ -102,16 +123,14 @@ inline void cmVisualStudio10TargetGenerator::WriteElem(const char* tag, const char* val, int indentLevel) { - this->WriteString("<", indentLevel); - (*this->BuildFileStream) << tag << ">" << val << "</" << tag << ">\n"; + Elem(*this->BuildFileStream, indentLevel).WriteElem(tag, val); } inline void cmVisualStudio10TargetGenerator::WriteElem(const char* tag, std::string const& val, int indentLevel) { - this->WriteString("<", indentLevel); - (*this->BuildFileStream) << tag << ">" << val << "</" << tag << ">\n"; + Elem(*this->BuildFileStream, indentLevel).WriteElem(tag, val); } inline void cmVisualStudio10TargetGenerator::WriteElemEscapeXML( @@ -247,14 +266,21 @@ void cmVisualStudio10TargetGenerator::WritePlatformConfigTag( } } +cmGeneratedFileStream& cmVisualStudio10TargetGenerator::Elem::WriteString( + const char* line) +{ + this->S.fill(' '); + this->S.width(this->Indent * 2); + // write an empty string to get the fill level indent to print + this->S << ""; + this->S << line; + return this->S; +} + void cmVisualStudio10TargetGenerator::WriteString(const char* line, int indentLevel) { - this->BuildFileStream->fill(' '); - this->BuildFileStream->width(indentLevel * 2); - // write an empty string to get the fill level indent to print - (*this->BuildFileStream) << ""; - (*this->BuildFileStream) << line; + Elem(*this->BuildFileStream, indentLevel).WriteString(line); } #define VS10_CXX_DEFAULT_PROPS "$(VCTargetsPath)\\Microsoft.Cpp.Default.props" @@ -1373,71 +1399,72 @@ void cmVisualStudio10TargetGenerator::WriteGroups() fout.SetCopyIfDifferent(true); char magic[] = { char(0xEF), char(0xBB), char(0xBF) }; fout.write(magic, 3); - cmGeneratedFileStream* save = this->BuildFileStream; - this->BuildFileStream = &fout; // get the tools version to use const std::string toolsVer(this->GlobalGenerator->GetToolsVersion()); - std::string project_defaults = "<?xml version=\"1.0\" encoding=\"" + - this->GlobalGenerator->Encoding() + "\"?>\n"; - project_defaults.append("<Project ToolsVersion=\""); - project_defaults.append(toolsVer + "\" "); - project_defaults.append( - "xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n"); - this->WriteString(project_defaults.c_str(), 0); + fout << "<?xml version=\"1.0\" encoding=\"" + << this->GlobalGenerator->Encoding() << "\"?>\n"; + + Elem e0(fout, 0); + e0.StartElement("Project"); + e0.Attr("ToolsVersion", toolsVer); + e0.Attr("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003"); + e0.SetHasElements(); for (auto const& ti : this->Tools) { - this->WriteGroupSources(ti.first.c_str(), ti.second, sourceGroups); + this->WriteGroupSources(e0, ti.first, ti.second, sourceGroups); } // Added files are images and the manifest. if (!this->AddedFiles.empty()) { - this->WriteString("<ItemGroup>\n", 1); + Elem e1(e0, "ItemGroup"); + e1.SetHasElements(); for (std::string const& oi : this->AddedFiles) { std::string fileName = cmSystemTools::LowerCase(cmSystemTools::GetFilenameName(oi)); if (fileName == "wmappmanifest.xml") { - this->WriteString("<XML Include=\"", 2); - (*this->BuildFileStream) << oi << "\">\n"; - this->WriteElem("Filter", "Resource Files", 3); - this->WriteString("</XML>\n", 2); + Elem e2(e1, "XML"); + e2.Attr("Include", oi); + Elem(e2).WriteElem("Filter", "Resource Files"); + e2.EndElement(); } else if (cmSystemTools::GetFilenameExtension(fileName) == ".appxmanifest") { - this->WriteString("<AppxManifest Include=\"", 2); - (*this->BuildFileStream) << oi << "\">\n"; - this->WriteElem("Filter", "Resource Files", 3); - this->WriteString("</AppxManifest>\n", 2); + Elem e2(e1, "AppxManifest"); + e2.Attr("Include", oi); + Elem(e2).WriteElem("Filter", "Resource Files"); + e2.EndElement(); } else if (cmSystemTools::GetFilenameExtension(fileName) == ".pfx") { - this->WriteString("<None Include=\"", 2); - (*this->BuildFileStream) << oi << "\">\n"; - this->WriteElem("Filter", "Resource Files", 3); - this->WriteString("</None>\n", 2); + Elem e2(e1, "None"); + e2.Attr("Include", oi); + Elem(e2).WriteElem("Filter", "Resource Files"); + e2.EndElement(); } else { - this->WriteString("<Image Include=\"", 2); - (*this->BuildFileStream) << oi << "\">\n"; - this->WriteElem("Filter", "Resource Files", 3); - this->WriteString("</Image>\n", 2); + Elem e2(e1, "Image"); + e2.Attr("Include", oi); + Elem(e2).WriteElem("Filter", "Resource Files"); + e2.EndElement(); } } - this->WriteString("</ItemGroup>\n", 1); + e1.EndElement(); } std::vector<cmSourceFile const*> resxObjs; this->GeneratorTarget->GetResxSources(resxObjs, ""); if (!resxObjs.empty()) { - this->WriteString("<ItemGroup>\n", 1); + Elem e1(e0, "ItemGroup"); for (cmSourceFile const* oi : resxObjs) { std::string obj = oi->GetFullPath(); - this->WriteString("<EmbeddedResource Include=\"", 2); ConvertToWindowsSlash(obj); - (*this->BuildFileStream) << cmVS10EscapeXML(obj) << "\">\n"; - this->WriteElem("Filter", "Resource Files", 3); - this->WriteString("</EmbeddedResource>\n", 2); + Elem e2(e1, "EmbeddedResource"); + e2.Attr("Include", cmVS10EscapeXML(obj)); + Elem(e2).WriteElem("Filter", "Resource Files"); + e2.EndElement(); } - this->WriteString("</ItemGroup>\n", 1); + e1.EndElement(); } - this->WriteString("<ItemGroup>\n", 1); + Elem e1(e0, "ItemGroup"); + e1.SetHasElements(); std::vector<cmSourceGroup*> groupsVec(groupsUsed.begin(), groupsUsed.end()); std::sort(groupsVec.begin(), groupsVec.end(), [](cmSourceGroup* l, cmSourceGroup* r) { @@ -1446,31 +1473,29 @@ void cmVisualStudio10TargetGenerator::WriteGroups() for (cmSourceGroup* sg : groupsVec) { std::string const& name = sg->GetFullName(); if (!name.empty()) { - this->WriteString("<Filter Include=\"", 2); - (*this->BuildFileStream) << name << "\">\n"; - std::string guidName = "SG_Filter_"; - guidName += name; + std::string guidName = "SG_Filter_" + name; std::string guid = this->GlobalGenerator->GetGUID(guidName); - this->WriteElem("UniqueIdentifier", "{" + guid + "}", 3); - this->WriteString("</Filter>\n", 2); + Elem e2(e1, "Filter"); + e2.Attr("Include", name); + Elem(e2).WriteElem("UniqueIdentifier", "{" + guid + "}"); + e2.EndElement(); } } if (!resxObjs.empty() || !this->AddedFiles.empty()) { - this->WriteString("<Filter Include=\"Resource Files\">\n", 2); std::string guidName = "SG_Filter_Resource Files"; std::string guid = this->GlobalGenerator->GetGUID(guidName); - this->WriteElem("UniqueIdentifier", "{" + guid + "}", 3); - this->WriteString("<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;", 3); - (*this->BuildFileStream) << "gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;"; - (*this->BuildFileStream) << "mfcribbon-ms</Extensions>\n"; - this->WriteString("</Filter>\n", 2); + Elem e2(e1, "Filter"); + e2.Attr("Include", "Resource Files"); + Elem(e2).WriteElem("UniqueIdentifier", "{" + guid + "}"); + Elem(e2).WriteElem("Extensions", + "rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;" + "gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms"); + e2.EndElement(); } - this->WriteString("</ItemGroup>\n", 1); - this->WriteString("</Project>\n", 0); - // restore stream pointer - this->BuildFileStream = save; + e1.EndElement(); + e0.EndElement(); if (fout.Close()) { this->GlobalGenerator->FileReplacedDuringGenerate(path); @@ -1515,30 +1540,27 @@ void cmVisualStudio10TargetGenerator::AddMissingSourceGroups( } void cmVisualStudio10TargetGenerator::WriteGroupSources( - std::string const& name, ToolSources const& sources, + Elem& e0, std::string const& name, ToolSources const& sources, std::vector<cmSourceGroup>& sourceGroups) { - this->WriteString("<ItemGroup>\n", 1); + Elem e1(e0, "ItemGroup"); + e1.SetHasElements(); for (ToolSource const& s : sources) { cmSourceFile const* sf = s.SourceFile; std::string const& source = sf->GetFullPath(); cmSourceGroup* sourceGroup = this->Makefile->FindSourceGroup(source, sourceGroups); std::string const& filter = sourceGroup->GetFullName(); - this->WriteString("<", 2); std::string path = this->ConvertPath(source, s.RelativePath); ConvertToWindowsSlash(path); - (*this->BuildFileStream) << name << " Include=\"" << cmVS10EscapeXML(path); + Elem e2(e1, name.c_str()); + e2.Attr("Include", cmVS10EscapeXML(path)); if (!filter.empty()) { - (*this->BuildFileStream) << "\">\n"; - this->WriteElem("Filter", filter, 3); - this->WriteString("</", 2); - (*this->BuildFileStream) << name << ">\n"; - } else { - (*this->BuildFileStream) << "\" />\n"; + Elem(e2).WriteElem("Filter", filter); } + e2.EndElement(); } - this->WriteString("</ItemGroup>\n", 1); + e1.EndElement(); } void cmVisualStudio10TargetGenerator::WriteHeaderSource(cmSourceFile const* sf) diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 7106737..4df03b6 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -158,7 +158,8 @@ private: void WriteEvent(const char* name, std::vector<cmCustomCommand> const& commands, std::string const& configName); - void WriteGroupSources(std::string const& name, ToolSources const& sources, + void WriteGroupSources(Elem& e0, std::string const& name, + ToolSources const& sources, std::vector<cmSourceGroup>&); void AddMissingSourceGroups(std::set<cmSourceGroup*>& groupsUsed, const std::vector<cmSourceGroup>& allGroups); |