2021-11-06 07:55:14 +08:00
function ( z_vcpkg_configure_cmake_both_or_neither_set var1 var2 )
if ( DEFINED "${var1}" AND NOT DEFINED "${var2}" )
message ( FATAL_ERROR "If ${var1} is set, ${var2} must be set." )
endif ( )
if ( NOT DEFINED "${var1}" AND DEFINED "${var2}" )
message ( FATAL_ERROR "If ${var2} is set, ${var1} must be set." )
endif ( )
endfunction ( )
function ( z_vcpkg_configure_cmake_build_cmakecache out_var whereat build_type )
2022-07-26 03:23:04 +08:00
set ( line "build ${whereat}/CMakeCache.txt: CreateProcess\n" )
string ( APPEND line " process = \" ${ CMAKE_COMMAND } \" -E chdir \"${whereat}\"")
2021-11-06 07:55:14 +08:00
foreach ( arg IN LISTS "${build_type}_command" )
string ( APPEND line " \" ${ arg } \"")
endforeach ( )
2022-07-26 03:23:04 +08:00
set ( "${out_var}" "${${out_var}}${line}\n\n" PARENT_SCOPE )
2021-11-06 07:55:14 +08:00
endfunction ( )
2022-04-12 06:57:36 +08:00
function ( z_vcpkg_get_visual_studio_generator )
cmake_parse_arguments ( PARSE_ARGV 0 arg "" "OUT_GENERATOR;OUT_ARCH" "" )
if ( NOT DEFINED arg_OUT_GENERATOR )
message ( FATAL_ERROR "OUT_GENERATOR must be defined." )
endif ( )
if ( NOT DEFINED arg_OUT_ARCH )
message ( FATAL_ERROR "OUT_ARCH must be defined." )
endif ( )
if ( DEFINED arg_UNPARSED_ARGUMENTS )
message ( FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}" )
endif ( )
2022-09-23 05:28:20 +08:00
if ( DEFINED ENV{VisualStudioVersion} )
if ( "$ENV{VisualStudioVersion}" VERSION_LESS_EQUAL "12.99" AND
" $ E N V { V i s u a l S t u d i o V e r s i o n } " V E R S I O N _ G R E A T E R _ E Q U A L " 1 2 . 0 " A N D
N O T " $ { V C P K G _ T A R G E T _ A R C H I T E C T U R E } " S T R E Q U A L " a r m 6 4 " )
set ( generator "Visual Studio 12 2013" )
elseif ( "$ENV{VisualStudioVersion}" VERSION_LESS_EQUAL "14.99" AND
N O T " $ { V C P K G _ T A R G E T _ A R C H I T E C T U R E } " S T R E Q U A L " a r m 6 4 " )
set ( generator "Visual Studio 14 2015" )
elseif ( "$ENV{VisualStudioVersion}" VERSION_LESS_EQUAL "15.99" )
set ( generator "Visual Studio 15 2017" )
elseif ( "$ENV{VisualStudioVersion}" VERSION_LESS_EQUAL "16.99" )
set ( generator "Visual Studio 16 2019" )
elseif ( "$ENV{VisualStudioVersion}" VERSION_LESS_EQUAL "17.99" )
set ( generator "Visual Studio 17 2022" )
endif ( )
2022-04-12 06:57:36 +08:00
endif ( )
if ( "${VCPKG_TARGET_ARCHITECTURE}" STREQUAL "x86" )
set ( generator_arch "Win32" )
elseif ( "${VCPKG_TARGET_ARCHITECTURE}" STREQUAL "x64" )
set ( generator_arch "x64" )
elseif ( "${VCPKG_TARGET_ARCHITECTURE}" STREQUAL "arm" )
set ( generator_arch "ARM" )
elseif ( "${VCPKG_TARGET_ARCHITECTURE}" STREQUAL "arm64" )
set ( generator_arch "ARM64" )
endif ( )
set ( ${ arg_OUT_GENERATOR } "${generator}" PARENT_SCOPE )
set ( ${ arg_OUT_ARCH } "${generator_arch}" PARENT_SCOPE )
endfunction ( )
function ( z_vcpkg_select_default_vcpkg_chainload_toolchain )
# Try avoiding adding more defaults here.
# Set VCPKG_CHAINLOAD_TOOLCHAIN_FILE explicitly in the triplet.
if ( DEFINED Z_VCPKG_CHAINLOAD_TOOLCHAIN_FILE )
set ( VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${Z_VCPKG_CHAINLOAD_TOOLCHAIN_FILE}" )
elseif ( VCPKG_TARGET_IS_MINGW )
set ( VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/mingw.cmake" )
elseif ( VCPKG_TARGET_IS_WINDOWS )
set ( VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/windows.cmake" )
elseif ( VCPKG_TARGET_IS_LINUX )
set ( VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/linux.cmake" )
elseif ( VCPKG_TARGET_IS_ANDROID )
set ( VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/android.cmake" )
elseif ( VCPKG_TARGET_IS_OSX )
set ( VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/osx.cmake" )
elseif ( VCPKG_TARGET_IS_IOS )
set ( VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/ios.cmake" )
elseif ( VCPKG_TARGET_IS_FREEBSD )
set ( VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/freebsd.cmake" )
elseif ( VCPKG_TARGET_IS_OPENBSD )
set ( VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/openbsd.cmake" )
endif ( )
set ( VCPKG_CHAINLOAD_TOOLCHAIN_FILE ${ VCPKG_CHAINLOAD_TOOLCHAIN_FILE } PARENT_SCOPE )
endfunction ( )
2021-11-06 07:55:14 +08:00
2016-09-19 11:50:08 +08:00
function ( vcpkg_configure_cmake )
2021-03-01 05:17:19 +08:00
cmake_parse_arguments ( PARSE_ARGV 0 arg
2021-07-30 00:47:35 +08:00
" P R E F E R _ N I N J A ; D I S A B L E _ P A R A L L E L _ C O N F I G U R E ; N O _ C H A R S E T _ F L A G ; Z _ G E T _ C M A K E _ V A R S _ U S A G E "
2020-10-16 02:01:00 +08:00
" S O U R C E _ P A T H ; G E N E R A T O R ; L O G N A M E "
2021-07-21 01:24:58 +08:00
" O P T I O N S ; O P T I O N S _ D E B U G ; O P T I O N S _ R E L E A S E ; M A Y B E _ U N U S E D _ V A R I A B L E S "
2019-07-10 05:53:48 +08:00
)
2016-09-19 11:50:08 +08:00
2021-07-30 00:47:35 +08:00
if ( NOT arg_Z_GET_CMAKE_VARS_USAGE AND Z_VCPKG_CMAKE_CONFIGURE_GUARD )
message ( FATAL_ERROR "The ${PORT} port already depends on vcpkg-cmake; using both vcpkg-cmake and vcpkg_configure_cmake in the same port is unsupported." )
endif ( )
2021-11-06 07:55:14 +08:00
if ( DEFINED arg_UNPARSED_ARGUMENTS )
message ( WARNING "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}" )
2017-04-23 15:11:42 +08:00
endif ( )
2021-11-06 07:55:14 +08:00
if ( NOT DEFINED arg_SOURCE_PATH )
message ( FATAL_ERROR "SOURCE_PATH must be specified" )
endif ( )
if ( NOT DEFINED arg_LOGNAME )
set ( arg_LOGNAME "config-${TARGET_TRIPLET}" )
2020-10-16 02:01:00 +08:00
endif ( )
2021-11-06 07:55:14 +08:00
vcpkg_list ( SET manually_specified_variables )
2021-07-30 00:47:35 +08:00
if ( arg_Z_GET_CMAKE_VARS_USAGE )
set ( configuring_message "Getting CMake variables for ${TARGET_TRIPLET}" )
else ( )
set ( configuring_message "Configuring ${TARGET_TRIPLET}" )
2021-07-21 01:24:58 +08:00
foreach ( option IN LISTS arg_OPTIONS arg_OPTIONS_RELEASE arg_OPTIONS_DEBUG )
2021-11-06 07:55:14 +08:00
if ( "${option}" MATCHES "^-D([^:=]*)[:=]" )
vcpkg_list ( APPEND manually_specified_variables "${CMAKE_MATCH_1}" )
2021-07-21 01:24:58 +08:00
endif ( )
endforeach ( )
2021-11-06 07:55:14 +08:00
vcpkg_list ( REMOVE_DUPLICATES manually_specified_variables )
foreach ( maybe_unused_var IN LISTS arg_MAYBE_UNUSED_VARIABLES )
vcpkg_list ( REMOVE_ITEM manually_specified_variables "${maybe_unused_var}" )
endforeach ( )
2021-07-21 01:24:58 +08:00
debug_message ( "manually specified variables: ${manually_specified_variables}" )
endif ( )
2021-11-06 07:55:14 +08:00
set ( ninja_can_be_used ON ) # Ninja as generator
set ( ninja_host ON ) # Ninja as parallel configurator
2022-04-12 06:57:36 +08:00
if ( NOT arg_PREFER_NINJA AND VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW )
set ( ninja_can_be_used OFF )
endif ( )
2021-11-06 07:55:14 +08:00
if ( VCPKG_HOST_IS_WINDOWS )
2019-07-10 05:53:48 +08:00
if ( DEFINED ENV{PROCESSOR_ARCHITEW6432} )
2021-11-06 07:55:14 +08:00
set ( host_arch "$ENV{PROCESSOR_ARCHITEW6432}" )
2019-07-10 05:53:48 +08:00
else ( )
2021-11-06 07:55:14 +08:00
set ( host_arch "$ENV{PROCESSOR_ARCHITECTURE}" )
2019-07-10 05:53:48 +08:00
endif ( )
2018-08-09 01:51:33 +08:00
2021-11-06 07:55:14 +08:00
if ( "${host_arch}" STREQUAL "x86" )
# Prebuilt ninja binaries are only provided for x64 hosts
set ( ninja_can_be_used OFF )
set ( ninja_host OFF )
endif ( )
2019-07-10 05:53:48 +08:00
endif ( )
2022-04-12 06:57:36 +08:00
set ( generator "Ninja" ) # the default generator is always ninja!
2021-11-06 07:55:14 +08:00
set ( generator_arch "" )
if ( DEFINED arg_GENERATOR )
set ( generator "${arg_GENERATOR}" )
2022-04-12 06:57:36 +08:00
elseif ( NOT ninja_can_be_used )
set ( generator "" )
z_vcpkg_get_visual_studio_generator ( OUT_GENERATOR generator OUT_ARCH generator_arch )
2021-11-06 07:55:14 +08:00
if ( "${generator}" STREQUAL "" OR "${generator_arch}" STREQUAL "" )
message ( FATAL_ERROR
" U n a b l e t o d e t e r m i n e a p p r o p r i a t e g e n e r a t o r f o r t r i p l e t $ { T A R G E T _ T R I P L E T } :
2022-09-23 05:28:20 +08:00
E N V { V i s u a l S t u d i o V e r s i o n } : $ E N V { V i s u a l S t u d i o V e r s i o n }
2021-11-06 07:55:14 +08:00
p l a t f o r m t o o l s e t : $ { V C P K G _ P L A T F O R M _ T O O L S E T }
a r c h i t e c t u r e : $ { V C P K G _ T A R G E T _ A R C H I T E C T U R E } " )
2019-03-06 06:42:07 +08:00
endif ( )
2022-09-23 05:28:20 +08:00
if ( DEFINED VCPKG_PLATFORM_TOOLSET )
vcpkg_list ( APPEND arg_OPTIONS "-T${VCPKG_PLATFORM_TOOLSET}" )
endif ( )
2016-09-19 11:50:08 +08:00
endif ( )
2018-03-02 00:31:14 +08:00
2017-02-04 00:16:13 +08:00
# If we use Ninja, make sure it's on PATH
2021-11-06 07:55:14 +08:00
if ( "${generator}" STREQUAL "Ninja" AND NOT DEFINED ENV{VCPKG_FORCE_SYSTEM_BINARIES} )
2017-02-04 00:16:13 +08:00
vcpkg_find_acquire_program ( NINJA )
2022-05-07 06:12:11 +08:00
get_filename_component ( ninja_path "${NINJA}" DIRECTORY )
vcpkg_add_to_path ( "${ninja_path}" )
2021-11-06 07:55:14 +08:00
vcpkg_list ( APPEND arg_OPTIONS "-DCMAKE_MAKE_PROGRAM=${NINJA}" )
2017-02-04 00:16:13 +08:00
endif ( )
2016-09-19 11:50:08 +08:00
2021-11-06 07:55:14 +08:00
file ( REMOVE_RECURSE
" $ { 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 "
" $ { 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 " )
2016-09-19 11:50:08 +08:00
2016-10-07 04:46:41 +08:00
if ( DEFINED VCPKG_CMAKE_SYSTEM_NAME )
2021-11-06 07:55:14 +08:00
vcpkg_list ( APPEND arg_OPTIONS "-DCMAKE_SYSTEM_NAME=${VCPKG_CMAKE_SYSTEM_NAME}" )
if ( VCPKG_TARGET_IS_UWP AND NOT DEFINED VCPKG_CMAKE_SYSTEM_VERSION )
2018-11-21 08:28:12 +08:00
set ( VCPKG_CMAKE_SYSTEM_VERSION 10.0 )
2021-11-06 07:55:14 +08:00
elseif ( VCPKG_TARGET_IS_ANDROID AND NOT DEFINED VCPKG_CMAKE_SYSTEM_VERSION )
2020-11-19 07:45:05 +08:00
set ( VCPKG_CMAKE_SYSTEM_VERSION 21 )
2018-11-21 08:28:12 +08:00
endif ( )
2016-10-07 04:46:41 +08:00
endif ( )
2019-07-10 05:53:48 +08:00
2023-06-09 02:17:29 +08:00
if ( DEFINED VCPKG_XBOX_CONSOLE_TARGET )
vcpkg_list ( APPEND arg_OPTIONS "-DXBOX_CONSOLE_TARGET=${VCPKG_XBOX_CONSOLE_TARGET}" )
endif ( )
2016-10-07 04:46:41 +08:00
if ( DEFINED VCPKG_CMAKE_SYSTEM_VERSION )
2021-11-06 07:55:14 +08:00
vcpkg_list ( APPEND arg_OPTIONS "-DCMAKE_SYSTEM_VERSION=${VCPKG_CMAKE_SYSTEM_VERSION}" )
2016-10-07 04:46:41 +08:00
endif ( )
2017-10-17 02:22:21 +08:00
2021-11-06 07:55:14 +08:00
if ( "${VCPKG_LIBRARY_LINKAGE}" STREQUAL "dynamic" )
vcpkg_list ( APPEND arg_OPTIONS -DBUILD_SHARED_LIBS=ON )
elseif ( "${VCPKG_LIBRARY_LINKAGE}" STREQUAL "static" )
vcpkg_list ( APPEND arg_OPTIONS -DBUILD_SHARED_LIBS=OFF )
2017-10-17 02:22:21 +08:00
else ( )
2019-07-10 05:53:48 +08:00
message ( FATAL_ERROR
2021-11-06 07:55:14 +08:00
" I n v a l i d s e t t i n g f o r V C P K G _ L I B R A R Y _ L I N K A G E : \ " $ { V C P K G _ L I B R A R Y _ L I N K A G E } \ " .
I t m u s t b e \ " s t a t i c \ " o r \ " d y n a m i c \ " " )
2017-05-31 03:24:21 +08:00
endif ( )
2020-01-18 07:36:08 +08:00
2021-11-06 07:55:14 +08:00
z_vcpkg_configure_cmake_both_or_neither_set ( VCPKG_CXX_FLAGS_DEBUG VCPKG_C_FLAGS_DEBUG )
z_vcpkg_configure_cmake_both_or_neither_set ( VCPKG_CXX_FLAGS_RELEASE VCPKG_C_FLAGS_RELEASE )
z_vcpkg_configure_cmake_both_or_neither_set ( VCPKG_CXX_FLAGS VCPKG_C_FLAGS )
2019-07-10 05:53:48 +08:00
2021-11-06 07:55:14 +08:00
set ( vcpkg_set_charset_flag ON )
2021-03-01 05:17:19 +08:00
if ( arg_NO_CHARSET_FLAG )
2021-11-06 07:55:14 +08:00
set ( vcpkg_set_charset_flag OFF )
2019-07-01 00:31:22 +08:00
endif ( )
2016-10-07 04:46:41 +08:00
2019-07-10 05:53:48 +08:00
if ( NOT VCPKG_CHAINLOAD_TOOLCHAIN_FILE )
2022-04-12 06:57:36 +08:00
z_vcpkg_select_default_vcpkg_chainload_toolchain ( )
2017-10-17 02:22:21 +08:00
endif ( )
2021-11-06 07:55:14 +08:00
vcpkg_list ( APPEND arg_OPTIONS
2019-07-10 05:53:48 +08:00
" - D V C P K G _ C H A I N L O A D _ T O O L C H A I N _ F I L E = $ { V C P K G _ C H A I N L O A D _ T O O L C H A I N _ F I L E } "
2017-03-31 15:35:40 +08:00
" - D V C P K G _ T A R G E T _ T R I P L E T = $ { T A R G E T _ T R I P L E T } "
2021-11-06 07:55:14 +08:00
" - D V C P K G _ S E T _ C H A R S E T _ F L A G = $ { v c p k g _ s e t _ c h a r s e t _ f l a g } "
2018-04-03 11:40:25 +08:00
" - D V C P K G _ P L A T F O R M _ T O O L S E T = $ { V C P K G _ P L A T F O R M _ T O O L S E T } "
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-03-07 02:35:03 +08:00
" - D C M A K E _ I N S T A L L _ S Y S T E M _ R U N T I M E _ L I B S _ S K I P = T R U E "
" - D C M A K E _ V E R B O S E _ M A K E F I L E = O N "
2017-03-21 16:48:40 +08:00
" - D V C P K G _ A P P L O C A L _ D E P S = O F F "
2019-09-13 14:52:52 +08:00
" - D C M A K E _ T O O L C H A I N _ F I L E = $ { S C R I P T S } / b u i l d s y s t e m s / v c p k g . c m a k e "
2017-03-21 16:48:40 +08:00
" - D C M A K E _ E R R O R _ O N _ A B S O L U T E _ I N S T A L L _ D E S T I N A T I O N = O N "
2018-03-07 01:57:37 +08:00
" - D V C P K G _ C X X _ F L A G S = $ { V C P K G _ C X X _ F L A G S } "
" - D V C P K G _ C X X _ F L A G S _ R E L E A S E = $ { V C P K G _ C X X _ F L A G S _ R E L E A S E } "
" - D V C P K G _ C X X _ F L A G S _ D E B U G = $ { V C P K G _ C X X _ F L A G S _ D E B U G } "
" - D V C P K G _ C _ F L A G S = $ { V C P K G _ C _ F L A G S } "
" - D V C P K G _ C _ F L A G S _ R E L E A S E = $ { V C P K G _ C _ F L A G S _ R E L E A S E } "
" - D V C P K G _ C _ F L A G S _ D E B U G = $ { V C P K G _ C _ F L A G S _ D E B U G } "
" - D V C P K G _ C R T _ L I N K A G E = $ { V C P K G _ C R T _ L I N K A G E } "
" - D V C P K G _ L I N K E R _ F L A G S = $ { V C P K G _ L I N K E R _ F L A G S } "
2020-09-04 02:00:35 +08:00
" - D V C P K G _ L I N K E R _ F L A G S _ R E L E A S E = $ { V C P K G _ L I N K E R _ F L A G S _ R E L E A S E } "
" - D V C P K G _ L I N K E R _ F L A G S _ D E B U G = $ { V C P K G _ L I N K E R _ F L A G S _ D E B U G } "
2021-11-06 07:55:14 +08:00
" - D V C P K G _ T A R G E T _ A R C H I T E C T U R E = $ { V C P K G _ T A R G E T _ A R C H I T E C T U R E } "
2018-03-24 07:23:37 +08:00
" - D C M A K E _ I N S T A L L _ L I B D I R : S T R I N G = l i b "
" - D C M A K E _ I N S T A L L _ B I N D I R : S T R I N G = b i n "
2020-06-04 10:31:28 +08:00
" - D _ V C P K G _ R O O T _ D I R = $ { V C P K G _ R O O T _ D I R } "
2021-11-06 07:55:14 +08:00
" - D Z _ V C P K G _ R O O T _ D I R = $ { V C P K G _ R O O T _ D I R } "
2020-06-04 10:31:28 +08:00
" - D _ V C P K G _ I N S T A L L E D _ D I R = $ { _ V C P K G _ I N S T A L L E D _ D I R } "
[vcpkg manifest] Manifest Implementation (#11757)
==== Changes Related to manifests ====
* Add the `manifests` feature flag
* This only says whether we look for a `vcpkg.json` in the cwd, not
whether we support parsing manifests (for ports, for example)
* Changes to the manifests RFC
* `"authors"` -> `"maintainers"`
* `--x-classic-mode` -> `-manifests` \in `vcpkg_feature_flags`
* reserve `"core"` in addition to `"default"`, since that's already
reserved for features
* Add a small helper note about what identifiers must look like
* `<license-string>`: SPDX v3.8 -> v3.9
* `"feature"."description"` is allowed to be an array of strings as well
* `"version"` -> `"version-string"` for forward-compat with versions
RFC
* Add the `--feature-flags` option
* Add the ability to turn off feature flags via passing
`-<feature-flag>` to `VCPKG_FEATURE_FLAGS` or `--feature-flags`
* Add CMake toolchain support for manifests
* Requires either:
* a feature flag of `manifests` in either `Env{VCPKG_FEATURE_FLAGS}`
or `VCPKG_FEATURE_FLAGS`
* Passing the `VCPKG_ENABLE_MANIFESTS` option
* The toolchain will install your packages to
`${VCPKG_MANIFEST_DIR}/vcpkg_installed`.
* Add MSBuild `vcpkg integrate install` support for manifests
* Requires `VcpkgEnableManifest` to be true
* `vcpkg create` creates a port that has a `vcpkg.json` instead of a
`CONTROL`
* argparse, abseil, 3fd, and avisynthplus ports switched to manifest
from CONTROL
* Add support for `--x-manifest-root`, as well as code for finding it if
not passed
* Add support for parsing manifests!
* Add a filesystem lock!
==== Important Changes which are somewhat unrelated to manifests ====
* Rename `logicexpression.{h,cpp}` to `platform-expression.{h,cpp}`
* Add `PlatformExpression` type which takes the place of the old logic
expression
* Split the parsing of platform expressions from checking whether
they're true or not
* Eagerly parse PlatformExpressions as opposed to leaving them as
strings
* Add checking for feature flag consistency
* i.e., if `-binarycaching` is passed, you shouldn't be passing
`--binarysource`
* Add the `Json::Reader` type which, with the help of user-defined
visitors, converts JSON to your internal type
* VcpkgArgParser: place the switch names into a constant as opposed to
using magic constants
* In general update the parsing code so that this ^ works
* Add `Port-Version` fields to CONTROL files
* This replaces the existing practice of
`Version: <my-version>-<port-version>`
==== Smaller changes ====
* small drive-by cleanups to some CMake
* `${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}` ->
`${CURRENT_INSTALLED_DIR}`
* Remove `-analyze` when compiling with clang-cl, since that's not a
supported flag (vcpkg's build system)
* Add a message about which compiler is detected by vcpkg's build
system machinery
* Fix `Expected::then`
* Convert `""` to `{}` for `std::string` and `fs::path`, to avoid a
`strlen` (additionally, `.empty()` instead of `== ""`, and `.clear()`)
* Add `Strings::strto` which converts strings to numeric types
* Support built-in arrays and `StringView` for `Strings::join`
* Add `operator<` and friends to `StringView`
* Add `substr` to `StringView`
* SourceParagraphParser gets some new errors
2020-07-01 01:40:18 +08:00
" - D V C P K G _ M A N I F E S T _ I N S T A L L = O F F "
2016-10-12 01:32:40 +08:00
)
2017-05-31 03:24:21 +08:00
2021-11-06 07:55:14 +08:00
if ( NOT "${generator_arch}" STREQUAL "" )
vcpkg_list ( APPEND arg_OPTIONS "-A${generator_arch}" )
2017-09-24 21:01:37 +08:00
endif ( )
2018-10-24 07:49:48 +08:00
# Sets configuration variables for macOS builds
2021-11-06 07:55:14 +08:00
foreach ( config_var IN ITEMS INSTALL_NAME_DIR OSX_DEPLOYMENT_TARGET OSX_SYSROOT OSX_ARCHITECTURES )
if ( DEFINED "VCPKG_${config_var}" )
vcpkg_list ( APPEND arg_OPTIONS "-DCMAKE_${config_var}=${VCPKG_${config_var}}" )
2019-07-10 05:53:48 +08:00
endif ( )
endforeach ( )
2018-10-24 07:49:48 +08:00
2022-05-07 06:12:11 +08:00
# Allow overrides / additional configuration variables from triplets
if ( DEFINED VCPKG_CMAKE_CONFIGURE_OPTIONS )
2022-06-21 04:58:43 +08:00
vcpkg_list ( APPEND arg_OPTIONS ${ VCPKG_CMAKE_CONFIGURE_OPTIONS } )
2022-05-07 06:12:11 +08:00
endif ( )
if ( DEFINED VCPKG_CMAKE_CONFIGURE_OPTIONS_RELEASE )
2022-06-21 04:58:43 +08:00
vcpkg_list ( APPEND arg_OPTIONS_RELEASE ${ VCPKG_CMAKE_CONFIGURE_OPTIONS_RELEASE } )
2022-05-07 06:12:11 +08:00
endif ( )
if ( DEFINED VCPKG_CMAKE_CONFIGURE_OPTIONS_DEBUG )
2022-06-21 04:58:43 +08:00
vcpkg_list ( APPEND arg_OPTIONS_DEBUG ${ VCPKG_CMAKE_CONFIGURE_OPTIONS_DEBUG } )
2022-05-07 06:12:11 +08:00
endif ( )
2021-11-06 07:55:14 +08:00
vcpkg_list ( SET rel_command
2022-05-07 06:12:11 +08:00
" $ { C M A K E _ C O M M A N D } " " $ { a r g _ S O U R C E _ P A T H } "
2021-11-06 07:55:14 +08:00
- G " $ { g e n e r a t o r } "
2022-05-07 06:12:11 +08:00
" - D C M A K E _ B U I L D _ T Y P E = R e l e a s e "
" - 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 } "
$ { a r g _ O P T I O N S } $ { a r g _ O P T I O N S _ R E L E A S E } )
2021-11-06 07:55:14 +08:00
vcpkg_list ( SET dbg_command
2022-05-07 06:12:11 +08:00
" $ { C M A K E _ C O M M A N D } " " $ { a r g _ S O U R C E _ P A T H } "
2021-11-06 07:55:14 +08:00
- G " $ { g e n e r a t o r } "
2022-05-07 06:12:11 +08:00
" - D C M A K E _ B U I L D _ T Y P E = D e b u g "
" - 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 "
$ { a r g _ O P T I O N S } $ { a r g _ O P T I O N S _ D E B U G } )
2018-02-08 08:57:47 +08:00
2021-11-06 07:55:14 +08:00
if ( ninja_host AND CMAKE_HOST_WIN32 AND NOT arg_DISABLE_PARALLEL_CONFIGURE )
vcpkg_list ( APPEND arg_OPTIONS "-DCMAKE_DISABLE_SOURCE_CHANGES=ON" )
2018-02-08 08:57:47 +08:00
vcpkg_find_acquire_program ( NINJA )
2022-05-07 06:12:11 +08:00
if ( NOT DEFINED ninja_path )
# if ninja_path was defined above, we've already done this
get_filename_component ( ninja_path "${NINJA}" DIRECTORY )
vcpkg_add_to_path ( "${ninja_path}" )
endif ( )
2018-02-08 08:57:47 +08:00
#parallelize the configure step
2021-11-06 07:55:14 +08:00
set ( ninja_configure_contents
" r u l e C r e a t e P r o c e s s \ n c o m m a n d = \ $ p r o c e s s \ n \ n "
2017-11-26 07:25:18 +08:00
)
2016-09-19 11:50:08 +08:00
2021-11-06 07:55:14 +08:00
if ( NOT DEFINED VCPKG_BUILD_TYPE OR "${VCPKG_BUILD_TYPE}" STREQUAL "release" )
z_vcpkg_configure_cmake_build_cmakecache ( ninja_configure_contents ".." "rel" )
endif ( )
if ( NOT DEFINED VCPKG_BUILD_TYPE OR "${VCPKG_BUILD_TYPE}" STREQUAL "debug" )
z_vcpkg_configure_cmake_build_cmakecache ( ninja_configure_contents "../../${TARGET_TRIPLET}-dbg" "dbg" )
2018-02-08 08:57:47 +08:00
endif ( )
2021-11-06 07:55:14 +08:00
file ( MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/vcpkg-parallel-configure" )
file ( WRITE
" $ { 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 / v c p k g - p a r a l l e l - c o n f i g u r e / b u i l d . n i n j a "
" $ { n i n j a _ c o n f i g u r e _ c o n t e n t s } " )
2018-02-08 08:57:47 +08:00
2021-07-30 00:47:35 +08:00
message ( STATUS "${configuring_message}" )
2017-11-26 07:25:18 +08:00
vcpkg_execute_required_process (
2022-05-07 06:12:11 +08:00
C O M M A N D " $ { N I N J A } " - v
2021-11-06 07:55:14 +08:00
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 / v c p k g - p a r a l l e l - c o n f i g u r e "
L O G N A M E " $ { a r g _ L O G N A M E } "
2023-01-10 03:13:59 +08:00
S A V E _ L O G _ F I L E S
" . . / . . / $ { T A R G E T _ T R I P L E T } - d b g / C M a k e C a c h e . t x t " A L I A S " d b g - C M a k e C a c h e . t x t . l o g "
" . . / C M a k e C a c h e . t x t " A L I A S " r e l - C M a k e C a c h e . t x t . l o g "
2017-11-26 07:25:18 +08:00
)
2021-07-21 01:24:58 +08:00
2021-11-06 07:55:14 +08:00
vcpkg_list ( APPEND config_logs
2021-07-21 01:24:58 +08:00
" $ { C U R R E N T _ B U I L D T R E E S _ D I R } / $ { a r g _ L O G N A M E } - o u t . l o g "
" $ { C U R R E N T _ B U I L D T R E E S _ D I R } / $ { a r g _ L O G N A M E } - e r r . l o g " )
2018-02-08 08:57:47 +08:00
else ( )
2021-11-06 07:55:14 +08:00
if ( NOT DEFINED VCPKG_BUILD_TYPE OR "${VCPKG_BUILD_TYPE}" STREQUAL "debug" )
2021-07-30 00:47:35 +08:00
message ( STATUS "${configuring_message}-dbg" )
2021-11-06 07:55:14 +08:00
file ( MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg" )
2018-02-08 08:57:47 +08:00
vcpkg_execute_required_process (
C O M M A N D $ { d b g _ c o m m a n d }
2021-11-06 07:55:14 +08:00
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 " $ { a r g _ L O G N A M E } - d b g "
2022-07-08 05:58:03 +08:00
S A V E _ L O G _ F I L E S C M a k e C a c h e . t x t
2018-02-08 08:57:47 +08:00
)
2021-11-06 07:55:14 +08:00
vcpkg_list ( APPEND config_logs
2021-07-21 01:24:58 +08:00
" $ { C U R R E N T _ B U I L D T R E E S _ D I R } / $ { a r g _ L O G N A M E } - d b g - o u t . l o g "
" $ { C U R R E N T _ B U I L D T R E E S _ D I R } / $ { a r g _ L O G N A M E } - d b g - e r r . l o g " )
2018-02-08 08:57:47 +08:00
endif ( )
2018-03-02 00:31:14 +08:00
2021-11-06 07:55:14 +08:00
if ( NOT DEFINED VCPKG_BUILD_TYPE OR "${VCPKG_BUILD_TYPE}" STREQUAL "release" )
2021-07-30 00:47:35 +08:00
message ( STATUS "${configuring_message}-rel" )
2021-11-06 07:55:14 +08:00
file ( MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel" )
2018-03-02 00:31:14 +08:00
vcpkg_execute_required_process (
C O M M A N D $ { r e l _ c o m m a n d }
2021-11-06 07:55:14 +08:00
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 " $ { a r g _ L O G N A M E } - r e l "
2022-07-08 05:58:03 +08:00
S A V E _ L O G _ F I L E S C M a k e C a c h e . t x t
2018-03-02 00:31:14 +08:00
)
2021-11-06 07:55:14 +08:00
vcpkg_list ( APPEND config_logs
2021-07-21 01:24:58 +08:00
" $ { C U R R E N T _ B U I L D T R E E S _ D I R } / $ { a r g _ L O G N A M E } - r e l - o u t . l o g "
" $ { C U R R E N T _ B U I L D T R E E S _ D I R } / $ { a r g _ L O G N A M E } - r e l - e r r . l o g " )
endif ( )
endif ( )
# Check unused variables
2021-11-06 07:55:14 +08:00
vcpkg_list ( SET all_unused_variables )
2021-07-21 01:24:58 +08:00
foreach ( config_log IN LISTS config_logs )
2021-11-06 07:55:14 +08:00
if ( NOT EXISTS "${config_log}" )
2021-07-21 01:24:58 +08:00
continue ( )
endif ( )
file ( READ "${config_log}" log_contents )
debug_message ( "Reading configure log ${config_log}..." )
2021-11-06 07:55:14 +08:00
if ( NOT "${log_contents}" MATCHES "Manually-specified variables were not used by the project:\n\n(( [^\n]*\n)*)" )
2021-07-21 01:24:58 +08:00
continue ( )
2018-03-02 00:31:14 +08:00
endif ( )
2021-07-21 01:24:58 +08:00
string ( STRIP "${CMAKE_MATCH_1}" unused_variables ) # remove leading ` ` and trailing `\n`
string ( REPLACE "\n " ";" unused_variables "${unused_variables}" )
debug_message ( "unused variables: ${unused_variables}" )
foreach ( unused_variable IN LISTS unused_variables )
2021-11-06 07:55:14 +08:00
if ( "${unused_variable}" IN_LIST manually_specified_variables )
2021-07-21 01:24:58 +08:00
debug_message ( "manually specified unused variable: ${unused_variable}" )
2021-11-06 07:55:14 +08:00
vcpkg_list ( APPEND all_unused_variables "${unused_variable}" )
2021-07-21 01:24:58 +08:00
else ( )
debug_message ( "unused variable (not manually specified): ${unused_variable}" )
endif ( )
endforeach ( )
endforeach ( )
2021-11-06 07:55:14 +08:00
if ( NOT "${all_unused_variables}" STREQUAL "" )
vcpkg_list ( REMOVE_DUPLICATES all_unused_variables )
vcpkg_list ( JOIN all_unused_variables "\n " all_unused_variables )
2021-07-21 01:24:58 +08:00
message ( WARNING " The following variables are not used in CMakeLists.txt:
$ { a l l _ u n u s e d _ v a r i a b l e s }
P l e a s e r e c h e c k t h e m a n d r e m o v e t h e u n n e c e s s a r y o p t i o n s f r o m t h e ` v c p k g _ c o n f i g u r e _ c m a k e ` c a l l .
I f t h e s e o p t i o n s s h o u l d s t i l l b e p a s s e d f o r w h a t e v e r r e a s o n , p l e a s e u s e t h e ` M A Y B E _ U N U S E D _ V A R I A B L E S ` a r g u m e n t . " )
2017-11-26 07:25:18 +08:00
endif ( )
2017-10-06 08:49:28 +08:00
2021-07-30 00:47:35 +08:00
if ( NOT arg_Z_GET_CMAKE_VARS_USAGE )
2021-11-06 07:55:14 +08:00
set ( Z_VCPKG_CMAKE_GENERATOR "${generator}" PARENT_SCOPE )
2021-07-30 00:47:35 +08:00
endif ( )
2018-03-02 00:31:14 +08:00
endfunction ( )