2013-09-06 07:01:42 +00:00
|
|
|
# - Find MS Visual C++
|
|
|
|
#
|
|
|
|
# VC_INCLUDE_DIR - where to find headers
|
|
|
|
# VC_INCLUDE_DIRS - where to find headers
|
|
|
|
# VC_LIBRARY_DIR - where to find libraries
|
|
|
|
# VC_FOUND - True if MSVC found.
|
|
|
|
|
|
|
|
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")
|
|
|
|
SET(VC${_VERSION}_DIR "${VC${_VERSION}_DIR}VC/")
|
2015-12-15 12:41:27 +00:00
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
2013-09-06 07:01:42 +00:00
|
|
|
|
|
|
|
IF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry")
|
|
|
|
SET(VC${_VERSION}_FOUND ON)
|
2013-09-27 09:05:52 +00:00
|
|
|
DETECT_EXPRESS_VERSION(${_VERSION})
|
2013-09-06 07:01:42 +00:00
|
|
|
IF(NOT MSVC_FIND_QUIETLY)
|
2013-09-27 09:05:52 +00:00
|
|
|
SET(_VERSION_STR ${_VERSION})
|
|
|
|
IF(MSVC_EXPRESS)
|
|
|
|
SET(_VERSION_STR "${_VERSION_STR} Express")
|
2015-12-15 12:41:27 +00:00
|
|
|
ENDIF()
|
2013-09-27 09:05:52 +00:00
|
|
|
MESSAGE(STATUS "Found Visual C++ ${_VERSION_STR} in ${VC${_VERSION}_DIR}")
|
2015-12-15 12:41:27 +00:00
|
|
|
ENDIF()
|
2013-09-06 07:01:42 +00:00
|
|
|
ELSEIF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry")
|
|
|
|
SET(VC${_VERSION}_FOUND OFF)
|
|
|
|
SET(VC${_VERSION}_DIR "")
|
2015-12-15 12:41:27 +00:00
|
|
|
ENDIF()
|
|
|
|
ENDMACRO()
|
2013-09-06 07:01:42 +00:00
|
|
|
|
|
|
|
MACRO(DETECT_VC_VERSION _VERSION)
|
|
|
|
SET(VC${_VERSION}_FOUND OFF)
|
|
|
|
DETECT_VC_VERSION_HELPER("HKEY_CURRENT_USER" ${_VERSION})
|
|
|
|
|
|
|
|
IF(NOT VC${_VERSION}_FOUND)
|
|
|
|
DETECT_VC_VERSION_HELPER("HKEY_LOCAL_MACHINE" ${_VERSION})
|
2015-12-15 12:41:27 +00:00
|
|
|
ENDIF()
|
2013-09-06 07:01:42 +00:00
|
|
|
|
2013-09-21 12:14:29 +00:00
|
|
|
IF(VC${_VERSION}_FOUND)
|
2013-09-06 07:01:42 +00:00
|
|
|
SET(VC_FOUND ON)
|
|
|
|
SET(VC_DIR "${VC${_VERSION}_DIR}")
|
2015-12-15 12:41:27 +00:00
|
|
|
ENDIF()
|
|
|
|
ENDMACRO()
|
2013-09-06 07:01:42 +00:00
|
|
|
|
2013-09-27 09:05:52 +00:00
|
|
|
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")
|
|
|
|
SET(MSVC_EXPRESS ON)
|
2015-12-15 12:41:27 +00:00
|
|
|
ENDIF()
|
|
|
|
ENDMACRO()
|
2013-09-27 09:05:52 +00:00
|
|
|
|
2016-12-23 08:58:44 +00:00
|
|
|
IF(MSVC14)
|
|
|
|
DETECT_VC_VERSION("14.0")
|
|
|
|
SET(MSVC_TOOLSET "140")
|
|
|
|
|
|
|
|
IF(NOT MSVC14_REDIST_DIR)
|
|
|
|
# If you have VC++ 2015 Express, put x64/Microsoft.VC140.CRT/*.dll in ${EXTERNAL_PATH}/redist
|
|
|
|
SET(MSVC14_REDIST_DIR "${EXTERNAL_PATH}/redist")
|
|
|
|
ENDIF()
|
|
|
|
ELSEIF(MSVC12)
|
2013-09-27 09:05:52 +00:00
|
|
|
DETECT_VC_VERSION("12.0")
|
2015-02-14 12:47:37 +00:00
|
|
|
SET(MSVC_TOOLSET "120")
|
2013-09-27 09:05:52 +00:00
|
|
|
|
|
|
|
IF(NOT MSVC12_REDIST_DIR)
|
|
|
|
# If you have VC++ 2013 Express, put x64/Microsoft.VC120.CRT/*.dll in ${EXTERNAL_PATH}/redist
|
|
|
|
SET(MSVC12_REDIST_DIR "${EXTERNAL_PATH}/redist")
|
2015-12-15 12:41:27 +00:00
|
|
|
ENDIF()
|
2013-09-27 09:05:52 +00:00
|
|
|
ELSEIF(MSVC11)
|
2013-09-06 07:01:42 +00:00
|
|
|
DETECT_VC_VERSION("11.0")
|
2015-02-14 12:47:37 +00:00
|
|
|
SET(MSVC_TOOLSET "110")
|
2013-09-06 07:01:42 +00:00
|
|
|
|
|
|
|
IF(NOT MSVC11_REDIST_DIR)
|
|
|
|
# If you have VC++ 2012 Express, put x64/Microsoft.VC110.CRT/*.dll in ${EXTERNAL_PATH}/redist
|
|
|
|
SET(MSVC11_REDIST_DIR "${EXTERNAL_PATH}/redist")
|
2015-12-15 12:41:27 +00:00
|
|
|
ENDIF()
|
2013-09-06 07:01:42 +00:00
|
|
|
ELSEIF(MSVC10)
|
|
|
|
DETECT_VC_VERSION("10.0")
|
2015-02-14 12:47:37 +00:00
|
|
|
SET(MSVC_TOOLSET "100")
|
2013-09-06 07:01:42 +00:00
|
|
|
|
|
|
|
IF(NOT MSVC10_REDIST_DIR)
|
|
|
|
# If you have VC++ 2010 Express, put x64/Microsoft.VC100.CRT/*.dll in ${EXTERNAL_PATH}/redist
|
|
|
|
SET(MSVC10_REDIST_DIR "${EXTERNAL_PATH}/redist")
|
2015-12-15 12:41:27 +00:00
|
|
|
ENDIF()
|
2013-09-06 07:01:42 +00:00
|
|
|
ELSEIF(MSVC90)
|
|
|
|
DETECT_VC_VERSION("9.0")
|
2015-02-14 12:47:37 +00:00
|
|
|
SET(MSVC_TOOLSET "90")
|
2013-09-06 07:01:42 +00:00
|
|
|
ELSEIF(MSVC80)
|
|
|
|
DETECT_VC_VERSION("8.0")
|
2015-02-14 12:47:37 +00:00
|
|
|
SET(MSVC_TOOLSET "80")
|
2015-12-15 12:41:27 +00:00
|
|
|
ENDIF()
|
2013-09-06 07:01:42 +00:00
|
|
|
|
|
|
|
# If you plan to use VC++ compilers with WINE, set VC_DIR environment variable
|
|
|
|
IF(NOT VC_DIR)
|
|
|
|
SET(VC_DIR $ENV{VC_DIR})
|
2015-12-15 12:41:27 +00:00
|
|
|
ENDIF()
|
2013-09-06 07:01:42 +00:00
|
|
|
|
|
|
|
IF(NOT VC_DIR)
|
2016-01-26 21:43:58 +00:00
|
|
|
IF(CMAKE_CXX_COMPILER)
|
|
|
|
SET(_COMPILER ${CMAKE_CXX_COMPILER})
|
|
|
|
ELSE()
|
|
|
|
SET(_COMPILER ${CMAKE_C_COMPILER})
|
|
|
|
ENDIF()
|
2016-12-23 08:58:44 +00:00
|
|
|
STRING(REGEX REPLACE "/(bin|BIN|Bin)/.+" "" VC_DIR ${_COMPILER})
|
2016-01-26 21:43:58 +00:00
|
|
|
ENDIF()
|
2013-09-06 07:01:42 +00:00
|
|
|
|
|
|
|
SET(VC_INCLUDE_DIR "${VC_DIR}/include")
|
|
|
|
SET(VC_INCLUDE_DIRS ${VC_INCLUDE_DIR})
|
|
|
|
INCLUDE_DIRECTORIES(${VC_INCLUDE_DIR})
|