diff options
| author | myd7349 <myd7349@gmail.com> | 2019-06-29 23:29:13 +0800 |
|---|---|---|
| committer | Curtis J Bezault <curtbezault@gmail.com> | 2019-06-29 08:29:13 -0700 |
| commit | a7bbee315276d37344a464eb95b02ca20ff1b0c2 (patch) | |
| tree | f5e2e50b91aa575dd01ab758a92c3195f2f90a4f /scripts | |
| parent | 62ed7c17318b4f46109c2de73b7584fb04e85720 (diff) | |
| download | vcpkg-a7bbee315276d37344a464eb95b02ca20ff1b0c2.tar.gz vcpkg-a7bbee315276d37344a464eb95b02ca20ff1b0c2.zip | |
[vcpkg] Update vcpkg_check_features document (#7091)
* [oniguruma] Fix misusage of vcpkg_check_features
* [xsimd] Use vcpkg_check_features
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/cmake/vcpkg_check_features.cmake | 48 |
1 files changed, 39 insertions, 9 deletions
diff --git a/scripts/cmake/vcpkg_check_features.cmake b/scripts/cmake/vcpkg_check_features.cmake index c8848e987..115b1501f 100644 --- a/scripts/cmake/vcpkg_check_features.cmake +++ b/scripts/cmake/vcpkg_check_features.cmake @@ -1,6 +1,6 @@ ## # vcpkg_check_features ## -## Check if one or more features are part of the package installation. +## Check if one or more features are a part of the package installation. ## ## ## Usage ## ```cmake @@ -11,12 +11,9 @@ ## ) ## ``` ## -## `vcpkg_check_features` accepts a list of (feature, output_variable) pairs. -## The syntax is similar to the `PROPERTIES` argument of `set_target_properties`. +## `vcpkg_check_features` accepts a list of (feature, output_variable) pairs. If a feature is specified, the corresponding output variable will be set as `ON`, or `OFF` otherwise. The syntax is similar to the `PROPERTIES` argument of `set_target_properties`. ## -## `vcpkg_check_features` will create a variable `FEATURE_OPTIONS` in the -## parent scope, which you can pass as a part of `OPTIONS` argument when -## calling functions like `vcpkg_config_cmake`: +## `vcpkg_check_features` will create a variable `FEATURE_OPTIONS` in the parent scope, which you can pass as a part of `OPTIONS` argument when calling functions like `vcpkg_config_cmake`: ## ```cmake ## vcpkg_config_cmake( ## SOURCE_PATH ${SOURCE_PATH} @@ -28,13 +25,46 @@ ## ``` ## ## ## Notes -## `vcpkg_check_features` is supposed to be called only once. Otherwise, the -## `FEATURE_OPTIONS` variable set by a previous call will be overwritten. +## ```cmake +## vcpkg_check_features(<feature> <output_variable>) +## ``` +## can be used as a replacement of: +## ```cmake +## if(<feature> IN_LIST FEATURES) +## set(<output_variable> ON) +## else() +## set(<output_variable> OFF) +## endif() +## ``` +## +## However, if you have a feature that was checked like this before: +## ```cmake +## if(<feature> IN_LIST FEATURES) +## set(<output_variable> OFF) +## else() +## set(<output_variable> ON) +## endif() +## ``` +## then you should not use `vcpkg_check_features` instead. [```oniguruma```](https://github.com/microsoft/vcpkg/blob/master/ports/oniguruma/portfile.cmake), for example, has a feature named `non-posix` which is checked with: +## ```cmake +## if("non-posix" IN_LIST FEATURES) +## set(ENABLE_POSIX_API OFF) +## else() +## set(ENABLE_POSIX_API ON) +## endif() +## ``` +## and by replacing these code with: +## ```cmake +## vcpkg_check_features(non-posix ENABLE_POSIX_API) +## ``` +## is totally wrong. +## +## `vcpkg_check_features` is supposed to be called only once. Otherwise, the `FEATURE_OPTIONS` variable set by a previous call will be overwritten. ## ## ## Examples ## ## * [czmq](https://github.com/microsoft/vcpkg/blob/master/ports/czmq/portfile.cmake) -## * [oniguruma](https://github.com/microsoft/vcpkg/blob/master/ports/oniguruma/portfile.cmake) +## * [xsimd](https://github.com/microsoft/vcpkg/blob/master/ports/xsimd/portfile.cmake) ## * [xtensor](https://github.com/microsoft/vcpkg/blob/master/ports/xtensor/portfile.cmake) function(vcpkg_check_features) cmake_parse_arguments(_vcf "" "" "" ${ARGN}) |
