2017-05-29 04:07:20 +08:00
# Mark variables as used so cmake doesn't complain about them
2017-10-17 02:22:21 +08:00
mark_as_advanced ( CMAKE_TOOLCHAIN_FILE )
2021-02-19 08:27:47 +08:00
# NOTE: to figure out what cmake versions are required for different things,
# grep for `CMake 3`. All version requirement comments should follow that format.
2020-09-04 00:58:15 +08:00
2022-03-24 07:16:17 +08:00
# Attention: Changes to this file do not affect ABI hashing.
2021-02-19 08:27:47 +08:00
#[===[.md:
# z_vcpkg_add_fatal_error
A d d a f a t a l e r r o 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
2021-02-19 08:27:47 +08:00
` ` ` c m a k e
z_vcpkg_add_fatal_error ( <message>... )
` ` `
[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
2020-11-13 02:16:24 +08:00
W e u s e t h i s s y s t e m , i n s t e a d o f ` message ( FATAL_ERROR ) ` ,
s i n c e c m a k e p r i n t s a l o t o f n o n s e n s e i f t h e t o o l c h a i n e r r o r s o u t b e f o r e i t ' s f o u n d t h e b u i l d t o o l s .
2021-02-19 08:27:47 +08:00
T h i s ` Z _ V C P K G _ H A S _ F A T A L _ E R R O R ` m u s t b e c h e c k e d b e f o r e a n y f i l e s y s t e m o p e r a t i o n s a r e d o n e ,
2020-11-13 02:16:24 +08:00
s i n c e o t h e r w i s e y o u m i g h t b e d o i n g s o m e t h i n g w i t h b a d v a r i a b l e s s e t u p .
#]===]
2021-02-19 08:27:47 +08:00
# this is defined above everything else so that it can be used.
set ( Z_VCPKG_FATAL_ERROR )
set ( Z_VCPKG_HAS_FATAL_ERROR OFF )
function ( z_vcpkg_add_fatal_error ERROR )
if ( NOT Z_VCPKG_HAS_FATAL_ERROR )
set ( Z_VCPKG_HAS_FATAL_ERROR ON PARENT_SCOPE )
set ( Z_VCPKG_FATAL_ERROR "${ERROR}" PARENT_SCOPE )
2020-11-13 02:16:24 +08:00
else ( )
2021-02-19 08:27:47 +08:00
string ( APPEND Z_VCPKG_FATAL_ERROR "\n${ERROR}" )
2020-11-13 02:16:24 +08:00
endif ( )
endfunction ( )
2022-02-18 02:46:49 +08:00
set ( Z_VCPKG_CMAKE_REQUIRED_MINIMUM_VERSION "3.7.2" )
2021-02-19 08:27:47 +08:00
if ( CMAKE_VERSION VERSION_LESS Z_VCPKG_CMAKE_REQUIRED_MINIMUM_VERSION )
message ( FATAL_ERROR "vcpkg.cmake requires at least CMake ${Z_VCPKG_CMAKE_REQUIRED_MINIMUM_VERSION}." )
endif ( )
cmake_policy ( PUSH )
2024-11-19 15:42:09 +08:00
cmake_policy ( VERSION 3.16 )
2021-02-19 08:27:47 +08:00
include ( CMakeDependentOption )
# VCPKG toolchain options.
option ( VCPKG_VERBOSE "Enables messages from the VCPKG toolchain for debugging purposes." OFF )
mark_as_advanced ( VCPKG_VERBOSE )
option ( VCPKG_APPLOCAL_DEPS "Automatically copy dependencies into the output directory for executables." ON )
option ( X_VCPKG_APPLOCAL_DEPS_SERIALIZED "(experimental) Add USES_TERMINAL to VCPKG_APPLOCAL_DEPS to force serialization." OFF )
2021-07-15 03:45:18 +08:00
# requires CMake 3.14
option ( X_VCPKG_APPLOCAL_DEPS_INSTALL "(experimental) Automatically copy dependencies into the install target directory for executables. Requires CMake 3.14." OFF )
2021-06-24 06:30:46 +08:00
option ( VCPKG_PREFER_SYSTEM_LIBS "Appends the vcpkg paths to CMAKE_PREFIX_PATH, CMAKE_LIBRARY_PATH and CMAKE_FIND_ROOT_PATH so that vcpkg libraries/packages are found after toolchain/system libraries/packages." OFF )
2022-08-24 03:07:33 +08:00
if ( VCPKG_PREFER_SYSTEM_LIBS )
message ( WARNING "VCPKG_PREFER_SYSTEM_LIBS has been deprecated. Use empty overlay ports instead." )
endif ( )
2021-02-19 08:27:47 +08:00
# Manifest options and settings
2023-05-10 08:08:28 +08:00
set ( Z_VCPKG_MANIFEST_DIR_INITIAL_VALUE "${VCPKG_MANIFEST_DIR}" )
2020-08-22 17:04:16 +08:00
if ( NOT DEFINED VCPKG_MANIFEST_DIR )
if ( EXISTS "${CMAKE_SOURCE_DIR}/vcpkg.json" )
2023-05-10 08:08:28 +08:00
set ( Z_VCPKG_MANIFEST_DIR_INITIAL_VALUE "${CMAKE_SOURCE_DIR}" )
2020-08-22 17:04:16 +08:00
endif ( )
2021-02-19 08:27:47 +08:00
endif ( )
2023-05-10 08:08:28 +08:00
set ( VCPKG_MANIFEST_DIR "${Z_VCPKG_MANIFEST_DIR_INITIAL_VALUE}"
2021-02-19 08:27:47 +08:00
C A C H E P A T H " T h e p a t h t o t h e v c p k g m a n i f e s t d i r e c t o r y . " F O R C E )
if ( DEFINED VCPKG_MANIFEST_DIR AND NOT VCPKG_MANIFEST_DIR STREQUAL "" )
set ( Z_VCPKG_HAS_MANIFEST_DIR ON )
2020-08-22 17:04:16 +08:00
else ( )
2021-02-19 08:27:47 +08:00
set ( Z_VCPKG_HAS_MANIFEST_DIR OFF )
2020-08-22 17:04:16 +08:00
endif ( )
2021-02-19 08:27:47 +08:00
option ( VCPKG_MANIFEST_MODE "Use manifest mode, as opposed to classic mode." "${Z_VCPKG_HAS_MANIFEST_DIR}" )
if ( VCPKG_MANIFEST_MODE AND NOT Z_VCPKG_HAS_MANIFEST_DIR )
z_vcpkg_add_fatal_error (
" v c p k g m a n i f e s t m o d e w a s e n a b l e d , b u t w e c o u l d n ' t f i n d a m a n i f e s t file ( vcpkg.json )
i n t h e c u r r e n t s o u r c e directory ( ${ CMAKE_CURRENT_SOURCE_DIR } ) .
P l e a s e a d d a m a n i f e s t , o r d i s a b l e m a n i f e s t s b y t u r n i n g o f f V C P K G _ M A N I F E S T _ M O D E . "
)
[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
endif ( )
2021-02-19 08:27:47 +08:00
if ( NOT DEFINED CACHE{Z_VCPKG_CHECK_MANIFEST_MODE} )
set ( Z_VCPKG_CHECK_MANIFEST_MODE "${VCPKG_MANIFEST_MODE}"
2020-09-04 00:58:15 +08:00
C A C H E I N T E R N A L " M a k i n g s u r e V C P K G _ M A N I F E S T _ M O D E d o e s n ' t c h a n g e " )
endif ( )
2021-02-19 08:27:47 +08:00
if ( NOT VCPKG_MANIFEST_MODE AND Z_VCPKG_CHECK_MANIFEST_MODE )
z_vcpkg_add_fatal_error ( [[
v c p k g m a n i f e s t m o d e w a s d i s a b l e d f o r a b u i l d d i r e c t o r y w h e r e i t w a s i n i t i a l l y e n a b l e d .
T h i s i s n o t s u p p o r t e d . P l e a s e d e l e t e t h e b u i l d d i r e c t o r y a n d r e c o n f i g u r e .
] ] )
elseif ( VCPKG_MANIFEST_MODE AND NOT Z_VCPKG_CHECK_MANIFEST_MODE )
z_vcpkg_add_fatal_error ( [[
2020-09-04 00:58:15 +08:00
v c p k g m a n i f e s t m o d e w a s e n a b l e d f o r a b u i l d d i r e c t o r y w h e r e i t w a s i n i t i a l l y d i s a b l e d .
T h i s i s n o t s u p p o r t e d . P l e a s e d e l e t e t h e b u i l d d i r e c t o r y a n d r e c o n f i g u r e .
] ] )
endif ( )
CMAKE_DEPENDENT_OPTION ( VCPKG_MANIFEST_INSTALL [[
2020-07-10 03:32:31 +08:00
I n s t a l l t h e d e p e n d e n c i e s l i s t e d i n y o u r m a n i f e s t :
I f t h i s i s o f f , y o u w i l l h a v e t o m a n u a l l y i n s t a l l y o u r d e p e n d e n c i e s .
S e e h t t p s : / / g i t h u b . c o m / m i c r o s o f t / v c p k g / t r e e / m a s t e r / d o c s / s p e c i f i c a t i o n s / m a n i f e s t s . m d f o r m o r e i n f o .
] ]
2020-09-04 00:58:15 +08:00
O N
" V C P K G _ M A N I F E S T _ M O D E "
O F F )
[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
2021-02-19 08:27:47 +08:00
if ( VCPKG_MANIFEST_INSTALL )
set ( VCPKG_BOOTSTRAP_OPTIONS "${VCPKG_BOOTSTRAP_OPTIONS}" CACHE STRING "Additional options to bootstrap vcpkg" FORCE )
set ( VCPKG_OVERLAY_PORTS "${VCPKG_OVERLAY_PORTS}" CACHE STRING "Overlay ports to use for vcpkg install in manifest mode" FORCE )
set ( VCPKG_OVERLAY_TRIPLETS "${VCPKG_OVERLAY_TRIPLETS}" CACHE STRING "Overlay triplets to use for vcpkg install in manifest mode" FORCE )
set ( VCPKG_INSTALL_OPTIONS "${VCPKG_INSTALL_OPTIONS}" CACHE STRING "Additional install options to pass to vcpkg" FORCE )
set ( Z_VCPKG_UNUSED VCPKG_BOOTSTRAP_OPTIONS )
set ( Z_VCPKG_UNUSED VCPKG_OVERLAY_PORTS )
set ( Z_VCPKG_UNUSED VCPKG_OVERLAY_TRIPLETS )
set ( Z_VCPKG_UNUSED VCPKG_INSTALL_OPTIONS )
endif ( )
# CMake helper utilities
#[===[.md:
# z_vcpkg_function_arguments
G e t a l i s t o f t h e a r g u m e n t s w h i c h w e r e p a s s e d i n .
U n l i k e ` A R G V ` , w h i c h i s s i m p l y t h e a r g u m e n t s j o i n e d w i t h ` ; ` ,
s o t h a t ` ( A B ) ` i s n o t d i s t i n g u i s h a b l e f r o m ` ( " A ; B " ) ` ,
t h i s m a c r o g i v e s ` " A ; B " ` f o r t h e f i r s t a r g u m e n t l i s t ,
a n d ` " A \ ; B " ` f o r t h e s e c o n d .
` ` ` c m a k e
z_vcpkg_function_arguments ( <out-var> [<N>] )
` ` `
` z _ v c p k g _ f u n c t i o n _ a r g u m e n t s ` g e t s t h e a r g u m e n t s b e t w e e n ` A R G V < N > ` a n d t h e l a s t a r g u m e n t .
` < N > ` d e f a u l t s t o ` 0 ` , s o t h a t a l l a r g u m e n t s a r e t a k e n .
## Example:
` ` ` c m a k e
function ( foo_replacement )
z_vcpkg_function_arguments ( ARGS )
foo ( ${ ARGS } )
. . .
endfunction ( )
` ` `
#]===]
# NOTE: this function definition is copied directly from scripts/cmake/z_vcpkg_function_arguments.cmake
# do not make changes here without making the same change there.
macro ( z_vcpkg_function_arguments OUT_VAR )
2022-11-23 00:51:34 +08:00
if ( "${ARGC}" EQUAL "1" )
set ( z_vcpkg_function_arguments_FIRST_ARG "0" )
elseif ( "${ARGC}" EQUAL "2" )
2021-02-19 08:27:47 +08:00
set ( z_vcpkg_function_arguments_FIRST_ARG "${ARGV1}" )
else ( )
# vcpkg bug
message ( FATAL_ERROR "z_vcpkg_function_arguments: invalid arguments (${ARGV})" )
endif ( )
2021-07-21 01:24:58 +08:00
set ( "${OUT_VAR}" "" )
2021-02-19 08:27:47 +08:00
# this allows us to get the value of the enclosing function's ARGC
set ( z_vcpkg_function_arguments_ARGC_NAME "ARGC" )
set ( z_vcpkg_function_arguments_ARGC "${${z_vcpkg_function_arguments_ARGC_NAME}}" )
math ( EXPR z_vcpkg_function_arguments_LAST_ARG "${z_vcpkg_function_arguments_ARGC} - 1" )
2023-02-22 02:58:03 +08:00
if ( z_vcpkg_function_arguments_LAST_ARG GREATER_EQUAL z_vcpkg_function_arguments_FIRST_ARG )
2021-02-19 08:27:47 +08:00
foreach ( z_vcpkg_function_arguments_N RANGE "${z_vcpkg_function_arguments_FIRST_ARG}" "${z_vcpkg_function_arguments_LAST_ARG}" )
string ( REPLACE ";" "\\;" z_vcpkg_function_arguments_ESCAPED_ARG "${ARGV${z_vcpkg_function_arguments_N}}" )
2021-07-21 01:24:58 +08:00
# adds an extra `;` on the first time through
set ( "${OUT_VAR}" "${${OUT_VAR}};${z_vcpkg_function_arguments_ESCAPED_ARG}" )
2021-02-19 08:27:47 +08:00
endforeach ( )
2021-07-21 01:24:58 +08:00
# remove leading `;`
2022-11-23 00:51:34 +08:00
string ( SUBSTRING "${${OUT_VAR}}" "1" "-1" "${OUT_VAR}" )
2021-02-19 08:27:47 +08:00
endif ( )
endmacro ( )
#[===[.md:
# z_vcpkg_set_powershell_path
G e t s e i t h e r t h e p a t h t o p o w e r s h e l l o r p o w e r s h e l l c o r e ,
a n d p l a c e s i t i n t h e v a r i a b l e Z _ V C P K G _ P O W E R S H E L L _ P A T H .
#]===]
function ( z_vcpkg_set_powershell_path )
# Attempt to use pwsh if it is present; otherwise use powershell
if ( NOT DEFINED Z_VCPKG_POWERSHELL_PATH )
find_program ( Z_VCPKG_PWSH_PATH pwsh )
if ( Z_VCPKG_PWSH_PATH )
set ( Z_VCPKG_POWERSHELL_PATH "${Z_VCPKG_PWSH_PATH}" CACHE INTERNAL "The path to the PowerShell implementation to use." )
else ( )
message ( DEBUG "vcpkg: Could not find PowerShell Core; falling back to PowerShell" )
2024-03-08 14:40:36 +08:00
find_program ( Z_VCPKG_BUILTIN_POWERSHELL_PATH powershell )
2021-02-19 08:27:47 +08:00
if ( Z_VCPKG_BUILTIN_POWERSHELL_PATH )
set ( Z_VCPKG_POWERSHELL_PATH "${Z_VCPKG_BUILTIN_POWERSHELL_PATH}" CACHE INTERNAL "The path to the PowerShell implementation to use." )
else ( )
message ( WARNING "vcpkg: Could not find PowerShell; using static string 'powershell.exe'" )
set ( Z_VCPKG_POWERSHELL_PATH "powershell.exe" CACHE INTERNAL "The path to the PowerShell implementation to use." )
endif ( )
endif ( )
endif ( ) # Z_VCPKG_POWERSHELL_PATH
endfunction ( )
2019-09-24 04:43:52 +08:00
# Determine whether the toolchain is loaded during a try-compile configuration
2021-02-19 08:27:47 +08:00
get_property ( Z_VCPKG_CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE )
2019-09-24 04:43:52 +08:00
2017-10-17 02:22:21 +08:00
if ( VCPKG_CHAINLOAD_TOOLCHAIN_FILE )
include ( "${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}" )
endif ( )
if ( VCPKG_TOOLCHAIN )
2021-02-19 08:27:47 +08:00
cmake_policy ( POP )
2017-10-17 02:22:21 +08:00
return ( )
endif ( )
2020-03-26 04:47:07 +08:00
#If CMake does not have a mapping for MinSizeRel and RelWithDebInfo in imported targets
#it will map those configuration to the first valid configuration in CMAKE_CONFIGURATION_TYPES or the targets IMPORTED_CONFIGURATIONS.
2020-06-04 10:31:28 +08:00
#In most cases this is the debug configuration which is wrong.
2020-03-26 04:47:07 +08:00
if ( NOT DEFINED CMAKE_MAP_IMPORTED_CONFIG_MINSIZEREL )
2024-01-09 06:10:55 +08:00
set ( CMAKE_MAP_IMPORTED_CONFIG_MINSIZEREL "MinSizeRel;Release;None;" )
2020-03-26 04:47:07 +08:00
if ( VCPKG_VERBOSE )
2024-01-09 06:10:55 +08:00
message ( STATUS "VCPKG-Info: CMAKE_MAP_IMPORTED_CONFIG_MINSIZEREL set to MinSizeRel;Release;None;" )
2020-01-10 07:26:27 +08:00
endif ( )
2020-03-26 04:47:07 +08:00
endif ( )
if ( NOT DEFINED CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO )
2024-01-09 06:10:55 +08:00
set ( CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO "RelWithDebInfo;Release;None;" )
2020-03-26 04:47:07 +08:00
if ( VCPKG_VERBOSE )
2024-01-09 06:10:55 +08:00
message ( STATUS "VCPKG-Info: CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO set to RelWithDebInfo;Release;None;" )
2020-01-10 07:26:27 +08:00
endif ( )
endif ( )
2017-10-17 02:22:21 +08:00
if ( VCPKG_TARGET_TRIPLET )
2020-10-13 06:09:20 +08:00
# This is required since a user might do: 'set(VCPKG_TARGET_TRIPLET somevalue)' [no CACHE] before the first project() call
# Latter within the toolchain file we do: 'set(VCPKG_TARGET_TRIPLET somevalue CACHE STRING "")' which
2020-11-02 09:12:49 +08:00
# will otherwise override the user setting of VCPKG_TARGET_TRIPLET in the current scope of the toolchain since the CACHE value
# did not exist previously. Since the value is newly created CMake will use the CACHE value within this scope since it is the more
2020-10-13 06:09:20 +08:00
# recently created value in directory scope. This 'strange' behaviour only happens on the very first configure call since subsequent
# configure call will see the user value as the more recent value. The same logic must be applied to all cache values within this file!
2020-11-02 09:12:49 +08:00
# The FORCE keyword is required to ALWAYS lift the user provided/previously set value into a CACHE value.
2021-02-19 08:27:47 +08:00
set ( VCPKG_TARGET_TRIPLET "${VCPKG_TARGET_TRIPLET}" CACHE STRING "Vcpkg target triplet (ex. x86-windows)" FORCE )
2017-10-17 02:22:21 +08:00
elseif ( CMAKE_GENERATOR_PLATFORM MATCHES "^[Ww][Ii][Nn]32$" )
2021-02-19 08:27:47 +08:00
set ( Z_VCPKG_TARGET_TRIPLET_ARCH x86 )
2017-10-17 02:22:21 +08:00
elseif ( CMAKE_GENERATOR_PLATFORM MATCHES "^[Xx]64$" )
2021-02-19 08:27:47 +08:00
set ( Z_VCPKG_TARGET_TRIPLET_ARCH x64 )
2017-10-17 02:22:21 +08:00
elseif ( CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]$" )
2021-02-19 08:27:47 +08:00
set ( Z_VCPKG_TARGET_TRIPLET_ARCH arm )
2018-01-04 07:19:52 +08:00
elseif ( CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]64$" )
2021-02-19 08:27:47 +08:00
set ( Z_VCPKG_TARGET_TRIPLET_ARCH arm64 )
2017-10-17 02:22:21 +08:00
else ( )
2022-05-25 03:11:39 +08:00
if ( CMAKE_GENERATOR STREQUAL "Visual Studio 14 2015 Win64" )
2021-02-19 08:27:47 +08:00
set ( Z_VCPKG_TARGET_TRIPLET_ARCH x64 )
2022-05-25 03:11:39 +08:00
elseif ( CMAKE_GENERATOR STREQUAL "Visual Studio 14 2015 ARM" )
2021-02-19 08:27:47 +08:00
set ( Z_VCPKG_TARGET_TRIPLET_ARCH arm )
2022-05-25 03:11:39 +08:00
elseif ( CMAKE_GENERATOR STREQUAL "Visual Studio 14 2015" )
2021-02-19 08:27:47 +08:00
set ( Z_VCPKG_TARGET_TRIPLET_ARCH x86 )
2022-05-25 03:11:39 +08:00
elseif ( CMAKE_GENERATOR STREQUAL "Visual Studio 15 2017 Win64" )
2021-02-19 08:27:47 +08:00
set ( Z_VCPKG_TARGET_TRIPLET_ARCH x64 )
2022-05-25 03:11:39 +08:00
elseif ( CMAKE_GENERATOR STREQUAL "Visual Studio 15 2017 ARM" )
2021-02-19 08:27:47 +08:00
set ( Z_VCPKG_TARGET_TRIPLET_ARCH arm )
2022-05-25 03:11:39 +08:00
elseif ( CMAKE_GENERATOR STREQUAL "Visual Studio 15 2017" )
2021-02-19 08:27:47 +08:00
set ( Z_VCPKG_TARGET_TRIPLET_ARCH x86 )
2022-09-28 06:49:44 +08:00
elseif ( CMAKE_GENERATOR STREQUAL "Visual Studio 16 2019" AND CMAKE_VS_PLATFORM_NAME_DEFAULT STREQUAL "ARM64" )
set ( Z_VCPKG_TARGET_TRIPLET_ARCH arm64 )
2022-05-25 03:11:39 +08:00
elseif ( CMAKE_GENERATOR STREQUAL "Visual Studio 16 2019" )
2021-02-19 08:27:47 +08:00
set ( Z_VCPKG_TARGET_TRIPLET_ARCH x64 )
2022-09-28 06:49:44 +08:00
elseif ( CMAKE_GENERATOR STREQUAL "Visual Studio 17 2022" AND CMAKE_VS_PLATFORM_NAME_DEFAULT STREQUAL "ARM64" )
set ( Z_VCPKG_TARGET_TRIPLET_ARCH arm64 )
2022-05-25 03:11:39 +08:00
elseif ( CMAKE_GENERATOR STREQUAL "Visual Studio 17 2022" )
2021-09-14 11:10:12 +08:00
set ( Z_VCPKG_TARGET_TRIPLET_ARCH x64 )
2023-10-07 07:47:54 +08:00
elseif ( CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin" AND DEFINED CMAKE_OSX_ARCHITECTURES )
list ( LENGTH CMAKE_OSX_ARCHITECTURES Z_VCPKG_OSX_ARCH_COUNT )
if ( Z_VCPKG_OSX_ARCH_COUNT EQUAL "0" )
message ( WARNING "Unable to determine target architecture. "
" C o n s i d e r p r o v i d i n g a v a l u e f o r t h e C M A K E _ O S X _ A R C H I T E C T U R E S c a c h e v a r i a b l e . "
" C o n t i n u i n g w i t h o u t v c p k g . " )
set ( VCPKG_TOOLCHAIN ON )
cmake_policy ( POP )
return ( )
endif ( )
if ( Z_VCPKG_OSX_ARCH_COUNT GREATER "1" )
message ( WARNING "Detected more than one target architecture. Using the first one." )
endif ( )
list ( GET CMAKE_OSX_ARCHITECTURES "0" Z_VCPKG_OSX_TARGET_ARCH )
if ( Z_VCPKG_OSX_TARGET_ARCH STREQUAL "arm64" )
set ( Z_VCPKG_TARGET_TRIPLET_ARCH arm64 )
elseif ( Z_VCPKG_OSX_TARGET_ARCH STREQUAL "arm64s" )
set ( Z_VCPKG_TARGET_TRIPLET_ARCH arm64s )
elseif ( Z_VCPKG_OSX_TARGET_ARCH STREQUAL "armv7s" )
set ( Z_VCPKG_TARGET_TRIPLET_ARCH armv7s )
elseif ( Z_VCPKG_OSX_TARGET_ARCH STREQUAL "armv7" )
set ( Z_VCPKG_TARGET_TRIPLET_ARCH arm )
elseif ( Z_VCPKG_OSX_TARGET_ARCH STREQUAL "x86_64" )
set ( Z_VCPKG_TARGET_TRIPLET_ARCH x64 )
elseif ( Z_VCPKG_OSX_TARGET_ARCH STREQUAL "i386" )
set ( Z_VCPKG_TARGET_TRIPLET_ARCH x86 )
else ( )
message ( WARNING "Unable to determine target architecture, continuing without vcpkg." )
set ( VCPKG_TOOLCHAIN ON )
cmake_policy ( POP )
return ( )
endif ( )
2016-09-19 11:50:08 +08:00
else ( )
2021-02-19 08:27:47 +08:00
find_program ( Z_VCPKG_CL cl )
if ( Z_VCPKG_CL MATCHES "amd64/cl.exe$" OR Z_VCPKG_CL MATCHES "x64/cl.exe$" )
set ( Z_VCPKG_TARGET_TRIPLET_ARCH x64 )
elseif ( Z_VCPKG_CL MATCHES "arm/cl.exe$" )
set ( Z_VCPKG_TARGET_TRIPLET_ARCH arm )
elseif ( Z_VCPKG_CL MATCHES "arm64/cl.exe$" )
set ( Z_VCPKG_TARGET_TRIPLET_ARCH arm64 )
elseif ( Z_VCPKG_CL MATCHES "bin/cl.exe$" OR Z_VCPKG_CL MATCHES "x86/cl.exe$" )
set ( Z_VCPKG_TARGET_TRIPLET_ARCH x86 )
2021-08-12 10:25:56 +08:00
elseif ( CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64" OR
C M A K E _ H O S T _ S Y S T E M _ P R O C E S S O R S T R E Q U A L " A M D 6 4 " O R
C M A K E _ H O S T _ S Y S T E M _ P R O C E S S O R S T R E Q U A L " a m d 6 4 " )
2021-02-19 08:27:47 +08:00
set ( Z_VCPKG_TARGET_TRIPLET_ARCH x64 )
2020-07-24 05:16:01 +08:00
elseif ( CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "s390x" )
2021-02-19 08:27:47 +08:00
set ( Z_VCPKG_TARGET_TRIPLET_ARCH s390x )
2021-01-23 02:37:26 +08:00
elseif ( CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "ppc64le" )
2021-02-19 08:27:47 +08:00
set ( Z_VCPKG_TARGET_TRIPLET_ARCH ppc64le )
2020-09-06 01:45:48 +08:00
elseif ( CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "armv7l" )
2021-02-19 08:27:47 +08:00
set ( Z_VCPKG_TARGET_TRIPLET_ARCH arm )
2022-11-18 14:48:47 +08:00
elseif ( CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64|ARM64)$" )
2021-02-19 08:27:47 +08:00
set ( Z_VCPKG_TARGET_TRIPLET_ARCH arm64 )
2023-02-23 04:44:40 +08:00
elseif ( CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "riscv32" )
set ( Z_VCPKG_TARGET_TRIPLET_ARCH riscv32 )
elseif ( CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "riscv64" )
set ( Z_VCPKG_TARGET_TRIPLET_ARCH riscv64 )
2023-08-24 02:53:24 +08:00
elseif ( CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "loongarch32" )
set ( Z_VCPKG_TARGET_TRIPLET_ARCH loongarch32 )
elseif ( CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "loongarch64" )
set ( Z_VCPKG_TARGET_TRIPLET_ARCH loongarch64 )
2016-09-19 11:50:08 +08:00
else ( )
2021-02-19 08:27:47 +08:00
if ( Z_VCPKG_CMAKE_IN_TRY_COMPILE )
2019-02-07 05:08:57 +08:00
message ( STATUS "Unable to determine target architecture, continuing without vcpkg." )
else ( )
message ( WARNING "Unable to determine target architecture, continuing without vcpkg." )
endif ( )
set ( VCPKG_TOOLCHAIN ON )
2021-02-19 08:27:47 +08:00
cmake_policy ( POP )
2019-02-07 05:08:57 +08:00
return ( )
2016-09-19 11:50:08 +08:00
endif ( )
endif ( )
2017-10-17 02:22:21 +08:00
endif ( )
2016-09-19 11:50:08 +08:00
2017-10-17 02:22:21 +08:00
if ( CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" OR CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" )
2021-02-19 08:27:47 +08:00
set ( Z_VCPKG_TARGET_TRIPLET_PLAT uwp )
2018-03-13 20:56:02 +08:00
elseif ( CMAKE_SYSTEM_NAME STREQUAL "Linux" OR ( NOT CMAKE_SYSTEM_NAME AND CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" ) )
2021-02-19 08:27:47 +08:00
set ( Z_VCPKG_TARGET_TRIPLET_PLAT linux )
2018-03-13 20:56:02 +08:00
elseif ( CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR ( NOT CMAKE_SYSTEM_NAME AND CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin" ) )
2021-02-19 08:27:47 +08:00
set ( Z_VCPKG_TARGET_TRIPLET_PLAT osx )
Add initial iOS support (#6275)
* Add iOS community triplets and toolchain support
Added an iOS toolchain to enable building packages for iOS.
The toolchain is used when a triplet's VCPKG_CMAKE_SYSTEM_NAME is set
to iOS.
To configure which architecture should be built, as well as other
iOS specifics, the following triplet variables can be set:
- VCPKG_TARGET_ARCHITECTURE
- VCPKG_OSX_SYSROOT
- VCPKG_OSX_DEPLOYMENT_TARGET
- VCPKG_OSX_ARCHITECTURES
The following VCPKG_TARGET_ARCHITECTURE values are currently
supported:
- arm, arm64, x64, x86.
The following VCPKG_OSX_SYSROOT values are currently supported:
- iphoneos, iphonesimulator, or an absolute path to the device or
simulator Xcode SDK.
VCPKG_OSX_DEPLOYMENT_TARGET can be set to control the minimum iOS
delopyment target for the built libraries.
CMAKE_OSX_ARCHITECTURES is derived from VCPKG_TARGET_ARCHITECTURE,
so generally it should not be set. In case if someone needs to target
a more specific architecture (like armv7k or arm64e), it can
be set in the triplet via VCPKG_OSX_ARCHITECTURES.
Note that only certain combinations of the architecture and sysroot
will work: simulator SDKs only provide x86-based libraries, etc.
The toolchain also sets CMAKE_SYSTEM_PROCESSOR for certain
configurations, because certain packages (like libpng) depend on the
processor type.
Added 4 community iOS triplets that build static libraries:
- arm-ios, arm64-ios, x86-ios, x64-ios.
The non-arm triplets target the iOS simulator.
The triplets build static libraries because they are easiest to
integrate into an iOS project. Dynamic libraries or frameworks require
code signing on iOS, which complicates integration.
Added heuristics to try and automatically detect what iOS triplet to
use when building your own CMake project (so when a CMake project sets
CMAKE_TOOLCHAIN_FILE to buildsystems/vcpkg.cmake), if no explicit
triplet is provided (VCPKG_TARGET_TRIPLET is undefined).
The heuristic checks for the values of CMAKE_SYSTEM_NAME and
CMAKE_OSX_ARCHITECTURES. Note that for this to work,
CMAKE_OSX_ARCHITECTURES needs to be set before the first project()
call in your CMake project.
Added workaround so find_package finds vcpkg installed packages
when targeting iOS.
This is done by saving / restoring the value of CMAKE_FIND_ROOT_PATH
while also adding the vcpkg package root in the find_package override
macro.
The workaround can be removed once vcpkg upgrades to CMake 3.15.0
or higher where the issue is fixed.
Fixes: #6003
* Fix building libpng and pcre2 targetting iOS
Fixes: #6003
2020-04-16 04:06:55 +08:00
elseif ( CMAKE_SYSTEM_NAME STREQUAL "iOS" )
2021-02-19 08:27:47 +08:00
set ( Z_VCPKG_TARGET_TRIPLET_PLAT ios )
2021-10-13 02:30:40 +08:00
elseif ( MINGW )
set ( Z_VCPKG_TARGET_TRIPLET_PLAT mingw-dynamic )
2018-03-13 20:56:02 +08:00
elseif ( CMAKE_SYSTEM_NAME STREQUAL "Windows" OR ( NOT CMAKE_SYSTEM_NAME AND CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows" ) )
2023-03-09 06:06:20 +08:00
if ( XBOX_CONSOLE_TARGET STREQUAL "scarlett" )
set ( Z_VCPKG_TARGET_TRIPLET_PLAT xbox-scarlett )
elseif ( XBOX_CONSOLE_TARGET STREQUAL "xboxone" )
set ( Z_VCPKG_TARGET_TRIPLET_PLAT xbox-xboxone )
else ( )
set ( Z_VCPKG_TARGET_TRIPLET_PLAT windows )
endif ( )
2018-03-13 20:56:02 +08:00
elseif ( CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR ( NOT CMAKE_SYSTEM_NAME AND CMAKE_HOST_SYSTEM_NAME STREQUAL "FreeBSD" ) )
2021-02-19 08:27:47 +08:00
set ( Z_VCPKG_TARGET_TRIPLET_PLAT freebsd )
2024-07-30 14:05:23 +08:00
elseif ( CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" OR ( NOT CMAKE_SYSTEM_NAME AND CMAKE_HOST_SYSTEM_NAME STREQUAL "OpenBSD" ) )
set ( Z_VCPKG_TARGET_TRIPLET_PLAT openbsd )
2023-06-27 13:14:44 +08:00
elseif ( CMAKE_SYSTEM_NAME STREQUAL "Android" OR ( NOT CMAKE_SYSTEM_NAME AND CMAKE_HOST_SYSTEM_NAME STREQUAL "Android" ) )
set ( Z_VCPKG_TARGET_TRIPLET_PLAT android )
2017-10-17 02:22:21 +08:00
endif ( )
2016-09-19 11:50:08 +08:00
2022-05-05 10:37:37 +08:00
if ( EMSCRIPTEN )
set ( Z_VCPKG_TARGET_TRIPLET_ARCH wasm32 )
set ( Z_VCPKG_TARGET_TRIPLET_PLAT emscripten )
endif ( )
2021-02-19 08:27:47 +08:00
set ( VCPKG_TARGET_TRIPLET "${Z_VCPKG_TARGET_TRIPLET_ARCH}-${Z_VCPKG_TARGET_TRIPLET_PLAT}" CACHE STRING "Vcpkg target triplet (ex. x86-windows)" )
set ( Z_VCPKG_TOOLCHAIN_DIR "${CMAKE_CURRENT_LIST_DIR}" )
2017-04-21 07:19:39 +08:00
2022-02-01 03:18:22 +08:00
# Detect .vcpkg-root to figure VCPKG_ROOT_DIR
set ( Z_VCPKG_ROOT_DIR_CANDIDATE "${CMAKE_CURRENT_LIST_DIR}" )
while ( NOT DEFINED Z_VCPKG_ROOT_DIR )
if ( EXISTS "${Z_VCPKG_ROOT_DIR_CANDIDATE}/.vcpkg-root" )
set ( Z_VCPKG_ROOT_DIR "${Z_VCPKG_ROOT_DIR_CANDIDATE}" CACHE INTERNAL "Vcpkg root directory" )
elseif ( IS_DIRECTORY "${Z_VCPKG_ROOT_DIR_CANDIDATE}" )
2021-02-19 08:27:47 +08:00
get_filename_component ( Z_VCPKG_ROOT_DIR_TEMP "${Z_VCPKG_ROOT_DIR_CANDIDATE}" DIRECTORY )
2022-02-01 03:18:22 +08:00
if ( Z_VCPKG_ROOT_DIR_TEMP STREQUAL Z_VCPKG_ROOT_DIR_CANDIDATE )
break ( ) # If unchanged, we have reached the root of the drive without finding vcpkg.
2017-12-09 14:03:03 +08:00
endif ( )
2022-02-01 03:18:22 +08:00
SET ( Z_VCPKG_ROOT_DIR_CANDIDATE "${Z_VCPKG_ROOT_DIR_TEMP}" )
unset ( Z_VCPKG_ROOT_DIR_TEMP )
else ( )
break ( )
endif ( )
endwhile ( )
unset ( Z_VCPKG_ROOT_DIR_CANDIDATE )
[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
2021-02-19 08:27:47 +08:00
if ( NOT Z_VCPKG_ROOT_DIR )
z_vcpkg_add_fatal_error ( "Could not find .vcpkg-root" )
2020-06-04 10:31:28 +08:00
endif ( )
2017-10-17 02:22:21 +08:00
2021-06-11 02:11:20 +08:00
if ( DEFINED VCPKG_INSTALLED_DIR )
2023-05-10 08:08:28 +08:00
set ( Z_VCPKG_INSTALLED_DIR_INITIAL_VALUE "${VCPKG_INSTALLED_DIR}" )
2021-06-11 02:11:20 +08:00
elseif ( DEFINED _VCPKG_INSTALLED_DIR )
2023-05-10 08:08:28 +08:00
set ( Z_VCPKG_INSTALLED_DIR_INITIAL_VALUE "${_VCPKG_INSTALLED_DIR}" )
2021-06-11 02:11:20 +08:00
elseif ( VCPKG_MANIFEST_MODE )
2023-05-10 08:08:28 +08:00
set ( Z_VCPKG_INSTALLED_DIR_INITIAL_VALUE "${CMAKE_BINARY_DIR}/vcpkg_installed" )
2021-06-11 02:11:20 +08:00
else ( )
2023-05-10 08:08:28 +08:00
set ( Z_VCPKG_INSTALLED_DIR_INITIAL_VALUE "${Z_VCPKG_ROOT_DIR}/installed" )
2021-06-11 02:11:20 +08:00
endif ( )
2023-05-10 08:08:28 +08:00
set ( VCPKG_INSTALLED_DIR "${Z_VCPKG_INSTALLED_DIR_INITIAL_VALUE}"
2021-06-11 02:11:20 +08:00
C A C H E P A T H
" T h e d i r e c t o r y w h i c h c o n t a i n s t h e i n s t a l l e d l i b r a r i e s f o r e a c h t r i p l e t " F O R C E )
set ( _VCPKG_INSTALLED_DIR "${VCPKG_INSTALLED_DIR}"
2021-02-19 08:27:47 +08:00
C A C H E P A T H
" T h e d i r e c t o r y w h i c h c o n t a i n s t h e i n s t a l l e d l i b r a r i e s f o r e a c h t r i p l e t " F O R C E )
2018-02-24 08:50:32 +08:00
2021-07-30 00:47:35 +08:00
function ( z_vcpkg_add_vcpkg_to_cmake_path list suffix )
set ( vcpkg_paths
" $ { _ V C P K G _ I N S T A L L E D _ D I R } / $ { V C P K G _ T A R G E T _ T R I P L E T } $ { s u f f i x } "
" $ { _ V C P K G _ I N S T A L L E D _ D I R } / $ { V C P K G _ T A R G E T _ T R I P L E T } / d e b u g $ { s u f f i x } "
2019-03-15 05:24:29 +08:00
)
2021-07-30 00:47:35 +08:00
if ( NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE MATCHES "^[Dd][Ee][Bb][Uu][Gg]$" )
list ( REVERSE vcpkg_paths ) # Debug build: Put Debug paths before Release paths.
endif ( )
if ( VCPKG_PREFER_SYSTEM_LIBS )
list ( APPEND "${list}" "${vcpkg_paths}" )
else ( )
2022-11-23 00:51:34 +08:00
list ( INSERT "${list}" "0" "${vcpkg_paths}" ) # CMake 3.15 is required for list(PREPEND ...).
2021-07-30 00:47:35 +08:00
endif ( )
set ( "${list}" "${${list}}" PARENT_SCOPE )
endfunction ( )
z_vcpkg_add_vcpkg_to_cmake_path ( CMAKE_PREFIX_PATH "" )
z_vcpkg_add_vcpkg_to_cmake_path ( CMAKE_LIBRARY_PATH "/lib/manual-link" )
z_vcpkg_add_vcpkg_to_cmake_path ( CMAKE_FIND_ROOT_PATH "" )
2016-09-19 11:50:08 +08:00
2022-03-16 04:21:32 +08:00
if ( NOT VCPKG_PREFER_SYSTEM_LIBS )
set ( CMAKE_FIND_FRAMEWORK "LAST" ) # we assume that frameworks are usually system-wide libs, not vcpkg-built
set ( CMAKE_FIND_APPBUNDLE "LAST" ) # we assume that appbundles are usually system-wide libs, not vcpkg-built
endif ( )
2020-07-10 03:32:31 +08:00
# If one CMAKE_FIND_ROOT_PATH_MODE_* variables is set to ONLY, to make sure that ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}
2020-07-08 06:01:01 +08:00
# and ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug are searched, it is not sufficient to just add them to CMAKE_FIND_ROOT_PATH,
2020-07-10 03:32:31 +08:00
# as CMAKE_FIND_ROOT_PATH specify "one or more directories to be prepended to all other search directories", so to make sure that
2020-07-08 06:01:01 +08:00
# the libraries are searched as they are, it is necessary to add "/" to the CMAKE_PREFIX_PATH
2020-07-10 03:32:31 +08:00
if ( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE STREQUAL "ONLY" OR
2020-07-08 06:01:01 +08:00
C M A K E _ F I N D _ R O O T _ P A T H _ M O D E _ L I B R A R Y S T R E Q U A L " O N L Y " O R
C M A K E _ F I N D _ R O O T _ P A T H _ M O D E _ P A C K A G E S T R E Q U A L " O N L Y " )
list ( APPEND CMAKE_PREFIX_PATH "/" )
endif ( )
2021-02-19 08:27:47 +08:00
set ( VCPKG_CMAKE_FIND_ROOT_PATH "${CMAKE_FIND_ROOT_PATH}" )
Add initial iOS support (#6275)
* Add iOS community triplets and toolchain support
Added an iOS toolchain to enable building packages for iOS.
The toolchain is used when a triplet's VCPKG_CMAKE_SYSTEM_NAME is set
to iOS.
To configure which architecture should be built, as well as other
iOS specifics, the following triplet variables can be set:
- VCPKG_TARGET_ARCHITECTURE
- VCPKG_OSX_SYSROOT
- VCPKG_OSX_DEPLOYMENT_TARGET
- VCPKG_OSX_ARCHITECTURES
The following VCPKG_TARGET_ARCHITECTURE values are currently
supported:
- arm, arm64, x64, x86.
The following VCPKG_OSX_SYSROOT values are currently supported:
- iphoneos, iphonesimulator, or an absolute path to the device or
simulator Xcode SDK.
VCPKG_OSX_DEPLOYMENT_TARGET can be set to control the minimum iOS
delopyment target for the built libraries.
CMAKE_OSX_ARCHITECTURES is derived from VCPKG_TARGET_ARCHITECTURE,
so generally it should not be set. In case if someone needs to target
a more specific architecture (like armv7k or arm64e), it can
be set in the triplet via VCPKG_OSX_ARCHITECTURES.
Note that only certain combinations of the architecture and sysroot
will work: simulator SDKs only provide x86-based libraries, etc.
The toolchain also sets CMAKE_SYSTEM_PROCESSOR for certain
configurations, because certain packages (like libpng) depend on the
processor type.
Added 4 community iOS triplets that build static libraries:
- arm-ios, arm64-ios, x86-ios, x64-ios.
The non-arm triplets target the iOS simulator.
The triplets build static libraries because they are easiest to
integrate into an iOS project. Dynamic libraries or frameworks require
code signing on iOS, which complicates integration.
Added heuristics to try and automatically detect what iOS triplet to
use when building your own CMake project (so when a CMake project sets
CMAKE_TOOLCHAIN_FILE to buildsystems/vcpkg.cmake), if no explicit
triplet is provided (VCPKG_TARGET_TRIPLET is undefined).
The heuristic checks for the values of CMAKE_SYSTEM_NAME and
CMAKE_OSX_ARCHITECTURES. Note that for this to work,
CMAKE_OSX_ARCHITECTURES needs to be set before the first project()
call in your CMake project.
Added workaround so find_package finds vcpkg installed packages
when targeting iOS.
This is done by saving / restoring the value of CMAKE_FIND_ROOT_PATH
while also adding the vcpkg package root in the find_package override
macro.
The workaround can be removed once vcpkg upgrades to CMake 3.15.0
or higher where the issue is fixed.
Fixes: #6003
* Fix building libpng and pcre2 targetting iOS
Fixes: #6003
2020-04-16 04:06:55 +08:00
[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
# CMAKE_EXECUTABLE_SUFFIX is not yet defined
2021-02-19 08:27:47 +08:00
if ( CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows" )
set ( Z_VCPKG_EXECUTABLE "${Z_VCPKG_ROOT_DIR}/vcpkg.exe" )
set ( Z_VCPKG_BOOTSTRAP_SCRIPT "${Z_VCPKG_ROOT_DIR}/bootstrap-vcpkg.bat" )
[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
else ( )
2021-02-19 08:27:47 +08:00
set ( Z_VCPKG_EXECUTABLE "${Z_VCPKG_ROOT_DIR}/vcpkg" )
set ( Z_VCPKG_BOOTSTRAP_SCRIPT "${Z_VCPKG_ROOT_DIR}/bootstrap-vcpkg.sh" )
[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
endif ( )
2021-02-19 08:27:47 +08:00
if ( VCPKG_MANIFEST_MODE AND VCPKG_MANIFEST_INSTALL AND NOT Z_VCPKG_CMAKE_IN_TRY_COMPILE AND NOT Z_VCPKG_HAS_FATAL_ERROR )
if ( NOT EXISTS "${Z_VCPKG_EXECUTABLE}" AND NOT Z_VCPKG_HAS_FATAL_ERROR )
2020-07-10 03:32:31 +08:00
message ( STATUS "Bootstrapping vcpkg before install" )
2022-08-13 06:21:20 +08:00
set ( Z_VCPKG_BOOTSTRAP_LOG "${CMAKE_BINARY_DIR}/vcpkg-bootstrap.log" )
file ( TO_NATIVE_PATH "${Z_VCPKG_BOOTSTRAP_LOG}" Z_NATIVE_VCPKG_BOOTSTRAP_LOG )
2020-07-10 03:32:31 +08:00
execute_process (
2021-02-19 08:27:47 +08:00
C O M M A N D " $ { Z _ V C P K G _ B O O T S T R A P _ S C R I P T } " $ { V C P K G _ B O O T S T R A P _ O P T I O N S }
O U T P U T _ F I L E " $ { Z _ V C P K G _ B O O T S T R A P _ L O G } "
E R R O R _ F I L E " $ { Z _ V C P K G _ B O O T S T R A P _ L O G } "
R E S U L T _ V A R I A B L E Z _ V C P K G _ B O O T S T R A P _ R E S U L T )
2020-07-10 03:32:31 +08:00
2022-11-23 00:51:34 +08:00
if ( Z_VCPKG_BOOTSTRAP_RESULT EQUAL "0" )
2020-11-13 02:16:24 +08:00
message ( STATUS "Bootstrapping vcpkg before install - done" )
else ( )
message ( STATUS "Bootstrapping vcpkg before install - failed" )
2022-08-13 06:21:20 +08:00
z_vcpkg_add_fatal_error ( "vcpkg install failed. See logs for more information: ${Z_NATIVE_VCPKG_BOOTSTRAP_LOG}" )
2020-07-10 03:32:31 +08:00
endif ( )
endif ( )
2021-02-19 08:27:47 +08:00
if ( NOT Z_VCPKG_HAS_FATAL_ERROR )
2020-11-13 02:16:24 +08:00
message ( STATUS "Running vcpkg install" )
2021-02-19 08:27:47 +08:00
set ( Z_VCPKG_ADDITIONAL_MANIFEST_PARAMS )
2021-03-11 07:33:16 +08:00
if ( DEFINED VCPKG_HOST_TRIPLET AND NOT VCPKG_HOST_TRIPLET STREQUAL "" )
list ( APPEND Z_VCPKG_ADDITIONAL_MANIFEST_PARAMS "--host-triplet=${VCPKG_HOST_TRIPLET}" )
endif ( )
2020-11-13 02:16:24 +08:00
if ( VCPKG_OVERLAY_PORTS )
2021-02-19 08:27:47 +08:00
foreach ( Z_VCPKG_OVERLAY_PORT IN LISTS VCPKG_OVERLAY_PORTS )
list ( APPEND Z_VCPKG_ADDITIONAL_MANIFEST_PARAMS "--overlay-ports=${Z_VCPKG_OVERLAY_PORT}" )
2020-11-13 02:16:24 +08:00
endforeach ( )
endif ( )
if ( VCPKG_OVERLAY_TRIPLETS )
2021-02-19 08:27:47 +08:00
foreach ( Z_VCPKG_OVERLAY_TRIPLET IN LISTS VCPKG_OVERLAY_TRIPLETS )
list ( APPEND Z_VCPKG_ADDITIONAL_MANIFEST_PARAMS "--overlay-triplets=${Z_VCPKG_OVERLAY_TRIPLET}" )
2020-11-13 02:16:24 +08:00
endforeach ( )
endif ( )
2020-07-10 03:32:31 +08:00
2021-01-15 11:50:31 +08:00
if ( DEFINED VCPKG_FEATURE_FLAGS OR DEFINED CACHE{VCPKG_FEATURE_FLAGS} )
2021-02-19 08:27:47 +08:00
list ( JOIN VCPKG_FEATURE_FLAGS "," Z_VCPKG_FEATURE_FLAGS )
set ( Z_VCPKG_FEATURE_FLAGS "--feature-flags=${Z_VCPKG_FEATURE_FLAGS}" )
2021-01-15 11:50:31 +08:00
endif ( )
2021-02-19 08:27:47 +08:00
foreach ( Z_VCPKG_FEATURE IN LISTS VCPKG_MANIFEST_FEATURES )
list ( APPEND Z_VCPKG_ADDITIONAL_MANIFEST_PARAMS "--x-feature=${Z_VCPKG_FEATURE}" )
2020-09-12 01:57:47 +08:00
endforeach ( )
2020-11-13 02:16:24 +08:00
if ( VCPKG_MANIFEST_NO_DEFAULT_FEATURES )
2021-02-19 08:27:47 +08:00
list ( APPEND Z_VCPKG_ADDITIONAL_MANIFEST_PARAMS "--x-no-default-features" )
2020-11-13 02:16:24 +08:00
endif ( )
2020-08-02 07:45:00 +08:00
2023-02-22 02:58:03 +08:00
if ( CMAKE_VERSION VERSION_GREATER_EQUAL "3.18" )
2021-02-19 08:27:47 +08:00
set ( Z_VCPKG_MANIFEST_INSTALL_ECHO_PARAMS ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE )
2020-12-22 04:13:32 +08:00
else ( )
2021-02-19 08:27:47 +08:00
set ( Z_VCPKG_MANIFEST_INSTALL_ECHO_PARAMS )
2020-12-22 04:13:32 +08:00
endif ( )
2020-11-13 02:16:24 +08:00
execute_process (
2021-02-19 08:27:47 +08:00
C O M M A N D " $ { Z _ V C P K G _ E X E C U T A B L E } " i n s t a l l
2020-11-13 02:16:24 +08:00
- - t r i p l e t " $ { V C P K G _ T A R G E T _ T R I P L E T } "
2021-02-19 08:27:47 +08:00
- - v c p k g - r o o t " $ { Z _ V C P K G _ R O O T _ D I R } "
2020-11-13 02:16:24 +08:00
" - - x - w a i t - f o r - l o c k "
2021-02-19 08:27:47 +08:00
" - - x - m a n i f e s t - r o o t = $ { V C P K G _ M A N I F E S T _ D I R } "
2020-11-13 02:16:24 +08:00
" - - x - i n s t a l l - r o o t = $ { _ V C P K G _ I N S T A L L E D _ D I R } "
2023-03-29 01:29:38 +08:00
$ { Z _ V C P K G _ F E A T U R E _ F L A G S }
2021-02-19 08:27:47 +08:00
$ { Z _ V C P K G _ A D D I T I O N A L _ M A N I F E S T _ P A R A M S }
2020-11-13 02:16:24 +08:00
$ { V C P K G _ I N S T A L L _ O P T I O N S }
2021-02-19 08:27:47 +08:00
O U T P U T _ V A R I A B L E Z _ V C P K G _ M A N I F E S T _ I N S T A L L _ L O G T E X T
E R R O R _ V A R I A B L E Z _ V C P K G _ M A N I F E S T _ I N S T A L L _ L O G T E X T
R E S U L T _ V A R I A B L E Z _ V C P K G _ M A N I F E S T _ I N S T A L L _ R E S U L T
$ { Z _ V C P K G _ M A N I F E S T _ I N S T A L L _ E C H O _ P A R A M S }
2020-11-13 02:16:24 +08:00
)
2020-08-02 07:45:00 +08:00
2022-08-13 06:21:20 +08:00
set ( Z_VCPKG_MANIFEST_INSTALL_LOGFILE "${CMAKE_BINARY_DIR}/vcpkg-manifest-install.log" )
file ( TO_NATIVE_PATH "${Z_VCPKG_MANIFEST_INSTALL_LOGFILE}" Z_NATIVE_VCPKG_MANIFEST_INSTALL_LOGFILE )
2021-02-19 08:27:47 +08:00
file ( WRITE "${Z_VCPKG_MANIFEST_INSTALL_LOGFILE}" "${Z_VCPKG_MANIFEST_INSTALL_LOGTEXT}" )
2020-12-22 04:13:32 +08:00
2022-11-23 00:51:34 +08:00
if ( Z_VCPKG_MANIFEST_INSTALL_RESULT EQUAL "0" )
2020-11-13 02:16:24 +08:00
message ( STATUS "Running vcpkg install - done" )
set_property ( DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
2022-02-16 15:13:59 +08:00
" $ { V C P K G _ M A N I F E S T _ D I R } / v c p k g . j s o n " )
2021-02-19 08:27:47 +08:00
if ( EXISTS "${VCPKG_MANIFEST_DIR}/vcpkg-configuration.json" )
2021-01-15 11:50:31 +08:00
set_property ( DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
2021-02-19 08:27:47 +08:00
" $ { V C P K G _ M A N I F E S T _ D I R } / v c p k g - c o n f i g u r a t i o n . j s o n " )
2021-01-15 11:50:31 +08:00
endif ( )
2020-11-13 02:16:24 +08:00
else ( )
message ( STATUS "Running vcpkg install - failed" )
2022-08-13 06:21:20 +08:00
z_vcpkg_add_fatal_error ( "vcpkg install failed. See logs for more information: ${Z_NATIVE_VCPKG_MANIFEST_INSTALL_LOGFILE}" )
2020-11-13 02:16:24 +08:00
endif ( )
[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
endif ( )
endif ( )
2022-03-05 06:16:47 +08:00
option ( VCPKG_SETUP_CMAKE_PROGRAM_PATH "Enable the setup of CMAKE_PROGRAM_PATH to vcpkg paths" ON )
2022-03-08 03:01:14 +08:00
set ( VCPKG_CAN_USE_HOST_TOOLS OFF )
if ( DEFINED VCPKG_HOST_TRIPLET AND NOT VCPKG_HOST_TRIPLET STREQUAL "" )
set ( VCPKG_CAN_USE_HOST_TOOLS ON )
endif ( )
cmake_dependent_option ( VCPKG_USE_HOST_TOOLS "Setup CMAKE_PROGRAM_PATH to use host tools" ON "VCPKG_CAN_USE_HOST_TOOLS" OFF )
unset ( VCPKG_CAN_USE_HOST_TOOLS )
2022-03-05 06:16:47 +08:00
if ( VCPKG_SETUP_CMAKE_PROGRAM_PATH )
set ( tools_base_path "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/tools" )
if ( VCPKG_USE_HOST_TOOLS )
set ( tools_base_path "${VCPKG_INSTALLED_DIR}/${VCPKG_HOST_TRIPLET}/tools" )
2021-03-09 04:44:32 +08:00
endif ( )
2022-03-05 06:16:47 +08:00
list ( APPEND CMAKE_PROGRAM_PATH "${tools_base_path}" )
2022-03-30 08:12:24 +08:00
file ( GLOB Z_VCPKG_TOOLS_DIRS LIST_DIRECTORIES true "${tools_base_path}/*" )
file ( GLOB Z_VCPKG_TOOLS_FILES LIST_DIRECTORIES false "${tools_base_path}/*" )
file ( GLOB Z_VCPKG_TOOLS_DIRS_BIN LIST_DIRECTORIES true "${tools_base_path}/*/bin" )
file ( GLOB Z_VCPKG_TOOLS_FILES_BIN LIST_DIRECTORIES false "${tools_base_path}/*/bin" )
2022-03-08 03:01:14 +08:00
list ( REMOVE_ITEM Z_VCPKG_TOOLS_DIRS ${ Z_VCPKG_TOOLS_FILES } "" ) # need at least one item for REMOVE_ITEM if CMake <= 3.19
2022-03-30 08:12:24 +08:00
list ( REMOVE_ITEM Z_VCPKG_TOOLS_DIRS_BIN ${ Z_VCPKG_TOOLS_FILES_BIN } "" )
string ( REPLACE "/bin" "" Z_VCPKG_TOOLS_DIRS_TO_REMOVE "${Z_VCPKG_TOOLS_DIRS_BIN}" )
list ( REMOVE_ITEM Z_VCPKG_TOOLS_DIRS ${ Z_VCPKG_TOOLS_DIRS_TO_REMOVE } "" )
list ( APPEND Z_VCPKG_TOOLS_DIRS ${ Z_VCPKG_TOOLS_DIRS_BIN } )
2022-03-05 06:16:47 +08:00
foreach ( Z_VCPKG_TOOLS_DIR IN LISTS Z_VCPKG_TOOLS_DIRS )
list ( APPEND CMAKE_PROGRAM_PATH "${Z_VCPKG_TOOLS_DIR}" )
endforeach ( )
unset ( Z_VCPKG_TOOLS_DIR )
2022-03-30 08:12:24 +08:00
unset ( Z_VCPKG_TOOLS_DIRS )
unset ( Z_VCPKG_TOOLS_FILES )
unset ( Z_VCPKG_TOOLS_DIRS_BIN )
unset ( Z_VCPKG_TOOLS_FILES_BIN )
unset ( Z_VCPKG_TOOLS_DIRS_TO_REMOVE )
2022-03-05 06:16:47 +08:00
unset ( tools_base_path )
endif ( )
2021-03-09 04:44:32 +08:00
2022-02-19 07:48:45 +08:00
cmake_policy ( POP )
2021-02-19 08:27:47 +08:00
function ( add_executable )
z_vcpkg_function_arguments ( ARGS )
_add_executable ( ${ ARGS } )
set ( target_name "${ARGV0}" )
2020-10-28 11:48:14 +08:00
2017-10-17 02:22:21 +08:00
list ( FIND ARGV "IMPORTED" IMPORTED_IDX )
list ( FIND ARGV "ALIAS" ALIAS_IDX )
2019-05-19 14:33:16 +08:00
list ( FIND ARGV "MACOSX_BUNDLE" MACOSX_BUNDLE_IDX )
2022-11-23 00:51:34 +08:00
if ( IMPORTED_IDX EQUAL "-1" AND ALIAS_IDX EQUAL "-1" )
2019-06-01 04:49:13 +08:00
if ( VCPKG_APPLOCAL_DEPS )
2023-03-09 06:06:20 +08:00
if ( Z_VCPKG_TARGET_TRIPLET_PLAT MATCHES "windows|uwp|xbox" )
2021-02-19 08:27:47 +08:00
z_vcpkg_set_powershell_path ( )
2020-10-20 10:52:36 +08:00
set ( EXTRA_OPTIONS "" )
if ( X_VCPKG_APPLOCAL_DEPS_SERIALIZED )
set ( EXTRA_OPTIONS USES_TERMINAL )
endif ( )
2021-02-19 08:27:47 +08:00
add_custom_command ( TARGET "${target_name}" POST_BUILD
C O M M A N D " $ { Z _ V C P K G _ P O W E R S H E L L _ P A T H } " - n o p r o f i l e - e x e c u t i o n p o l i c y B y p a s s - f i l e " $ { Z _ V C P K G _ T O O L C H A I N _ D I R } / m s b u i l d / a p p l o c a l . p s 1 "
- t a r g e t B i n a r y " $ < T A R G E T _ F I L E : $ { t a r g e t _ n a m e } > "
2019-05-17 04:24:03 +08:00
- 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 } / $ { V C P K G _ T A R G E T _ T R I P L E T } $ < $ < C O N F I G : D e b u g > : / d e b u g > / b i n "
- O u t V a r i a b l e o u t
2022-05-03 02:56:24 +08:00
V E R B A T I M
2020-10-20 10:52:36 +08:00
$ { E X T R A _ O P T I O N S }
2019-05-17 04:24:03 +08:00
)
2021-02-19 08:27:47 +08:00
elseif ( Z_VCPKG_TARGET_TRIPLET_PLAT MATCHES "osx" )
2022-11-23 00:51:34 +08:00
if ( NOT MACOSX_BUNDLE_IDX EQUAL "-1" )
2022-10-15 07:32:33 +08:00
find_package ( Python COMPONENTS Interpreter )
2021-02-19 08:27:47 +08:00
add_custom_command ( TARGET "${target_name}" POST_BUILD
2022-10-15 07:32:33 +08:00
C O M M A N D " $ { P y t h o n _ E X E C U T A B L E } " " $ { Z _ V C P K G _ T O O L C H A I N _ D I R } / o s x / a p p l o c a l . p y "
2022-05-03 02:56:24 +08:00
" $ < T A R G E T _ F I L E : $ { t a r g e t _ n a m e } > "
" $ { _ V C P K G _ I N S T A L L E D _ D I R } / $ { V C P K G _ T A R G E T _ T R I P L E T } $ < $ < C O N F I G : D e b u g > : / d e b u g > "
V E R B A T I M
2019-05-17 04:24:03 +08:00
)
endif ( )
endif ( )
2017-07-29 02:44:54 +08:00
endif ( )
2021-02-19 08:27:47 +08:00
set_target_properties ( "${target_name}" PROPERTIES VS_USER_PROPS do_not_import_user.props )
set_target_properties ( "${target_name}" PROPERTIES VS_GLOBAL_VcpkgEnabled false )
2017-10-17 02:22:21 +08:00
endif ( )
endfunction ( )
2017-07-29 02:44:54 +08:00
2021-02-19 08:27:47 +08:00
function ( add_library )
z_vcpkg_function_arguments ( ARGS )
_add_library ( ${ ARGS } )
set ( target_name "${ARGV0}" )
list ( FIND ARGS "IMPORTED" IMPORTED_IDX )
list ( FIND ARGS "INTERFACE" INTERFACE_IDX )
list ( FIND ARGS "ALIAS" ALIAS_IDX )
2022-11-23 00:51:34 +08:00
if ( IMPORTED_IDX EQUAL "-1" AND INTERFACE_IDX EQUAL "-1" AND ALIAS_IDX EQUAL "-1" )
2021-02-19 08:27:47 +08:00
get_target_property ( IS_LIBRARY_SHARED "${target_name}" TYPE )
2023-03-09 06:06:20 +08:00
if ( VCPKG_APPLOCAL_DEPS AND Z_VCPKG_TARGET_TRIPLET_PLAT MATCHES "windows|uwp|xbox" AND ( IS_LIBRARY_SHARED STREQUAL "SHARED_LIBRARY" OR IS_LIBRARY_SHARED STREQUAL "MODULE_LIBRARY" ) )
2021-02-19 08:27:47 +08:00
z_vcpkg_set_powershell_path ( )
add_custom_command ( TARGET "${target_name}" POST_BUILD
C O M M A N D " $ { Z _ V C P K G _ P O W E R S H E L L _ P A T H } " - n o p r o f i l e - e x e c u t i o n p o l i c y B y p a s s - f i l e " $ { Z _ V C P K G _ T O O L C H A I N _ D I R } / m s b u i l d / a p p l o c a l . p s 1 "
- t a r g e t B i n a r y " $ < T A R G E T _ F I L E : $ { t a r g e t _ n a m e } > "
2018-02-14 08:13:27 +08:00
- 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 } / $ { V C P K G _ T A R G E T _ T R I P L E T } $ < $ < C O N F I G : D e b u g > : / d e b u g > / b i n "
- O u t V a r i a b l e o u t
2022-05-03 02:56:24 +08:00
V E R B A T I M
2018-02-14 08:13:27 +08:00
)
endif ( )
2021-02-19 08:27:47 +08:00
set_target_properties ( "${target_name}" PROPERTIES VS_USER_PROPS do_not_import_user.props )
set_target_properties ( "${target_name}" PROPERTIES VS_GLOBAL_VcpkgEnabled false )
2017-10-17 02:22:21 +08:00
endif ( )
endfunction ( )
2020-10-14 05:40:16 +08:00
# This is an experimental function to enable applocal install of dependencies as part of the `make install` process
# Arguments:
# TARGETS - a list of installed targets to have dependencies copied for
# DESTINATION - the runtime directory for those targets (usually `bin`)
2021-06-11 07:14:37 +08:00
# COMPONENT - the component this install command belongs to (optional)
2021-02-19 08:27:47 +08:00
#
# Note that this function requires CMake 3.14 for policy CMP0087
2020-10-14 05:40:16 +08:00
function ( x_vcpkg_install_local_dependencies )
2021-07-02 01:45:01 +08:00
if ( CMAKE_VERSION VERSION_LESS "3.14" )
message ( FATAL_ERROR " x_vcpkg_install_local_dependencies and X_VCPKG_APPLOCAL_DEPS_INSTALL require at least CMake 3.14
( c u r r e n t v e r s i o n : $ { C M A K E _ V E R S I O N } ) "
)
endif ( )
2022-11-23 00:51:34 +08:00
cmake_parse_arguments ( PARSE_ARGV "0" arg
2021-07-02 01:45:01 +08:00
" "
" D E S T I N A T I O N ; C O M P O N E N T "
" T A R G E T S "
)
if ( DEFINED arg_UNPARSED_ARGUMENTS )
message ( FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}" )
endif ( )
if ( NOT DEFINED arg_DESTINATION )
message ( FATAL_ERROR "DESTINATION must be specified" )
endif ( )
2023-03-09 06:06:20 +08:00
if ( Z_VCPKG_TARGET_TRIPLET_PLAT MATCHES "^(windows|uwp|xbox-.*)$" )
2021-07-02 01:45:01 +08:00
# Install CODE|SCRIPT allow the use of generator expressions
2022-02-18 02:46:49 +08:00
cmake_policy ( SET CMP0087 NEW ) # CMake 3.14
2021-07-02 01:45:01 +08:00
2021-02-19 08:27:47 +08:00
z_vcpkg_set_powershell_path ( )
2021-07-02 01:45:01 +08:00
if ( NOT IS_ABSOLUTE "${arg_DESTINATION}" )
set ( arg_DESTINATION "\${CMAKE_INSTALL_PREFIX}/${arg_DESTINATION}" )
2021-02-04 04:51:28 +08:00
endif ( )
2021-07-02 01:45:01 +08:00
set ( component_param "" )
if ( DEFINED arg_COMPONENT )
set ( component_param COMPONENT "${arg_COMPONENT}" )
2021-06-11 07:14:37 +08:00
endif ( )
2021-07-02 01:45:01 +08:00
foreach ( target IN LISTS arg_TARGETS )
get_target_property ( target_type "${target}" TYPE )
if ( NOT target_type STREQUAL "INTERFACE_LIBRARY" )
install ( CODE "message(\" -- Installing app dependencies for ${ target } ...\ " )
2021-02-19 08:27:47 +08:00
execute_process ( COMMAND \"${Z_VCPKG_POWERSHELL_PATH}\" -noprofile -executionpolicy Bypass -file \"${Z_VCPKG_TOOLCHAIN_DIR}/msbuild/applocal.ps1\"
2021-07-02 01:45:01 +08:00
- t a r g e t B i n a r y \ " $ { a r g _ D E S T I N A T I O N } / $ < T A R G E T _ F I L E _ N A M E : $ { t a r g e t } > \ "
2020-12-08 08:06:02 +08:00
- 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 } / $ { V C P K G _ T A R G E T _ T R I P L E T } $ < $ < C O N F I G : D e b u g > : / d e b u g > / b i n \ "
2021-06-11 07:14:37 +08:00
- O u t V a r i a b l e o u t ) "
2021-07-02 01:45:01 +08:00
$ { c o m p o n e n t _ p a r a m }
)
2020-12-08 08:06:02 +08:00
endif ( )
2020-10-14 05:40:16 +08:00
endforeach ( )
endif ( )
endfunction ( )
2020-11-21 05:28:14 +08:00
if ( X_VCPKG_APPLOCAL_DEPS_INSTALL )
function ( install )
2021-02-19 08:27:47 +08:00
z_vcpkg_function_arguments ( ARGS )
_install ( ${ ARGS } )
2020-11-21 05:28:14 +08:00
if ( ARGV0 STREQUAL "TARGETS" )
# Will contain the list of targets
2021-07-02 01:45:01 +08:00
set ( parsed_targets "" )
2020-11-21 05:28:14 +08:00
# Destination - [RUNTIME] DESTINATION argument overrides this
2021-07-02 01:45:01 +08:00
set ( destination "bin" )
set ( component_param "" )
2020-11-21 05:28:14 +08:00
# Parse arguments given to the install function to find targets and (runtime) destination
2021-07-02 01:45:01 +08:00
set ( modifier "" ) # Modifier for the command in the argument
set ( last_command "" ) # Last command we found to process
foreach ( arg IN LISTS ARGS )
if ( arg MATCHES "^(ARCHIVE|LIBRARY|RUNTIME|OBJECTS|FRAMEWORK|BUNDLE|PRIVATE_HEADER|PUBLIC_HEADER|RESOURCE|INCLUDES)$" )
set ( modifier "${arg}" )
2020-11-21 05:28:14 +08:00
continue ( )
endif ( )
2021-07-02 01:45:01 +08:00
if ( arg MATCHES "^(TARGETS|DESTINATION|PERMISSIONS|CONFIGURATIONS|COMPONENT|NAMELINK_COMPONENT|OPTIONAL|EXCLUDE_FROM_ALL|NAMELINK_ONLY|NAMELINK_SKIP|EXPORT)$" )
set ( last_command "${arg}" )
2020-11-21 05:28:14 +08:00
continue ( )
endif ( )
2021-07-02 01:45:01 +08:00
if ( last_command STREQUAL "TARGETS" )
list ( APPEND parsed_targets "${arg}" )
2020-11-21 05:28:14 +08:00
endif ( )
2021-07-30 00:47:35 +08:00
if ( last_command STREQUAL "DESTINATION" AND ( modifier STREQUAL "" OR modifier STREQUAL "RUNTIME" ) )
2021-07-02 01:45:01 +08:00
set ( destination "${arg}" )
2020-11-21 05:28:14 +08:00
endif ( )
2023-07-21 23:56:51 +08:00
if ( last_command STREQUAL "COMPONENT" AND ( modifier STREQUAL "" OR modifier STREQUAL "RUNTIME" ) )
2021-07-02 01:45:01 +08:00
set ( component_param "COMPONENT" "${arg}" )
2021-06-11 07:14:37 +08:00
endif ( )
2020-11-21 05:28:14 +08:00
endforeach ( )
2021-07-02 01:45:01 +08:00
x_vcpkg_install_local_dependencies (
T A R G E T S $ { p a r s e d _ t a r g e t s }
D E S T I N A T I O N " $ { d e s t i n a t i o n } "
$ { c o m p o n e n t _ p a r a m }
)
2020-11-21 05:28:14 +08:00
endif ( )
endfunction ( )
endif ( )
2022-12-02 05:39:31 +08:00
option ( VCPKG_TRACE_FIND_PACKAGE "Trace calls to find_package()" OFF )
2020-02-10 06:40:13 +08:00
if ( NOT DEFINED VCPKG_OVERRIDE_FIND_PACKAGE_NAME )
set ( VCPKG_OVERRIDE_FIND_PACKAGE_NAME find_package )
endif ( )
2021-05-27 04:40:48 +08:00
# NOTE: this is not a function, which means that arguments _are not_ perfectly forwarded
# this is fine for `find_package`, since there are no usecases for `;` in arguments,
# so perfect forwarding is not important
2022-11-17 01:56:08 +08:00
set ( z_vcpkg_find_package_backup_id "0" )
2021-05-27 04:40:48 +08:00
macro ( "${VCPKG_OVERRIDE_FIND_PACKAGE_NAME}" z_vcpkg_find_package_package_name )
2022-12-02 05:39:31 +08:00
if ( VCPKG_TRACE_FIND_PACKAGE )
string ( REPEAT " " "${z_vcpkg_find_package_backup_id}" z_vcpkg_find_package_indent )
string ( JOIN " " z_vcpkg_find_package_argn ${ ARGN } )
message ( STATUS "${z_vcpkg_find_package_indent}find_package(${z_vcpkg_find_package_package_name} ${z_vcpkg_find_package_argn})" )
unset ( z_vcpkg_find_package_argn )
unset ( z_vcpkg_find_package_indent )
endif ( )
2022-11-17 01:56:08 +08:00
math ( EXPR z_vcpkg_find_package_backup_id "${z_vcpkg_find_package_backup_id} + 1" )
2021-05-27 04:40:48 +08:00
set ( z_vcpkg_find_package_package_name "${z_vcpkg_find_package_package_name}" )
2022-11-17 01:56:08 +08:00
set ( z_vcpkg_find_package_ ${ z_vcpkg_find_package_backup_id } _ARGN "${ARGN}" )
set ( z_vcpkg_find_package_ ${ z_vcpkg_find_package_backup_id } _backup_vars "" )
2021-05-27 04:40:48 +08:00
Add initial iOS support (#6275)
* Add iOS community triplets and toolchain support
Added an iOS toolchain to enable building packages for iOS.
The toolchain is used when a triplet's VCPKG_CMAKE_SYSTEM_NAME is set
to iOS.
To configure which architecture should be built, as well as other
iOS specifics, the following triplet variables can be set:
- VCPKG_TARGET_ARCHITECTURE
- VCPKG_OSX_SYSROOT
- VCPKG_OSX_DEPLOYMENT_TARGET
- VCPKG_OSX_ARCHITECTURES
The following VCPKG_TARGET_ARCHITECTURE values are currently
supported:
- arm, arm64, x64, x86.
The following VCPKG_OSX_SYSROOT values are currently supported:
- iphoneos, iphonesimulator, or an absolute path to the device or
simulator Xcode SDK.
VCPKG_OSX_DEPLOYMENT_TARGET can be set to control the minimum iOS
delopyment target for the built libraries.
CMAKE_OSX_ARCHITECTURES is derived from VCPKG_TARGET_ARCHITECTURE,
so generally it should not be set. In case if someone needs to target
a more specific architecture (like armv7k or arm64e), it can
be set in the triplet via VCPKG_OSX_ARCHITECTURES.
Note that only certain combinations of the architecture and sysroot
will work: simulator SDKs only provide x86-based libraries, etc.
The toolchain also sets CMAKE_SYSTEM_PROCESSOR for certain
configurations, because certain packages (like libpng) depend on the
processor type.
Added 4 community iOS triplets that build static libraries:
- arm-ios, arm64-ios, x86-ios, x64-ios.
The non-arm triplets target the iOS simulator.
The triplets build static libraries because they are easiest to
integrate into an iOS project. Dynamic libraries or frameworks require
code signing on iOS, which complicates integration.
Added heuristics to try and automatically detect what iOS triplet to
use when building your own CMake project (so when a CMake project sets
CMAKE_TOOLCHAIN_FILE to buildsystems/vcpkg.cmake), if no explicit
triplet is provided (VCPKG_TARGET_TRIPLET is undefined).
The heuristic checks for the values of CMAKE_SYSTEM_NAME and
CMAKE_OSX_ARCHITECTURES. Note that for this to work,
CMAKE_OSX_ARCHITECTURES needs to be set before the first project()
call in your CMake project.
Added workaround so find_package finds vcpkg installed packages
when targeting iOS.
This is done by saving / restoring the value of CMAKE_FIND_ROOT_PATH
while also adding the vcpkg package root in the find_package override
macro.
The workaround can be removed once vcpkg upgrades to CMake 3.15.0
or higher where the issue is fixed.
Fixes: #6003
* Fix building libpng and pcre2 targetting iOS
Fixes: #6003
2020-04-16 04:06:55 +08:00
# Workaround to set the ROOT_PATH until upstream CMake stops overriding
# the ROOT_PATH at apple OS initialization phase.
# See https://gitlab.kitware.com/cmake/cmake/merge_requests/3273
2021-05-27 04:40:48 +08:00
# Fixed in CMake 3.15
2022-11-17 01:56:08 +08:00
if ( CMAKE_SYSTEM_NAME STREQUAL "iOS" )
list ( APPEND z_vcpkg_find_package_ ${ z_vcpkg_find_package_backup_id } _backup_vars "CMAKE_FIND_ROOT_PATH" )
2021-05-27 04:40:48 +08:00
if ( DEFINED CMAKE_FIND_ROOT_PATH )
2022-11-17 01:56:08 +08:00
set ( z_vcpkg_find_package_ ${ z_vcpkg_find_package_backup_id } _backup_CMAKE_FIND_ROOT_PATH "${CMAKE_FIND_ROOT_PATH}" )
2021-05-27 04:40:48 +08:00
endif ( )
2021-02-19 08:27:47 +08:00
list ( APPEND CMAKE_FIND_ROOT_PATH "${VCPKG_CMAKE_FIND_ROOT_PATH}" )
Add initial iOS support (#6275)
* Add iOS community triplets and toolchain support
Added an iOS toolchain to enable building packages for iOS.
The toolchain is used when a triplet's VCPKG_CMAKE_SYSTEM_NAME is set
to iOS.
To configure which architecture should be built, as well as other
iOS specifics, the following triplet variables can be set:
- VCPKG_TARGET_ARCHITECTURE
- VCPKG_OSX_SYSROOT
- VCPKG_OSX_DEPLOYMENT_TARGET
- VCPKG_OSX_ARCHITECTURES
The following VCPKG_TARGET_ARCHITECTURE values are currently
supported:
- arm, arm64, x64, x86.
The following VCPKG_OSX_SYSROOT values are currently supported:
- iphoneos, iphonesimulator, or an absolute path to the device or
simulator Xcode SDK.
VCPKG_OSX_DEPLOYMENT_TARGET can be set to control the minimum iOS
delopyment target for the built libraries.
CMAKE_OSX_ARCHITECTURES is derived from VCPKG_TARGET_ARCHITECTURE,
so generally it should not be set. In case if someone needs to target
a more specific architecture (like armv7k or arm64e), it can
be set in the triplet via VCPKG_OSX_ARCHITECTURES.
Note that only certain combinations of the architecture and sysroot
will work: simulator SDKs only provide x86-based libraries, etc.
The toolchain also sets CMAKE_SYSTEM_PROCESSOR for certain
configurations, because certain packages (like libpng) depend on the
processor type.
Added 4 community iOS triplets that build static libraries:
- arm-ios, arm64-ios, x86-ios, x64-ios.
The non-arm triplets target the iOS simulator.
The triplets build static libraries because they are easiest to
integrate into an iOS project. Dynamic libraries or frameworks require
code signing on iOS, which complicates integration.
Added heuristics to try and automatically detect what iOS triplet to
use when building your own CMake project (so when a CMake project sets
CMAKE_TOOLCHAIN_FILE to buildsystems/vcpkg.cmake), if no explicit
triplet is provided (VCPKG_TARGET_TRIPLET is undefined).
The heuristic checks for the values of CMAKE_SYSTEM_NAME and
CMAKE_OSX_ARCHITECTURES. Note that for this to work,
CMAKE_OSX_ARCHITECTURES needs to be set before the first project()
call in your CMake project.
Added workaround so find_package finds vcpkg installed packages
when targeting iOS.
This is done by saving / restoring the value of CMAKE_FIND_ROOT_PATH
while also adding the vcpkg package root in the find_package override
macro.
The workaround can be removed once vcpkg upgrades to CMake 3.15.0
or higher where the issue is fixed.
Fixes: #6003
* Fix building libpng and pcre2 targetting iOS
Fixes: #6003
2020-04-16 04:06:55 +08:00
endif ( )
2021-05-27 04:40:48 +08:00
2022-11-17 01:56:08 +08:00
string ( TOLOWER "${z_vcpkg_find_package_package_name}" z_vcpkg_find_package_lowercase_package_name )
2021-05-27 04:40:48 +08:00
set ( z_vcpkg_find_package_vcpkg_cmake_wrapper_path
" $ { _ V C P K G _ I N S T A L L E D _ D I R } / $ { V C P K G _ T A R G E T _ T R I P L E T } / s h a r e / $ { z _ v c p k g _ f i n d _ p a c k a g e _ l o w e r c a s e _ p a c k a g e _ n a m e } / v c p k g - c m a k e - w r a p p e r . c m a k e " )
if ( EXISTS "${z_vcpkg_find_package_vcpkg_cmake_wrapper_path}" )
2022-12-09 07:55:26 +08:00
if ( VCPKG_TRACE_FIND_PACKAGE )
string ( REPEAT " " "${z_vcpkg_find_package_backup_id}" z_vcpkg_find_package_indent )
message ( STATUS "${z_vcpkg_find_package_indent}using share/${z_vcpkg_find_package_lowercase_package_name}/vcpkg-cmake-wrapper.cmake" )
unset ( z_vcpkg_find_package_indent )
endif ( )
2022-11-17 01:56:08 +08:00
list ( APPEND z_vcpkg_find_package_ ${ z_vcpkg_find_package_backup_id } _backup_vars "ARGS" )
2021-05-27 04:40:48 +08:00
if ( DEFINED ARGS )
2022-11-17 01:56:08 +08:00
set ( z_vcpkg_find_package_ ${ z_vcpkg_find_package_backup_id } _backup_ARGS "${ARGS}" )
2021-05-27 04:40:48 +08:00
endif ( )
2022-11-17 01:56:08 +08:00
set ( ARGS "${z_vcpkg_find_package_package_name};${z_vcpkg_find_package_${z_vcpkg_find_package_backup_id}_ARGN}" )
2021-05-27 04:40:48 +08:00
include ( "${z_vcpkg_find_package_vcpkg_cmake_wrapper_path}" )
elseif ( z_vcpkg_find_package_package_name STREQUAL "Boost" AND EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include/boost" )
2018-03-14 20:08:35 +08:00
# Checking for the boost headers disables this wrapper unless the user has installed at least one boost library
2021-05-27 04:40:48 +08:00
# these intentionally are not backed up
2019-03-01 15:53:42 +08:00
set ( Boost_USE_STATIC_LIBS OFF )
set ( Boost_USE_MULTITHREADED ON )
2019-04-05 10:13:10 +08:00
set ( Boost_NO_BOOST_CMAKE ON )
2021-05-27 04:40:48 +08:00
set ( Boost_USE_STATIC_RUNTIME )
2019-03-01 15:53:42 +08:00
unset ( Boost_USE_STATIC_RUNTIME CACHE )
2021-05-27 04:40:48 +08:00
if ( CMAKE_VS_PLATFORM_TOOLSET STREQUAL "v120" )
2020-08-02 06:02:50 +08:00
set ( Boost_COMPILER "-vc120" )
else ( )
set ( Boost_COMPILER "-vc140" )
2020-08-02 07:45:00 +08:00
endif ( )
2022-11-17 01:56:08 +08:00
_find_package ( "${z_vcpkg_find_package_package_name}" ${ z_vcpkg_find_package_${z_vcpkg_find_package_backup_id } _ARGN} )
2021-05-27 04:40:48 +08:00
elseif ( z_vcpkg_find_package_package_name STREQUAL "ICU" AND EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include/unicode/utf.h" )
2022-11-17 01:56:08 +08:00
list ( FIND z_vcpkg_find_package_ ${ z_vcpkg_find_package_backup_id } _ARGN "COMPONENTS" z_vcpkg_find_package_COMPONENTS_IDX )
2022-11-23 00:51:34 +08:00
if ( NOT z_vcpkg_find_package_COMPONENTS_IDX EQUAL "-1" )
2022-11-17 01:56:08 +08:00
_find_package ( "${z_vcpkg_find_package_package_name}" ${ z_vcpkg_find_package_${z_vcpkg_find_package_backup_id } _ARGN} COMPONENTS data )
2017-11-16 13:58:26 +08:00
else ( )
2022-11-17 01:56:08 +08:00
_find_package ( "${z_vcpkg_find_package_package_name}" ${ z_vcpkg_find_package_${z_vcpkg_find_package_backup_id } _ARGN} )
2017-11-16 13:58:26 +08:00
endif ( )
2021-05-27 04:40:48 +08:00
elseif ( z_vcpkg_find_package_package_name STREQUAL "GSL" AND EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include/gsl" )
2022-11-17 01:56:08 +08:00
_find_package ( "${z_vcpkg_find_package_package_name}" ${ z_vcpkg_find_package_${z_vcpkg_find_package_backup_id } _ARGN} )
2018-03-08 03:56:21 +08:00
if ( GSL_FOUND AND TARGET GSL::gsl )
set_property ( TARGET GSL::gslcblas APPEND PROPERTY IMPORTED_CONFIGURATIONS Release )
set_property ( TARGET GSL::gsl APPEND PROPERTY IMPORTED_CONFIGURATIONS Release )
if ( EXISTS "${GSL_LIBRARY_DEBUG}" AND EXISTS "${GSL_CBLAS_LIBRARY_DEBUG}" )
2021-02-19 08:27:47 +08:00
set_property ( TARGET GSL::gsl APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug )
set_target_properties ( GSL::gsl PROPERTIES IMPORTED_LOCATION_DEBUG "${GSL_LIBRARY_DEBUG}" )
2018-03-08 03:56:21 +08:00
set_property ( TARGET GSL::gslcblas APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug )
set_target_properties ( GSL::gslcblas PROPERTIES IMPORTED_LOCATION_DEBUG "${GSL_CBLAS_LIBRARY_DEBUG}" )
endif ( )
endif ( )
2021-05-27 04:40:48 +08:00
elseif ( "${z_vcpkg_find_package_package_name}" STREQUAL "CURL" AND EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include/curl" )
2022-11-17 01:56:08 +08:00
_find_package ( "${z_vcpkg_find_package_package_name}" ${ z_vcpkg_find_package_${z_vcpkg_find_package_backup_id } _ARGN} )
2018-02-08 09:02:47 +08:00
if ( CURL_FOUND )
if ( EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/nghttp2.lib" )
list ( APPEND CURL_LIBRARIES
" d e b u g " " $ { _ V C P K G _ I N S T A L L E D _ D I R } / $ { V C P K G _ T A R G E T _ T R I P L E T } / d e b u g / l i b / n g h t t p 2 . l i b "
" o p t i m i z e d " " $ { _ V C P K G _ I N S T A L L E D _ D I R } / $ { V C P K G _ T A R G E T _ T R I P L E T } / l i b / n g h t t p 2 . l i b " )
endif ( )
endif ( )
2021-05-27 04:40:48 +08:00
elseif ( "${z_vcpkg_find_package_lowercase_package_name}" STREQUAL "grpc" AND EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/grpc" )
2022-11-17 01:56:08 +08:00
_find_package ( gRPC ${ z_vcpkg_find_package_${z_vcpkg_find_package_backup_id } _ARGN} )
2017-11-16 13:58:26 +08:00
else ( )
2022-11-17 01:56:08 +08:00
_find_package ( "${z_vcpkg_find_package_package_name}" ${ z_vcpkg_find_package_${z_vcpkg_find_package_backup_id } _ARGN} )
Add initial iOS support (#6275)
* Add iOS community triplets and toolchain support
Added an iOS toolchain to enable building packages for iOS.
The toolchain is used when a triplet's VCPKG_CMAKE_SYSTEM_NAME is set
to iOS.
To configure which architecture should be built, as well as other
iOS specifics, the following triplet variables can be set:
- VCPKG_TARGET_ARCHITECTURE
- VCPKG_OSX_SYSROOT
- VCPKG_OSX_DEPLOYMENT_TARGET
- VCPKG_OSX_ARCHITECTURES
The following VCPKG_TARGET_ARCHITECTURE values are currently
supported:
- arm, arm64, x64, x86.
The following VCPKG_OSX_SYSROOT values are currently supported:
- iphoneos, iphonesimulator, or an absolute path to the device or
simulator Xcode SDK.
VCPKG_OSX_DEPLOYMENT_TARGET can be set to control the minimum iOS
delopyment target for the built libraries.
CMAKE_OSX_ARCHITECTURES is derived from VCPKG_TARGET_ARCHITECTURE,
so generally it should not be set. In case if someone needs to target
a more specific architecture (like armv7k or arm64e), it can
be set in the triplet via VCPKG_OSX_ARCHITECTURES.
Note that only certain combinations of the architecture and sysroot
will work: simulator SDKs only provide x86-based libraries, etc.
The toolchain also sets CMAKE_SYSTEM_PROCESSOR for certain
configurations, because certain packages (like libpng) depend on the
processor type.
Added 4 community iOS triplets that build static libraries:
- arm-ios, arm64-ios, x86-ios, x64-ios.
The non-arm triplets target the iOS simulator.
The triplets build static libraries because they are easiest to
integrate into an iOS project. Dynamic libraries or frameworks require
code signing on iOS, which complicates integration.
Added heuristics to try and automatically detect what iOS triplet to
use when building your own CMake project (so when a CMake project sets
CMAKE_TOOLCHAIN_FILE to buildsystems/vcpkg.cmake), if no explicit
triplet is provided (VCPKG_TARGET_TRIPLET is undefined).
The heuristic checks for the values of CMAKE_SYSTEM_NAME and
CMAKE_OSX_ARCHITECTURES. Note that for this to work,
CMAKE_OSX_ARCHITECTURES needs to be set before the first project()
call in your CMake project.
Added workaround so find_package finds vcpkg installed packages
when targeting iOS.
This is done by saving / restoring the value of CMAKE_FIND_ROOT_PATH
while also adding the vcpkg package root in the find_package override
macro.
The workaround can be removed once vcpkg upgrades to CMake 3.15.0
or higher where the issue is fixed.
Fixes: #6003
* Fix building libpng and pcre2 targetting iOS
Fixes: #6003
2020-04-16 04:06:55 +08:00
endif ( )
2022-11-17 01:56:08 +08:00
# Do not use z_vcpkg_find_package_package_name beyond this point since it might have changed!
# Only variables using z_vcpkg_find_package_backup_id can used correctly below!
foreach ( z_vcpkg_find_package_ ${ z_vcpkg_find_package_backup_id } _backup_var IN LISTS z_vcpkg_find_package_ ${ z_vcpkg_find_package_backup_id } _backup_vars )
if ( DEFINED z_vcpkg_find_package_ ${ z_vcpkg_find_package_backup_id } _backup_ ${ z_vcpkg_find_package_${z_vcpkg_find_package_backup_id } _backup_var} )
set ( "${z_vcpkg_find_package_${z_vcpkg_find_package_backup_id}_backup_var}" "${z_vcpkg_find_package_${z_vcpkg_find_package_backup_id}_backup_${z_vcpkg_find_package_${z_vcpkg_find_package_backup_id}_backup_var}}" )
2022-11-24 08:04:20 +08:00
else ( )
unset ( "${z_vcpkg_find_package_${z_vcpkg_find_package_backup_id}_backup_var}" )
2021-05-27 04:40:48 +08:00
endif ( )
2022-11-24 08:04:20 +08:00
unset ( "z_vcpkg_find_package_${z_vcpkg_find_package_backup_id}_backup_${z_vcpkg_find_package_${z_vcpkg_find_package_backup_id}_backup_var}" )
2021-05-27 04:40:48 +08:00
endforeach ( )
2022-11-17 01:56:08 +08:00
math ( EXPR z_vcpkg_find_package_backup_id "${z_vcpkg_find_package_backup_id} - 1" )
2022-11-23 00:51:34 +08:00
if ( z_vcpkg_find_package_backup_id LESS "0" )
2022-11-17 01:56:08 +08:00
message ( FATAL_ERROR "[vcpkg]: find_package ended with z_vcpkg_find_package_backup_id being less than 0! This is a logical error and should never happen. Please provide a cmake trace log via cmake cmd line option '--trace-expand'!" )
endif ( )
2021-05-27 04:40:48 +08:00
endmacro ( )
2017-07-01 08:33:48 +08:00
2022-02-19 07:48:45 +08:00
cmake_policy ( PUSH )
2024-11-19 15:42:09 +08:00
cmake_policy ( VERSION 3.16 )
2022-02-19 07:48:45 +08:00
2017-10-17 02:22:21 +08:00
set ( VCPKG_TOOLCHAIN ON )
2021-02-19 08:27:47 +08:00
set ( Z_VCPKG_UNUSED "${CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION}" )
set ( Z_VCPKG_UNUSED "${CMAKE_EXPORT_NO_PACKAGE_REGISTRY}" )
set ( Z_VCPKG_UNUSED "${CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY}" )
set ( Z_VCPKG_UNUSED "${CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY}" )
set ( Z_VCPKG_UNUSED "${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP}" )
2017-10-17 02:22:21 +08:00
2024-01-17 03:04:54 +08:00
# Propagate these values to try-compile configurations so the triplet and toolchain load
2021-02-19 08:27:47 +08:00
if ( NOT Z_VCPKG_CMAKE_IN_TRY_COMPILE )
2022-02-18 02:46:49 +08:00
list ( APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES
V C P K G _ T A R G E T _ T R I P L E T
V C P K G _ T A R G E T _ A R C H I T E C T U R E
2024-06-20 05:38:36 +08:00
V C P K G _ H O S T _ T R I P L E T
V C P K G _ I N S T A L L E D _ D I R
V C P K G _ P R E F E R _ S Y S T E M _ L I B S
# VCPKG_APPLOCAL_DEPS # This should be off within try_compile!
2022-02-18 02:46:49 +08:00
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
Z _ V C P K G _ R O O T _ D I R
)
2024-06-20 05:38:36 +08:00
else ( )
set ( VCPKG_APPLOCAL_DEPS OFF )
2017-12-09 14:03:03 +08:00
endif ( )
2020-11-13 02:16:24 +08:00
2021-02-19 08:27:47 +08:00
if ( Z_VCPKG_HAS_FATAL_ERROR )
message ( FATAL_ERROR "${Z_VCPKG_FATAL_ERROR}" )
2020-11-13 02:16:24 +08:00
endif ( )
2021-02-19 08:27:47 +08:00
cmake_policy ( POP )