2016-09-18 20:50:08 -07: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-10-31 09:37:13 -07:00
|
|
|
elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 14 2015$")
|
|
|
|
set(_VCPKG_TARGET_TRIPLET_ARCH x86)
|
2016-11-19 01:33:31 -05: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-18 20:50:08 -07:00
|
|
|
else()
|
2016-10-30 18:46:24 +09:00
|
|
|
find_program(_VCPKG_CL cl)
|
2016-11-16 12:38:30 -05:00
|
|
|
if(_VCPKG_CL MATCHES "amd64/cl.exe$" OR _VCPKG_CL MATCHES "x64/cl.exe$")
|
2016-10-30 18:46:24 +09:00
|
|
|
set(_VCPKG_TARGET_TRIPLET_ARCH x64)
|
|
|
|
elseif(_VCPKG_CL MATCHES "arm/cl.exe$")
|
|
|
|
set(_VCPKG_TARGET_TRIPLET_ARCH arm)
|
2016-10-31 10:11:25 -07:00
|
|
|
elseif(_VCPKG_CL MATCHES "bin/cl.exe$" OR _VCPKG_CL MATCHES "x86/cl.exe$")
|
2016-10-30 18:46:24 +09:00
|
|
|
set(_VCPKG_TARGET_TRIPLET_ARCH x86)
|
2016-10-31 09:37:13 -07:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Unable to determine target architecture.")
|
2016-10-30 18:46:24 +09:00
|
|
|
endif()
|
2016-09-18 20:50:08 -07:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WINDOWS_STORE OR WINDOWS_PHONE)
|
|
|
|
set(_VCPKG_TARGET_TRIPLET_PLAT uwp)
|
|
|
|
else()
|
|
|
|
set(_VCPKG_TARGET_TRIPLET_PLAT windows)
|
|
|
|
endif()
|
|
|
|
|
2016-09-28 12:05:46 -07:00
|
|
|
set(VCPKG_TARGET_TRIPLET ${_VCPKG_TARGET_TRIPLET_ARCH}-${_VCPKG_TARGET_TRIPLET_PLAT} CACHE STRING "Vcpkg target triplet (ex. x86-windows)")
|
2016-09-24 12:05:56 -07:00
|
|
|
set(_VCPKG_INSTALLED_DIR ${CMAKE_CURRENT_LIST_DIR}/../../installed)
|
2016-09-18 20:50:08 -07:00
|
|
|
set(_VCPKG_TOOLCHAIN_DIR ${CMAKE_CURRENT_LIST_DIR})
|
|
|
|
|
|
|
|
if(CMAKE_BUILD_TYPE MATCHES "^Debug$" OR NOT DEFINED CMAKE_BUILD_TYPE)
|
|
|
|
list(APPEND CMAKE_PREFIX_PATH
|
2016-09-28 12:05:46 -07:00
|
|
|
${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug
|
2016-09-18 20:50:08 -07:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
list(APPEND CMAKE_PREFIX_PATH
|
2016-09-28 12:05:46 -07:00
|
|
|
${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}
|
2016-09-18 20:50:08 -07:00
|
|
|
)
|
|
|
|
|
2016-09-28 12:05:46 -07:00
|
|
|
include_directories(${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include)
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2016-10-09 10:59:37 -05:00
|
|
|
set(CMAKE_PROGRAM_PATH ${CMAKE_PROGRAM_PATH} ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/tools)
|
|
|
|
|
2016-09-18 20:50:08 -07:00
|
|
|
option(OVERRIDE_ADD_EXECUTABLE "Automatically copy dependencies into the output directory for executables." ON)
|
|
|
|
if(OVERRIDE_ADD_EXECUTABLE)
|
|
|
|
function(add_executable name)
|
|
|
|
_add_executable(${ARGV})
|
2016-11-11 16:17:39 -08:00
|
|
|
list(FIND ARGV "IMPORTED" IMPORTED_IDX)
|
|
|
|
if(IMPORTED_IDX EQUAL -1)
|
|
|
|
add_custom_command(TARGET ${name} POST_BUILD
|
|
|
|
COMMAND powershell -noprofile -executionpolicy UnRestricted -file ${_VCPKG_TOOLCHAIN_DIR}/msbuild/applocal.ps1
|
|
|
|
-targetBinary $<TARGET_FILE:${name}>
|
|
|
|
-installedDir "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$<CONFIG:Debug>:/debug>/bin"
|
|
|
|
-OutVariable out
|
|
|
|
)
|
2016-11-01 19:19:05 -04:00
|
|
|
endif()
|
2016-09-18 20:50:08 -07:00
|
|
|
endfunction()
|
|
|
|
endif()
|
|
|
|
set(VCPKG_TOOLCHAIN ON)
|
|
|
|
endif()
|