|
|
@ -1,89 +1,55 @@
|
|
|
|
# - Find MS Visual C++
|
|
|
|
# - Find MS Visual C++
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
# VC_DIR - where to find Visual C++
|
|
|
|
# VC_INCLUDE_DIR - where to find headers
|
|
|
|
# VC_INCLUDE_DIR - where to find headers
|
|
|
|
# VC_INCLUDE_DIRS - where to find headers
|
|
|
|
# VC_INCLUDE_DIRS - where to find headers
|
|
|
|
# VC_LIBRARY_DIR - where to find libraries
|
|
|
|
# VC_LIBRARY_DIR - where to find libraries
|
|
|
|
# VC_FOUND - True if MSVC found.
|
|
|
|
# VC_FOUND - True if MSVC found
|
|
|
|
|
|
|
|
|
|
|
|
MACRO(ADD_TRAILING_SLASH _FILENAME_VAR)
|
|
|
|
IF(CMAKE_CXX_COMPILER)
|
|
|
|
# put content in a new variable
|
|
|
|
SET(_COMPILER ${CMAKE_CXX_COMPILER})
|
|
|
|
SET(_FILENAME ${${_FILENAME_VAR}})
|
|
|
|
SET(_VERSION ${CMAKE_CXX_COMPILER_VERSION})
|
|
|
|
# get length of the string
|
|
|
|
ELSEIF(CMAKE_C_COMPILER)
|
|
|
|
STRING(LENGTH ${_FILENAME} _LEN)
|
|
|
|
SET(_COMPILER ${CMAKE_C_COMPILER})
|
|
|
|
# convert length to last pos
|
|
|
|
SET(_VERSION ${CMAKE_C_COMPILER_VERSION})
|
|
|
|
MATH(EXPR _POS "${_LEN}-1")
|
|
|
|
ELSE()
|
|
|
|
# get last character of the string
|
|
|
|
MESSAGE(FATAL_ERROR "No way to determine Visual C++ location")
|
|
|
|
STRING(SUBSTRING ${_FILENAME} ${_POS} 1 _FILENAME_END)
|
|
|
|
ENDIF()
|
|
|
|
# compare it with a slash
|
|
|
|
|
|
|
|
IF(NOT _FILENAME_END STREQUAL "/")
|
|
|
|
|
|
|
|
# not a slash, append it
|
|
|
|
|
|
|
|
SET(${_FILENAME_VAR} "${_FILENAME}/")
|
|
|
|
|
|
|
|
ELSE()
|
|
|
|
|
|
|
|
# already a slash
|
|
|
|
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
ENDMACRO()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MACRO(DETECT_VC_VERSION_HELPER _ROOT _VERSION)
|
|
|
|
|
|
|
|
# Software/Wow6432Node/...
|
|
|
|
|
|
|
|
GET_FILENAME_COMPONENT(VC${_VERSION}_DIR "[${_ROOT}\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VC7;${_VERSION}]" ABSOLUTE)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF(VC${_VERSION}_DIR AND VC${_VERSION}_DIR STREQUAL "/registry")
|
|
|
|
|
|
|
|
SET(VC${_VERSION}_DIR)
|
|
|
|
|
|
|
|
GET_FILENAME_COMPONENT(VC${_VERSION}_DIR "[${_ROOT}\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7;${_VERSION}]" ABSOLUTE)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry")
|
|
|
|
|
|
|
|
# be sure it's finishing by a /
|
|
|
|
|
|
|
|
ADD_TRAILING_SLASH(VC${_VERSION}_DIR)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SET(VC${_VERSION}_DIR "${VC${_VERSION}_DIR}VC/")
|
|
|
|
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry")
|
|
|
|
IF(MSVC_VERSION LESS 1910)
|
|
|
|
SET(VC${_VERSION}_FOUND ON)
|
|
|
|
IF(MSVC_VERSION LESS 1500)
|
|
|
|
DETECT_EXPRESS_VERSION(${_VERSION})
|
|
|
|
MESSAGE(FATAL_ERROR "Unsupported version of Visual C++ (minimum version is 2008)")
|
|
|
|
IF(NOT MSVC_FIND_QUIETLY)
|
|
|
|
ELSEIF(MSVC_VERSION LESS 1600)
|
|
|
|
SET(_VERSION_STR ${_VERSION})
|
|
|
|
SET(MSVC_TOOLSET "90")
|
|
|
|
IF(MSVC_EXPRESS)
|
|
|
|
SET(_NAME "2008")
|
|
|
|
SET(_VERSION_STR "${_VERSION_STR} Express")
|
|
|
|
ELSEIF(MSVC_VERSION LESS 1700)
|
|
|
|
ENDIF()
|
|
|
|
SET(MSVC_TOOLSET "100")
|
|
|
|
MESSAGE(STATUS "Found Visual C++ ${_VERSION_STR} in ${VC${_VERSION}_DIR}")
|
|
|
|
SET(_NAME "2010")
|
|
|
|
ENDIF()
|
|
|
|
ELSEIF(MSVC_VERSION LESS 1800)
|
|
|
|
ELSEIF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry")
|
|
|
|
SET(MSVC_TOOLSET "110")
|
|
|
|
SET(VC${_VERSION}_FOUND OFF)
|
|
|
|
SET(_NAME "2012")
|
|
|
|
SET(VC${_VERSION}_DIR "")
|
|
|
|
ELSEIF(MSVC_VERSION LESS 1900)
|
|
|
|
|
|
|
|
SET(MSVC_TOOLSET "120")
|
|
|
|
|
|
|
|
SET(_NAME "2013")
|
|
|
|
|
|
|
|
ELSE()
|
|
|
|
|
|
|
|
SET(MSVC_TOOLSET "140")
|
|
|
|
|
|
|
|
SET(_NAME "2015")
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
ENDMACRO()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MACRO(DETECT_VC_VERSION _VERSION)
|
|
|
|
|
|
|
|
IF(NOT VC_FOUND)
|
|
|
|
|
|
|
|
SET(VC${_VERSION}_FOUND OFF)
|
|
|
|
|
|
|
|
DETECT_VC_VERSION_HELPER("HKEY_CURRENT_USER" ${_VERSION})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF(NOT VC${_VERSION}_FOUND)
|
|
|
|
STRING(REGEX REPLACE "/bin/.+" "" VC_DIR ${_COMPILER})
|
|
|
|
DETECT_VC_VERSION_HELPER("HKEY_LOCAL_MACHINE" ${_VERSION})
|
|
|
|
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF(VC${_VERSION}_FOUND)
|
|
|
|
MESSAGE(STATUS "Found Visual C++ ${_NAME} (${_VERSION}) in ${VC_DIR}")
|
|
|
|
SET(VC_FOUND ON)
|
|
|
|
ELSE()
|
|
|
|
SET(VC_DIR "${VC${_VERSION}_DIR}")
|
|
|
|
# Toolset = version of runtime DLLs
|
|
|
|
ENDIF()
|
|
|
|
SET(MSVC_TOOLSET "140")
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
ENDMACRO()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MACRO(DETECT_EXPRESS_VERSION _VERSION)
|
|
|
|
|
|
|
|
GET_FILENAME_COMPONENT(MSVC_EXPRESS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\${_VERSION}\\Setup\\VC;ProductDir]" ABSOLUTE)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF(MSVC_EXPRESS AND NOT MSVC_EXPRESS STREQUAL "/registry")
|
|
|
|
IF(MSVC_VERSION LESS 1920)
|
|
|
|
SET(MSVC_EXPRESS ON)
|
|
|
|
SET(_NAME "2017")
|
|
|
|
|
|
|
|
ELSE()
|
|
|
|
|
|
|
|
SET(_NAME "2019")
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
ENDMACRO()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF(MSVC_VERSION GREATER 1909)
|
|
|
|
|
|
|
|
DETECT_VC_VERSION("15.0")
|
|
|
|
|
|
|
|
SET(MSVC_TOOLSET "140")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SET(VC_DIR "${VC_DIR}Tools/MSVC")
|
|
|
|
STRING(REGEX REPLACE "/MSVC/.+" "/MSVC" VC_DIR ${_COMPILER})
|
|
|
|
|
|
|
|
|
|
|
|
FILE(GLOB MSVC_TOOLCHAIN_VERSIONS RELATIVE ${VC_DIR} "${VC_DIR}/*")
|
|
|
|
FILE(GLOB MSVC_TOOLCHAIN_VERSIONS RELATIVE ${VC_DIR} "${VC_DIR}/*")
|
|
|
|
|
|
|
|
|
|
|
@ -92,48 +58,15 @@ IF(MSVC_VERSION GREATER 1909)
|
|
|
|
LIST(REVERSE MSVC_TOOLCHAIN_VERSIONS)
|
|
|
|
LIST(REVERSE MSVC_TOOLCHAIN_VERSIONS)
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
IF(NOT MSVC_TOOLCHAIN_VERSIONS)
|
|
|
|
IF(MSVC_TOOLCHAIN_VERSIONS)
|
|
|
|
MESSAGE(FATAL_ERROR "No MSVC version found in default search path ${VC_DIR}")
|
|
|
|
LIST(GET MSVC_TOOLCHAIN_VERSIONS 0 MSVC_TOOLCHAIN_VERSION)
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LIST(GET MSVC_TOOLCHAIN_VERSIONS 0 MSVC_TOOLCHAIN_VERSION)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SET(VC_DIR "${VC_DIR}/${MSVC_TOOLCHAIN_VERSION}")
|
|
|
|
|
|
|
|
SET(VC_INCLUDE_DIR "${VC_DIR}/include")
|
|
|
|
|
|
|
|
ELSEIF(MSVC14)
|
|
|
|
|
|
|
|
DETECT_VC_VERSION("14.0")
|
|
|
|
|
|
|
|
SET(MSVC_TOOLSET "140")
|
|
|
|
|
|
|
|
ELSEIF(MSVC12)
|
|
|
|
|
|
|
|
DETECT_VC_VERSION("12.0")
|
|
|
|
|
|
|
|
SET(MSVC_TOOLSET "120")
|
|
|
|
|
|
|
|
ELSEIF(MSVC11)
|
|
|
|
|
|
|
|
DETECT_VC_VERSION("11.0")
|
|
|
|
|
|
|
|
SET(MSVC_TOOLSET "110")
|
|
|
|
|
|
|
|
ELSEIF(MSVC10)
|
|
|
|
|
|
|
|
DETECT_VC_VERSION("10.0")
|
|
|
|
|
|
|
|
SET(MSVC_TOOLSET "100")
|
|
|
|
|
|
|
|
ELSEIF(MSVC90)
|
|
|
|
|
|
|
|
DETECT_VC_VERSION("9.0")
|
|
|
|
|
|
|
|
SET(MSVC_TOOLSET "90")
|
|
|
|
|
|
|
|
ELSEIF(MSVC80)
|
|
|
|
|
|
|
|
DETECT_VC_VERSION("8.0")
|
|
|
|
|
|
|
|
SET(MSVC_TOOLSET "80")
|
|
|
|
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# If you plan to use VC++ compilers with WINE, set VC_DIR environment variable
|
|
|
|
SET(VC_DIR "${VC_DIR}/${MSVC_TOOLCHAIN_VERSION}")
|
|
|
|
IF(NOT VC_DIR)
|
|
|
|
|
|
|
|
SET(VC_DIR $ENV{VC_DIR})
|
|
|
|
|
|
|
|
# Fix path
|
|
|
|
|
|
|
|
FILE(TO_CMAKE_PATH ${VC_DIR} VC_DIR)
|
|
|
|
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IF(NOT VC_DIR)
|
|
|
|
MESSAGE(STATUS "Found Visual C++ ${_NAME} (${_VERSION} with toolchain ${MSVC_TOOLCHAIN_VERSION}) in ${VC_DIR}")
|
|
|
|
IF(CMAKE_CXX_COMPILER)
|
|
|
|
|
|
|
|
SET(_COMPILER ${CMAKE_CXX_COMPILER})
|
|
|
|
|
|
|
|
ELSE()
|
|
|
|
ELSE()
|
|
|
|
SET(_COMPILER ${CMAKE_C_COMPILER})
|
|
|
|
MESSAGE(FATAL_ERROR "Unable to find Visual C++ in ${VC_DIR}")
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
STRING(REGEX REPLACE "/(bin|BIN|Bin)/.+" "" VC_DIR ${_COMPILER})
|
|
|
|
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
IF(NOT VC_INCLUDE_DIR AND VC_DIR AND EXISTS "${VC_DIR}")
|
|
|
|
IF(NOT VC_INCLUDE_DIR AND VC_DIR AND EXISTS "${VC_DIR}")
|
|
|
@ -154,7 +87,7 @@ IF(NOT EXISTS "${MSVC_REDIST_DIR}")
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
IF(MSVC_REDIST_DIR)
|
|
|
|
IF(MSVC_REDIST_DIR)
|
|
|
|
IF(MSVC1411 OR MSVC1410)
|
|
|
|
IF(MSVC_VERSION GREATER 1909)
|
|
|
|
# If you have VC++ 2017 Express, put x64/Microsoft.VC141.CRT/*.dll in ${EXTERNAL_PATH}/redist
|
|
|
|
# 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
|
|
|
|
# original files whould be in ${VC_DIR}/Redist/MSVC/14.11.25325/x64/Microsoft.VC141.CRT
|
|
|
|
SET(MSVC14_REDIST_DIR "${MSVC_REDIST_DIR}")
|
|
|
|
SET(MSVC14_REDIST_DIR "${MSVC_REDIST_DIR}")
|
|
|
@ -167,7 +100,7 @@ IF(MSVC_REDIST_DIR)
|
|
|
|
# If you have VC++ 2012 Express, put x64/Microsoft.VC110.CRT/*.dll in ${EXTERNAL_PATH}/redist
|
|
|
|
# If you have VC++ 2012 Express, put x64/Microsoft.VC110.CRT/*.dll in ${EXTERNAL_PATH}/redist
|
|
|
|
SET(MSVC11_REDIST_DIR "${MSVC_REDIST_DIR}")
|
|
|
|
SET(MSVC11_REDIST_DIR "${MSVC_REDIST_DIR}")
|
|
|
|
ELSEIF(MSVC10)
|
|
|
|
ELSEIF(MSVC10)
|
|
|
|
# If you have VC++ 2010 Express, put x64/Microsoft.VC100.CRT/*.dll in ${EXTERNAL_PATH}/redist
|
|
|
|
# If you have VC++ 2010 Express, put x64/Microsoft.VC100.CRT/*.dll in ${EXTERNAL_PATH}/redist
|
|
|
|
SET(MSVC10_REDIST_DIR "${MSVC_REDIST_DIR}")
|
|
|
|
SET(MSVC10_REDIST_DIR "${MSVC_REDIST_DIR}")
|
|
|
|
ELSEIF(MSVC90)
|
|
|
|
ELSEIF(MSVC90)
|
|
|
|
SET(MSVC90_REDIST_DIR "${MSVC_REDIST_DIR}")
|
|
|
|
SET(MSVC90_REDIST_DIR "${MSVC_REDIST_DIR}")
|
|
|
@ -176,7 +109,11 @@ IF(MSVC_REDIST_DIR)
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
MESSAGE(STATUS "Using headers from ${VC_INCLUDE_DIR}")
|
|
|
|
IF(VC_INCLUDE_DIR)
|
|
|
|
|
|
|
|
MESSAGE(STATUS "Using VC++ headers from ${VC_INCLUDE_DIR}")
|
|
|
|
|
|
|
|
ELSE()
|
|
|
|
|
|
|
|
MESSAGE(FATAL_ERROR "Unable to find VC++ headers")
|
|
|
|
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
SET(VC_INCLUDE_DIRS ${VC_INCLUDE_DIR})
|
|
|
|
SET(VC_INCLUDE_DIRS ${VC_INCLUDE_DIR})
|
|
|
|
INCLUDE_DIRECTORIES(${VC_INCLUDE_DIR})
|
|
|
|
INCLUDE_DIRECTORIES(${VC_INCLUDE_DIR})
|
|
|
|