2017-05-29 04:07:20 +08:00
|
|
|
# Mark variables as used so cmake doesn't complain about them
|
|
|
|
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE})
|
2016-09-19 11:50:08 +08:00
|
|
|
if(NOT VCPKG_TOOLCHAIN)
|
|
|
|
if(CMAKE_GENERATOR_PLATFORM MATCHES "^[Ww][Ii][Nn]32$")
|
|
|
|
set(_VCPKG_TARGET_TRIPLET_ARCH x86)
|
|
|
|
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Xx]64$")
|
|
|
|
set(_VCPKG_TARGET_TRIPLET_ARCH x64)
|
|
|
|
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]$")
|
|
|
|
set(_VCPKG_TARGET_TRIPLET_ARCH arm)
|
|
|
|
else()
|
|
|
|
if(CMAKE_GENERATOR MATCHES "^Visual Studio 14 2015 Win64$")
|
|
|
|
set(_VCPKG_TARGET_TRIPLET_ARCH x64)
|
|
|
|
elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 14 2015 ARM$")
|
|
|
|
set(_VCPKG_TARGET_TRIPLET_ARCH arm)
|
2016-11-01 00:37:13 +08:00
|
|
|
elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 14 2015$")
|
|
|
|
set(_VCPKG_TARGET_TRIPLET_ARCH x86)
|
2016-11-19 14:33:31 +08:00
|
|
|
elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 15 2017 Win64$")
|
|
|
|
set(_VCPKG_TARGET_TRIPLET_ARCH x64)
|
|
|
|
elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 15 2017 ARM")
|
|
|
|
set(_VCPKG_TARGET_TRIPLET_ARCH arm)
|
|
|
|
elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 15 2017")
|
|
|
|
set(_VCPKG_TARGET_TRIPLET_ARCH x86)
|
2016-09-19 11:50:08 +08:00
|
|
|
else()
|
2016-10-30 17:46:24 +08:00
|
|
|
find_program(_VCPKG_CL cl)
|
2016-11-17 01:38:30 +08:00
|
|
|
if(_VCPKG_CL MATCHES "amd64/cl.exe$" OR _VCPKG_CL MATCHES "x64/cl.exe$")
|
2016-10-30 17:46:24 +08:00
|
|
|
set(_VCPKG_TARGET_TRIPLET_ARCH x64)
|
|
|
|
elseif(_VCPKG_CL MATCHES "arm/cl.exe$")
|
|
|
|
set(_VCPKG_TARGET_TRIPLET_ARCH arm)
|
2016-11-01 01:11:25 +08:00
|
|
|
elseif(_VCPKG_CL MATCHES "bin/cl.exe$" OR _VCPKG_CL MATCHES "x86/cl.exe$")
|
2016-10-30 17:46:24 +08:00
|
|
|
set(_VCPKG_TARGET_TRIPLET_ARCH x86)
|
2016-11-01 00:37:13 +08:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Unable to determine target architecture.")
|
2016-10-30 17:46:24 +08:00
|
|
|
endif()
|
2016-09-19 11:50:08 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2017-05-29 04:07:20 +08:00
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" OR CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone")
|
2016-09-19 11:50:08 +08:00
|
|
|
set(_VCPKG_TARGET_TRIPLET_PLAT uwp)
|
|
|
|
else()
|
|
|
|
set(_VCPKG_TARGET_TRIPLET_PLAT windows)
|
|
|
|
endif()
|
|
|
|
|
2016-09-29 03:05:46 +08:00
|
|
|
set(VCPKG_TARGET_TRIPLET ${_VCPKG_TARGET_TRIPLET_ARCH}-${_VCPKG_TARGET_TRIPLET_PLAT} CACHE STRING "Vcpkg target triplet (ex. x86-windows)")
|
2016-09-19 11:50:08 +08:00
|
|
|
set(_VCPKG_TOOLCHAIN_DIR ${CMAKE_CURRENT_LIST_DIR})
|
2017-04-21 07:19:39 +08:00
|
|
|
|
|
|
|
#Detect .vcpkg-root to figure VCPKG_ROOT_DIR
|
|
|
|
SET(_VCPKG_ROOT_DIR_CANDIDATE ${CMAKE_CURRENT_LIST_DIR})
|
|
|
|
while(IS_DIRECTORY ${_VCPKG_ROOT_DIR_CANDIDATE} AND NOT EXISTS "${_VCPKG_ROOT_DIR_CANDIDATE}/.vcpkg-root")
|
|
|
|
get_filename_component(_VCPKG_ROOT_DIR_TEMP ${_VCPKG_ROOT_DIR_CANDIDATE} DIRECTORY)
|
|
|
|
if (_VCPKG_ROOT_DIR_TEMP STREQUAL _VCPKG_ROOT_DIR_CANDIDATE) # If unchanged, we have reached the root of the drive
|
|
|
|
message(FATAL_ERROR "Could not find .vcpkg-root")
|
|
|
|
else()
|
|
|
|
SET(_VCPKG_ROOT_DIR_CANDIDATE ${_VCPKG_ROOT_DIR_TEMP})
|
|
|
|
endif()
|
|
|
|
endwhile()
|
|
|
|
set(_VCPKG_ROOT_DIR ${_VCPKG_ROOT_DIR_CANDIDATE})
|
2017-03-22 06:48:29 +08:00
|
|
|
set(_VCPKG_INSTALLED_DIR ${_VCPKG_ROOT_DIR}/installed)
|
2016-09-19 11:50:08 +08:00
|
|
|
|
|
|
|
if(CMAKE_BUILD_TYPE MATCHES "^Debug$" OR NOT DEFINED CMAKE_BUILD_TYPE)
|
|
|
|
list(APPEND CMAKE_PREFIX_PATH
|
2016-09-29 03:05:46 +08:00
|
|
|
${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug
|
2016-09-19 11:50:08 +08:00
|
|
|
)
|
2016-11-26 15:10:27 +08:00
|
|
|
list(APPEND CMAKE_LIBRARY_PATH
|
|
|
|
${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib/manual-link
|
|
|
|
)
|
2016-09-19 11:50:08 +08:00
|
|
|
endif()
|
|
|
|
list(APPEND CMAKE_PREFIX_PATH
|
2016-09-29 03:05:46 +08:00
|
|
|
${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}
|
2016-09-19 11:50:08 +08:00
|
|
|
)
|
2016-11-26 15:10:27 +08:00
|
|
|
list(APPEND CMAKE_LIBRARY_PATH
|
|
|
|
${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/manual-link
|
|
|
|
)
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2017-02-03 07:41:20 +08:00
|
|
|
set(Boost_COMPILER "-vc140")
|
|
|
|
|
2017-03-22 06:48:29 +08:00
|
|
|
if (NOT DEFINED CMAKE_SYSTEM_VERSION)
|
|
|
|
include(${_VCPKG_ROOT_DIR}/scripts/cmake/vcpkg_get_windows_sdk.cmake)
|
|
|
|
# This is used as an implicit parameter for vcpkg_get_windows_sdk
|
|
|
|
set(VCPKG_ROOT_DIR ${_VCPKG_ROOT_DIR})
|
|
|
|
vcpkg_get_windows_sdk(WINDOWS_SDK_VERSION)
|
|
|
|
unset(VCPKG_ROOT_DIR)
|
|
|
|
set(CMAKE_SYSTEM_VERSION ${WINDOWS_SDK_VERSION})
|
|
|
|
endif()
|
|
|
|
|
2017-03-21 16:48:40 +08:00
|
|
|
file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles)
|
|
|
|
set(CMAKE_SYSTEM_IGNORE_PATH
|
|
|
|
"${_programfiles}/OpenSSL"
|
|
|
|
"${_programfiles}/OpenSSL-Win32"
|
|
|
|
"${_programfiles}/OpenSSL-Win64"
|
2017-04-25 14:25:12 +08:00
|
|
|
"${_programfiles}/OpenSSL-Win32/lib/VC"
|
|
|
|
"${_programfiles}/OpenSSL-Win64/lib/VC"
|
|
|
|
"${_programfiles}/OpenSSL-Win32/lib/VC/static"
|
|
|
|
"${_programfiles}/OpenSSL-Win64/lib/VC/static"
|
2017-03-21 16:48:40 +08:00
|
|
|
"C:/OpenSSL/"
|
|
|
|
"C:/OpenSSL-Win32/"
|
|
|
|
"C:/OpenSSL-Win64/"
|
2017-04-25 14:25:12 +08:00
|
|
|
"C:/OpenSSL-Win32/lib/VC"
|
|
|
|
"C:/OpenSSL-Win64/lib/VC"
|
|
|
|
"C:/OpenSSL-Win32/lib/VC/static"
|
|
|
|
"C:/OpenSSL-Win64/lib/VC/static"
|
2017-03-21 16:48:40 +08:00
|
|
|
)
|
|
|
|
|
2016-10-09 23:59:37 +08:00
|
|
|
set(CMAKE_PROGRAM_PATH ${CMAKE_PROGRAM_PATH} ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/tools)
|
2017-06-10 13:38:17 +08:00
|
|
|
file(GLOB _VCPKG_TOOLS_DIRS ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/tools/*)
|
|
|
|
foreach(_VCPKG_TOOLS_DIR ${_VCPKG_TOOLS_DIRS})
|
|
|
|
if(IS_DIRECTORY ${_VCPKG_TOOLS_DIR})
|
|
|
|
set(CMAKE_PROGRAM_PATH ${CMAKE_PROGRAM_PATH} ${_VCPKG_TOOLS_DIR})
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2016-10-09 23:59:37 +08:00
|
|
|
|
2016-11-26 15:10:27 +08:00
|
|
|
option(VCPKG_APPLOCAL_DEPS "Automatically copy dependencies into the output directory for executables." ON)
|
|
|
|
function(add_executable name)
|
|
|
|
_add_executable(${ARGV})
|
|
|
|
list(FIND ARGV "IMPORTED" IMPORTED_IDX)
|
2017-03-29 01:08:30 +08:00
|
|
|
list(FIND ARGV "ALIAS" ALIAS_IDX)
|
|
|
|
if(IMPORTED_IDX EQUAL -1 AND ALIAS_IDX EQUAL -1)
|
2016-11-26 15:10:27 +08:00
|
|
|
if(VCPKG_APPLOCAL_DEPS)
|
2016-11-12 08:17:39 +08:00
|
|
|
add_custom_command(TARGET ${name} POST_BUILD
|
2017-04-07 06:08:35 +08:00
|
|
|
COMMAND powershell -noprofile -executionpolicy Bypass -file ${_VCPKG_TOOLCHAIN_DIR}/msbuild/applocal.ps1
|
2016-11-12 08:17:39 +08:00
|
|
|
-targetBinary $<TARGET_FILE:${name}>
|
|
|
|
-installedDir "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$<CONFIG:Debug>:/debug>/bin"
|
|
|
|
-OutVariable out
|
|
|
|
)
|
2016-11-02 07:19:05 +08:00
|
|
|
endif()
|
2017-05-02 14:12:43 +08:00
|
|
|
set_target_properties(${name} PROPERTIES VS_USER_PROPS do_not_import_user.props)
|
2016-11-26 15:10:27 +08:00
|
|
|
set_target_properties(${name} PROPERTIES VS_GLOBAL_VcpkgEnabled false)
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(add_library name)
|
|
|
|
_add_library(${ARGV})
|
|
|
|
list(FIND ARGV "IMPORTED" IMPORTED_IDX)
|
2016-12-03 01:24:14 +08:00
|
|
|
list(FIND ARGV "INTERFACE" INTERFACE_IDX)
|
|
|
|
list(FIND ARGV "ALIAS" ALIAS_IDX)
|
|
|
|
if(IMPORTED_IDX EQUAL -1 AND INTERFACE_IDX EQUAL -1 AND ALIAS_IDX EQUAL -1)
|
2017-05-02 14:12:43 +08:00
|
|
|
set_target_properties(${name} PROPERTIES VS_USER_PROPS do_not_import_user.props)
|
2016-11-26 15:10:27 +08:00
|
|
|
set_target_properties(${name} PROPERTIES VS_GLOBAL_VcpkgEnabled false)
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
2017-07-29 07:46:57 +08:00
|
|
|
macro(find_package name)
|
2017-07-29 02:44:54 +08:00
|
|
|
if(name STREQUAL "Boost")
|
|
|
|
unset(Boost_USE_STATIC_LIBS)
|
|
|
|
endif()
|
|
|
|
_find_package(${ARGV})
|
2017-07-29 07:46:57 +08:00
|
|
|
endmacro()
|
2017-07-29 02:44:54 +08:00
|
|
|
|
2016-09-19 11:50:08 +08:00
|
|
|
set(VCPKG_TOOLCHAIN ON)
|
|
|
|
endif()
|
2017-07-01 08:33:48 +08:00
|
|
|
|
|
|
|
set(_UNUSED ${CMAKE_TOOLCHAIN_FILE})
|
|
|
|
set(_UNUSED ${CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION})
|
|
|
|
set(_UNUSED ${CMAKE_EXPORT_NO_PACKAGE_REGISTRY})
|
|
|
|
set(_UNUSED ${CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY})
|
|
|
|
set(_UNUSED ${CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY})
|
|
|
|
set(_UNUSED ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP})
|