You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
120 lines
3.6 KiB
CMake
120 lines
3.6 KiB
CMake
11 years ago
|
# - Find MS Visual C++
|
||
|
#
|
||
5 years ago
|
# VC_DIR - where to find Visual C++
|
||
11 years ago
|
# VC_INCLUDE_DIR - where to find headers
|
||
|
# VC_INCLUDE_DIRS - where to find headers
|
||
|
# VC_LIBRARY_DIR - where to find libraries
|
||
5 years ago
|
# VC_FOUND - True if MSVC found
|
||
|
|
||
|
IF(CMAKE_CXX_COMPILER)
|
||
|
SET(_COMPILER ${CMAKE_CXX_COMPILER})
|
||
|
SET(_VERSION ${CMAKE_CXX_COMPILER_VERSION})
|
||
|
ELSEIF(CMAKE_C_COMPILER)
|
||
|
SET(_COMPILER ${CMAKE_C_COMPILER})
|
||
|
SET(_VERSION ${CMAKE_C_COMPILER_VERSION})
|
||
|
ELSE()
|
||
|
MESSAGE(FATAL_ERROR "No way to determine Visual C++ location")
|
||
|
ENDIF()
|
||
11 years ago
|
|
||
5 years ago
|
IF(MSVC_VERSION LESS 1910)
|
||
|
IF(MSVC_VERSION LESS 1500)
|
||
|
MESSAGE(FATAL_ERROR "Unsupported version of Visual C++ (minimum version is 2008)")
|
||
|
ELSEIF(MSVC_VERSION LESS 1600)
|
||
|
SET(MSVC_TOOLSET "90")
|
||
|
SET(_NAME "2008")
|
||
|
ELSEIF(MSVC_VERSION LESS 1700)
|
||
|
SET(MSVC_TOOLSET "100")
|
||
|
SET(_NAME "2010")
|
||
|
ELSEIF(MSVC_VERSION LESS 1800)
|
||
|
SET(MSVC_TOOLSET "110")
|
||
|
SET(_NAME "2012")
|
||
|
ELSEIF(MSVC_VERSION LESS 1900)
|
||
|
SET(MSVC_TOOLSET "120")
|
||
|
SET(_NAME "2013")
|
||
|
ELSE()
|
||
|
SET(MSVC_TOOLSET "140")
|
||
|
SET(_NAME "2015")
|
||
9 years ago
|
ENDIF()
|
||
11 years ago
|
|
||
5 years ago
|
STRING(REGEX REPLACE "/bin/.+" "" VC_DIR ${_COMPILER})
|
||
11 years ago
|
|
||
5 years ago
|
MESSAGE(STATUS "Found Visual C++ ${_NAME} (${_VERSION}) in ${VC_DIR}")
|
||
|
ELSE()
|
||
|
# Toolset = version of runtime DLLs
|
||
|
SET(MSVC_TOOLSET "140")
|
||
11 years ago
|
|
||
5 years ago
|
IF(MSVC_VERSION LESS 1920)
|
||
|
SET(_NAME "2017")
|
||
|
ELSE()
|
||
|
SET(_NAME "2019")
|
||
9 years ago
|
ENDIF()
|
||
7 years ago
|
|
||
5 years ago
|
STRING(REGEX REPLACE "/MSVC/.+" "/MSVC" VC_DIR ${_COMPILER})
|
||
7 years ago
|
|
||
|
FILE(GLOB MSVC_TOOLCHAIN_VERSIONS RELATIVE ${VC_DIR} "${VC_DIR}/*")
|
||
|
|
||
|
IF(MSVC_TOOLCHAIN_VERSIONS)
|
||
|
LIST(SORT MSVC_TOOLCHAIN_VERSIONS)
|
||
|
LIST(REVERSE MSVC_TOOLCHAIN_VERSIONS)
|
||
|
ENDIF()
|
||
|
|
||
5 years ago
|
IF(MSVC_TOOLCHAIN_VERSIONS)
|
||
|
LIST(GET MSVC_TOOLCHAIN_VERSIONS 0 MSVC_TOOLCHAIN_VERSION)
|
||
11 years ago
|
|
||
5 years ago
|
SET(VC_DIR "${VC_DIR}/${MSVC_TOOLCHAIN_VERSION}")
|
||
11 years ago
|
|
||
5 years ago
|
MESSAGE(STATUS "Found Visual C++ ${_NAME} (${_VERSION} with toolchain ${MSVC_TOOLCHAIN_VERSION}) in ${VC_DIR}")
|
||
9 years ago
|
ELSE()
|
||
5 years ago
|
MESSAGE(FATAL_ERROR "Unable to find Visual C++ in ${VC_DIR}")
|
||
9 years ago
|
ENDIF()
|
||
|
ENDIF()
|
||
11 years ago
|
|
||
7 years ago
|
IF(NOT VC_INCLUDE_DIR AND VC_DIR AND EXISTS "${VC_DIR}")
|
||
7 years ago
|
SET(VC_INCLUDE_DIR "${VC_DIR}/include")
|
||
7 years ago
|
IF(EXISTS "${VC_INCLUDE_DIR}")
|
||
|
SET(VC_FOUND ON)
|
||
|
ENDIF()
|
||
|
ENDIF()
|
||
|
|
||
|
SET(MSVC_REDIST_DIR "${EXTERNAL_PATH}/redist")
|
||
|
|
||
|
IF(NOT EXISTS "${MSVC_REDIST_DIR}")
|
||
|
SET(MSVC_REDIST_DIR "${VC_DIR}/redist")
|
||
5 years ago
|
|
||
7 years ago
|
IF(NOT EXISTS "${MSVC_REDIST_DIR}")
|
||
|
SET(MSVC_REDIST_DIR)
|
||
|
ENDIF()
|
||
|
ENDIF()
|
||
|
|
||
|
IF(MSVC_REDIST_DIR)
|
||
5 years ago
|
IF(MSVC_VERSION GREATER 1909)
|
||
7 years ago
|
# If you have VC++ 2017 Express, put x64/Microsoft.VC141.CRT/*.dll in ${EXTERNAL_PATH}/redist
|
||
|
# original files whould be in ${VC_DIR}/Redist/MSVC/14.11.25325/x64/Microsoft.VC141.CRT
|
||
|
SET(MSVC14_REDIST_DIR "${MSVC_REDIST_DIR}")
|
||
|
ELSEIF(MSVC14)
|
||
|
SET(MSVC14_REDIST_DIR "${MSVC_REDIST_DIR}")
|
||
|
ELSEIF(MSVC12)
|
||
|
# If you have VC++ 2013 Express, put x64/Microsoft.VC120.CRT/*.dll in ${EXTERNAL_PATH}/redist
|
||
|
SET(MSVC12_REDIST_DIR "${MSVC_REDIST_DIR}")
|
||
|
ELSEIF(MSVC11)
|
||
|
# If you have VC++ 2012 Express, put x64/Microsoft.VC110.CRT/*.dll in ${EXTERNAL_PATH}/redist
|
||
|
SET(MSVC11_REDIST_DIR "${MSVC_REDIST_DIR}")
|
||
|
ELSEIF(MSVC10)
|
||
5 years ago
|
# If you have VC++ 2010 Express, put x64/Microsoft.VC100.CRT/*.dll in ${EXTERNAL_PATH}/redist
|
||
7 years ago
|
SET(MSVC10_REDIST_DIR "${MSVC_REDIST_DIR}")
|
||
|
ELSEIF(MSVC90)
|
||
|
SET(MSVC90_REDIST_DIR "${MSVC_REDIST_DIR}")
|
||
|
ELSEIF(MSVC80)
|
||
|
SET(MSVC80_REDIST_DIR "${MSVC_REDIST_DIR}")
|
||
|
ENDIF()
|
||
7 years ago
|
ENDIF()
|
||
|
|
||
5 years ago
|
IF(VC_INCLUDE_DIR)
|
||
|
MESSAGE(STATUS "Using VC++ headers from ${VC_INCLUDE_DIR}")
|
||
|
ELSE()
|
||
|
MESSAGE(FATAL_ERROR "Unable to find VC++ headers")
|
||
|
ENDIF()
|
||
7 years ago
|
|
||
11 years ago
|
SET(VC_INCLUDE_DIRS ${VC_INCLUDE_DIR})
|
||
|
INCLUDE_DIRECTORIES(${VC_INCLUDE_DIR})
|