1 # - Find MS Visual C++
\r
3 # VC_DIR - where to find Visual C++
\r
4 # VC_INCLUDE_DIR - where to find headers
\r
5 # VC_INCLUDE_DIRS - where to find headers
\r
6 # VC_LIBRARY_DIR - where to find libraries
\r
7 # VC_FOUND - True if MSVC found
\r
9 IF(CMAKE_CXX_COMPILER)
\r
10 SET(_COMPILER ${CMAKE_CXX_COMPILER})
\r
11 SET(_VERSION ${CMAKE_CXX_COMPILER_VERSION})
\r
12 ELSEIF(CMAKE_C_COMPILER)
\r
13 SET(_COMPILER ${CMAKE_C_COMPILER})
\r
14 SET(_VERSION ${CMAKE_C_COMPILER_VERSION})
\r
16 MESSAGE(FATAL_ERROR "No way to determine Visual C++ location")
\r
19 IF(MSVC_VERSION LESS 1910)
\r
20 IF(MSVC_VERSION LESS 1500)
\r
21 MESSAGE(FATAL_ERROR "Unsupported version of Visual C++ (minimum version is 2008)")
\r
22 ELSEIF(MSVC_VERSION LESS 1600)
\r
23 SET(MSVC_TOOLSET "90")
\r
25 ELSEIF(MSVC_VERSION LESS 1700)
\r
26 SET(MSVC_TOOLSET "100")
\r
28 ELSEIF(MSVC_VERSION LESS 1800)
\r
29 SET(MSVC_TOOLSET "110")
\r
31 ELSEIF(MSVC_VERSION LESS 1900)
\r
32 SET(MSVC_TOOLSET "120")
\r
35 SET(MSVC_TOOLSET "140")
\r
39 STRING(REGEX REPLACE "/bin/.+" "" VC_DIR ${_COMPILER})
\r
41 MESSAGE(STATUS "Found Visual C++ ${_NAME} (${_VERSION}) in ${VC_DIR}")
\r
43 # Toolset = version of runtime DLLs
\r
44 SET(MSVC_TOOLSET "140")
\r
46 IF(MSVC_VERSION LESS 1920)
\r
52 STRING(REGEX REPLACE "/MSVC/.+" "/MSVC" VC_DIR ${_COMPILER})
\r
54 FILE(GLOB MSVC_TOOLCHAIN_VERSIONS RELATIVE ${VC_DIR} "${VC_DIR}/*")
\r
56 IF(MSVC_TOOLCHAIN_VERSIONS)
\r
57 LIST(SORT MSVC_TOOLCHAIN_VERSIONS)
\r
58 LIST(REVERSE MSVC_TOOLCHAIN_VERSIONS)
\r
61 IF(MSVC_TOOLCHAIN_VERSIONS)
\r
62 LIST(GET MSVC_TOOLCHAIN_VERSIONS 0 MSVC_TOOLCHAIN_VERSION)
\r
64 SET(VC_DIR "${VC_DIR}/${MSVC_TOOLCHAIN_VERSION}")
\r
66 MESSAGE(STATUS "Found Visual C++ ${_NAME} (${_VERSION} with toolchain ${MSVC_TOOLCHAIN_VERSION}) in ${VC_DIR}")
\r
68 MESSAGE(FATAL_ERROR "Unable to find Visual C++ in ${VC_DIR}")
\r
72 IF(NOT VC_INCLUDE_DIR AND VC_DIR AND EXISTS "${VC_DIR}")
\r
73 SET(VC_INCLUDE_DIR "${VC_DIR}/include")
\r
74 IF(EXISTS "${VC_INCLUDE_DIR}")
\r
79 SET(MSVC_REDIST_DIR "${EXTERNAL_PATH}/redist")
\r
81 IF(NOT EXISTS "${MSVC_REDIST_DIR}")
\r
82 SET(MSVC_REDIST_DIR "${VC_DIR}/redist")
\r
84 IF(NOT EXISTS "${MSVC_REDIST_DIR}")
\r
85 SET(MSVC_REDIST_DIR)
\r
90 IF(MSVC_VERSION GREATER 1909)
\r
91 # If you have VC++ 2017 Express, put x64/Microsoft.VC141.CRT/*.dll in ${EXTERNAL_PATH}/redist
\r
92 # original files whould be in ${VC_DIR}/Redist/MSVC/14.11.25325/x64/Microsoft.VC141.CRT
\r
93 SET(MSVC14_REDIST_DIR "${MSVC_REDIST_DIR}")
\r
95 SET(MSVC14_REDIST_DIR "${MSVC_REDIST_DIR}")
\r
97 # If you have VC++ 2013 Express, put x64/Microsoft.VC120.CRT/*.dll in ${EXTERNAL_PATH}/redist
\r
98 SET(MSVC12_REDIST_DIR "${MSVC_REDIST_DIR}")
\r
100 # If you have VC++ 2012 Express, put x64/Microsoft.VC110.CRT/*.dll in ${EXTERNAL_PATH}/redist
\r
101 SET(MSVC11_REDIST_DIR "${MSVC_REDIST_DIR}")
\r
103 # If you have VC++ 2010 Express, put x64/Microsoft.VC100.CRT/*.dll in ${EXTERNAL_PATH}/redist
\r
104 SET(MSVC10_REDIST_DIR "${MSVC_REDIST_DIR}")
\r
106 SET(MSVC90_REDIST_DIR "${MSVC_REDIST_DIR}")
\r
108 SET(MSVC80_REDIST_DIR "${MSVC_REDIST_DIR}")
\r
113 MESSAGE(STATUS "Using VC++ headers from ${VC_INCLUDE_DIR}")
\r
115 MESSAGE(FATAL_ERROR "Unable to find VC++ headers")
\r
118 SET(VC_INCLUDE_DIRS ${VC_INCLUDE_DIR})
\r
119 INCLUDE_DIRECTORIES(${VC_INCLUDE_DIR})
\r