Commit 308d21b2 authored by Brad King's avatar Brad King Committed by Kitware Robot
Browse files

Merge topic 'msvc-toolset-version-variable'

45bf6f62 Modules: Use MSVC_TOOLSET_VERSION variable to simplify logic
304f493e

 MSVC: Add MSVC_TOOLSET_VERSION variable
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !1882
parents 43e44bcd 45bf6f62
......@@ -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
......
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`.
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.
......@@ -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.
......@@ -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()
......
......@@ -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()
......
......@@ -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)
......
......@@ -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()
......
......@@ -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}")
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment