2016-09-19 11:50:08 +08:00
function ( vcpkg_configure_cmake )
2017-02-04 00:16:13 +08:00
cmake_parse_arguments ( _csc "PREFER_NINJA" "SOURCE_PATH;GENERATOR" "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE" ${ ARGN } )
2016-09-19 11:50:08 +08:00
2017-01-25 10:55:41 +08:00
if ( NOT VCPKG_PLATFORM_TOOLSET )
message ( FATAL_ERROR "Vcpkg has been updated with VS2017 support, however you need to rebuild vcpkg.exe by re-running bootstrap.ps1\n powershell -exec bypass scripts\\bootstrap.ps1\n" )
endif ( )
2016-09-19 11:50:08 +08:00
if ( _csc_GENERATOR )
set ( GENERATOR ${ _csc_GENERATOR } )
2017-02-04 00:16:13 +08:00
elseif ( _csc_PREFER_NINJA AND NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" )
set ( GENERATOR "Ninja" )
2017-01-24 11:25:47 +08:00
elseif ( VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "x86" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140" )
2016-09-19 11:50:08 +08:00
set ( GENERATOR "Visual Studio 14 2015" )
2017-01-24 11:25:47 +08:00
elseif ( VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "x64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140" )
2016-09-19 11:50:08 +08:00
set ( GENERATOR "Visual Studio 14 2015 Win64" )
2017-01-24 11:25:47 +08:00
elseif ( VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "arm" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140" )
2016-09-19 11:50:08 +08:00
set ( GENERATOR "Visual Studio 14 2015 ARM" )
2017-01-24 11:25:47 +08:00
elseif ( TRIPLET_SYSTEM_ARCH MATCHES "x86" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140" )
2016-09-19 11:50:08 +08:00
set ( GENERATOR "Visual Studio 14 2015" )
2017-01-24 11:25:47 +08:00
elseif ( TRIPLET_SYSTEM_ARCH MATCHES "x64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140" )
2016-09-19 11:50:08 +08:00
set ( GENERATOR "Visual Studio 14 2015 Win64" )
elseif ( TRIPLET_SYSTEM_ARCH MATCHES "arm" )
2017-01-24 11:25:47 +08:00
set ( GENERATOR "Visual Studio 14 2015 ARM" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140" )
elseif ( VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "x86" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141" )
set ( GENERATOR "Visual Studio 15 2017" )
elseif ( VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "x64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141" )
set ( GENERATOR "Visual Studio 15 2017 Win64" )
elseif ( VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "arm" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141" )
set ( GENERATOR "Visual Studio 15 2017 ARM" )
elseif ( TRIPLET_SYSTEM_ARCH MATCHES "x86" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141" )
set ( GENERATOR "Visual Studio 15 2017" )
elseif ( TRIPLET_SYSTEM_ARCH MATCHES "x64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141" )
set ( GENERATOR "Visual Studio 15 2017 Win64" )
elseif ( TRIPLET_SYSTEM_ARCH MATCHES "arm" )
set ( GENERATOR "Visual Studio 15 2017 ARM" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141" )
2016-09-19 11:50:08 +08:00
endif ( )
2017-02-04 00:16:13 +08:00
# If we use Ninja, make sure it's on PATH
if ( GENERATOR STREQUAL "Ninja" )
vcpkg_find_acquire_program ( NINJA )
get_filename_component ( NINJA_PATH ${ NINJA } DIRECTORY )
2017-02-09 09:39:31 +08:00
set ( ENV{PATH} "$ENV{PATH};${NINJA_PATH}" )
2017-02-04 00:16:13 +08:00
endif ( )
2016-09-19 11:50:08 +08:00
file ( REMOVE_RECURSE ${ CURRENT_BUILDTREES_DIR } / ${ TARGET_TRIPLET } -rel ${ CURRENT_BUILDTREES_DIR } / ${ TARGET_TRIPLET } -dbg )
2016-10-07 04:46:41 +08:00
if ( DEFINED VCPKG_CMAKE_SYSTEM_NAME )
list ( APPEND _csc_OPTIONS -DCMAKE_SYSTEM_NAME= ${ VCPKG_CMAKE_SYSTEM_NAME } )
endif ( )
if ( DEFINED VCPKG_CMAKE_SYSTEM_VERSION )
list ( APPEND _csc_OPTIONS -DCMAKE_SYSTEM_VERSION= ${ VCPKG_CMAKE_SYSTEM_VERSION } )
endif ( )
2016-10-08 07:34:31 +08:00
if ( DEFINED VCPKG_LIBRARY_LINKAGE AND VCPKG_LIBRARY_LINKAGE STREQUAL dynamic )
list ( APPEND _csc_OPTIONS -DBUILD_SHARED_LIBS=ON )
2016-10-19 03:55:37 +08:00
elseif ( DEFINED VCPKG_LIBRARY_LINKAGE AND VCPKG_LIBRARY_LINKAGE STREQUAL static )
list ( APPEND _csc_OPTIONS -DBUILD_SHARED_LIBS=OFF )
2016-10-07 04:46:41 +08:00
endif ( )
2017-01-24 11:25:47 +08:00
2016-10-07 04:46:41 +08:00
2016-10-12 01:32:40 +08:00
list ( APPEND _csc_OPTIONS
2017-02-02 08:19:27 +08:00
" - D C M A K E _ C X X _ F L A G S = / D W I N 3 2 / D _ W I N D O W S / W 3 / u t f - 8 / G R / E H s c / M P "
" - D C M A K E _ C _ F L A G S = / D W I N 3 2 / D _ W I N D O W S / W 3 / u t f - 8 / M P "
2016-12-06 17:26:21 +08:00
" - D C M A K E _ E X P O R T _ N O _ P A C K A G E _ R E G I S T R Y = O N "
" - D C M A K E _ F I N D _ P A C K A G E _ N O _ P A C K A G E _ R E G I S T R Y = O N "
" - D C M A K E _ F I N D _ P A C K A G E _ N O _ S Y S T E M _ P A C K A G E _ R E G I S T R Y = O N "
2017-02-03 07:41:20 +08:00
" - D B o o s t _ C O M P I L E R = - v c 1 4 0 "
2016-10-12 01:32:40 +08:00
)
2016-10-19 03:55:37 +08:00
if ( DEFINED VCPKG_CRT_LINKAGE AND VCPKG_CRT_LINKAGE STREQUAL dynamic )
list ( APPEND _csc_OPTIONS_DEBUG
" - D C M A K E _ C X X _ F L A G S _ D E B U G = / D _ D E B U G / M D d / Z i / O b 0 / O d / R T C 1 "
2016-11-01 07:18:30 +08:00
" - D C M A K E _ C _ F L A G S _ D E B U G = / D _ D E B U G / M D d / Z i / O b 0 / O d / R T C 1 "
2016-10-19 03:55:37 +08:00
)
list ( APPEND _csc_OPTIONS_RELEASE
" - D C M A K E _ C X X _ F L A G S _ R E L E A S E = / M D / O 2 / O i / G y / D N D E B U G / Z i "
" - D C M A K E _ C _ F L A G S _ R E L E A S E = / M D / O 2 / O i / G y / D N D E B U G / Z i "
)
elseif ( DEFINED VCPKG_CRT_LINKAGE AND VCPKG_CRT_LINKAGE STREQUAL static )
list ( APPEND _csc_OPTIONS_DEBUG
" - D C M A K E _ C X X _ F L A G S _ D E B U G = / D _ D E B U G / M T d / Z i / O b 0 / O d / R T C 1 "
2016-11-01 07:18:30 +08:00
" - D C M A K E _ C _ F L A G S _ D E B U G = / D _ D E B U G / M T d / Z i / O b 0 / O d / R T C 1 "
2016-10-19 03:55:37 +08:00
)
list ( APPEND _csc_OPTIONS_RELEASE
" - D C M A K E _ C X X _ F L A G S _ R E L E A S E = / M T / O 2 / O i / G y / D N D E B U G / Z i "
" - D C M A K E _ C _ F L A G S _ R E L E A S E = / M T / O 2 / O i / G y / D N D E B U G / Z i "
)
endif ( )
2016-10-08 03:55:41 +08:00
list ( APPEND _csc_OPTIONS_RELEASE
2016-10-11 19:36:37 +08:00
" - D C M A K E _ S H A R E D _ L I N K E R _ F L A G S _ R E L E A S E = / D E B U G / I N C R E M E N T A L : N O / O P T : R E F / O P T : I C F "
" - D C M A K E _ E X E _ L I N K E R _ F L A G S _ R E L E A S E = / D E B U G / I N C R E M E N T A L : N O / O P T : R E F / O P T : I C F "
2016-10-08 03:55:41 +08:00
)
2016-09-19 11:50:08 +08:00
message ( STATUS "Configuring ${TARGET_TRIPLET}-rel" )
file ( MAKE_DIRECTORY ${ CURRENT_BUILDTREES_DIR } / ${ TARGET_TRIPLET } -rel )
vcpkg_execute_required_process (
C O M M A N D $ { C M A K E _ C O M M A N D } $ { _ c s c _ S O U R C E _ P A T H } $ { _ c s c _ O P T I O N S } $ { _ c s c _ O P T I O N S _ R E L E A S E }
- G $ { G E N E R A T O R }
- D C M A K E _ V E R B O S E _ M A K E F I L E = O N
- D C M A K E _ B U I L D _ T Y P E = R e l e a s e
2016-10-04 07:52:36 +08:00
- D C M A K E _ T O O L C H A I N _ F I L E = $ { C M A K E _ T R I P L E T _ F I L E }
2016-09-19 11:50:08 +08:00
- D C M A K E _ P R E F I X _ P A T H = $ { C U R R E N T _ I N S T A L L E D _ D I R }
- D C M A K E _ I N S T A L L _ P R E F I X = $ { C U R R E N T _ P A C K A G E S _ D I R }
W O R K I N G _ D I R E C T O R Y $ { C U R R E N T _ B U I L D T R E E S _ D I R } / $ { T A R G E T _ T R I P L E T } - r e l
L O G N A M E c o n f i g - $ { T A R G E T _ T R I P L E T } - r e l
)
message ( STATUS "Configuring ${TARGET_TRIPLET}-rel done" )
message ( STATUS "Configuring ${TARGET_TRIPLET}-dbg" )
file ( MAKE_DIRECTORY ${ CURRENT_BUILDTREES_DIR } / ${ TARGET_TRIPLET } -dbg )
vcpkg_execute_required_process (
C O M M A N D $ { C M A K E _ C O M M A N D } $ { _ c s c _ S O U R C E _ P A T H } $ { _ c s c _ O P T I O N S } $ { _ c s c _ O P T I O N S _ D E B U G }
- G $ { G E N E R A T O R }
- D C M A K E _ V E R B O S E _ M A K E F I L E = O N
- D C M A K E _ B U I L D _ T Y P E = D e b u g
2016-10-04 07:52:36 +08:00
- D C M A K E _ T O O L C H A I N _ F I L E = $ { C M A K E _ T R I P L E T _ F I L E }
2016-09-19 11:50:08 +08:00
- D C M A K E _ P R E F I X _ P A T H = $ { C U R R E N T _ I N S T A L L E D _ D I R } / d e b u g \ \ \ \ \ \ \ ; $ { C U R R E N T _ I N S T A L L E D _ D I R }
- D C M A K E _ I N S T A L L _ P R E F I X = $ { C U R R E N T _ P A C K A G E S _ D I R } / d e b u g
W O R K I N G _ D I R E C T O R Y $ { C U R R E N T _ B U I L D T R E E S _ D I R } / $ { T A R G E T _ T R I P L E T } - d b g
L O G N A M E c o n f i g - $ { T A R G E T _ T R I P L E T } - d b g
)
message ( STATUS "Configuring ${TARGET_TRIPLET}-dbg done" )
endfunction ( )