diff options
| author | myd7349 <myd7349@gmail.com> | 2019-06-29 01:17:39 +0800 |
|---|---|---|
| committer | Curtis J Bezault <curtbezault@gmail.com> | 2019-06-28 10:17:39 -0700 |
| commit | b4675fd65a5baebe93d0e60e082ae43013ed246f (patch) | |
| tree | 33a18d50181b38e0805c4ad7f032d32d5e6b9ae5 | |
| parent | 5b6b66512b84267c1b93ef577dea3a811a255c82 (diff) | |
| download | vcpkg-b4675fd65a5baebe93d0e60e082ae43013ed246f.tar.gz vcpkg-b4675fd65a5baebe93d0e60e082ae43013ed246f.zip | |
[vcpkg] Add vcpkg_check_features (#6958)
* [vcpkg] Add vcpkg_check_feature, vcpkg_check_features
* [vcpkg] Remove vcpkg_check_feature
* [oniguruma,xtensor] Use vcpkg_check_features
| -rw-r--r-- | docs/maintainers/portfile-functions.md | 1 | ||||
| -rw-r--r-- | docs/maintainers/vcpkg_check_features.md | 41 | ||||
| -rw-r--r-- | ports/oniguruma/CONTROL | 3 | ||||
| -rw-r--r-- | ports/oniguruma/portfile.cmake | 6 | ||||
| -rw-r--r-- | ports/xtensor/CONTROL | 3 | ||||
| -rw-r--r-- | ports/xtensor/portfile.cmake | 20 | ||||
| -rw-r--r-- | scripts/cmake/vcpkg_check_features.cmake | 82 | ||||
| -rw-r--r-- | scripts/cmake/vcpkg_common_functions.cmake | 1 |
8 files changed, 136 insertions, 21 deletions
diff --git a/docs/maintainers/portfile-functions.md b/docs/maintainers/portfile-functions.md index c4b810dc0..b98d89192 100644 --- a/docs/maintainers/portfile-functions.md +++ b/docs/maintainers/portfile-functions.md @@ -6,6 +6,7 @@ - [vcpkg\_apply\_patches](vcpkg_apply_patches.md)
- [vcpkg\_build\_cmake](vcpkg_build_cmake.md)
- [vcpkg\_build\_msbuild](vcpkg_build_msbuild.md)
+- [vcpkg\_check\_features](vcpkg_check_features.md)
- [vcpkg\_check\_linkage](vcpkg_check_linkage.md)
- [vcpkg\_clean\_msbuild](vcpkg_clean_msbuild.md)
- [vcpkg\_configure\_cmake](vcpkg_configure_cmake.md)
diff --git a/docs/maintainers/vcpkg_check_features.md b/docs/maintainers/vcpkg_check_features.md new file mode 100644 index 000000000..ca2debf85 --- /dev/null +++ b/docs/maintainers/vcpkg_check_features.md @@ -0,0 +1,41 @@ +# vcpkg_check_features + +Check if one or more features are part of the package installation. + +## Usage +```cmake +vcpkg_check_features( + <feature1> <output_variable1> + [<feature2> <output_variable2>] + ... +) +``` + +`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` 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} + PREFER_NINJA + OPTIONS + -DBUILD_TESTING=ON + ${FEATURE_OPTIONS} +) +``` + +## Notes +`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) +* [xtensor](https://github.com/microsoft/vcpkg/blob/master/ports/xtensor/portfile.cmake) + +## Source +[scripts/cmake/vcpkg_check_features.cmake](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_check_features.cmake)
diff --git a/ports/oniguruma/CONTROL b/ports/oniguruma/CONTROL index 1780b4505..7eb4e6173 100644 --- a/ports/oniguruma/CONTROL +++ b/ports/oniguruma/CONTROL @@ -1,6 +1,7 @@ Source: oniguruma
-Version: 6.9.2
+Version: 6.9.2-1
Description: Modern and flexible regular expressions library
+Homepage: https://github.com/kkos/oniguruma
Feature: non-posix
Description: Disable POSIX API
diff --git a/ports/oniguruma/portfile.cmake b/ports/oniguruma/portfile.cmake index 586bfbe07..28f489926 100644 --- a/ports/oniguruma/portfile.cmake +++ b/ports/oniguruma/portfile.cmake @@ -8,11 +8,7 @@ vcpkg_from_github( HEAD_REF master
)
-if("non-posix" IN_LIST FEATURES)
- set(ENABLE_POSIX_API OFF)
-else()
- set(ENABLE_POSIX_API ON)
-endif()
+vcpkg_check_features(non-posix ENABLE_POSIX_API)
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
diff --git a/ports/xtensor/CONTROL b/ports/xtensor/CONTROL index 3e5e33013..138d9e1fe 100644 --- a/ports/xtensor/CONTROL +++ b/ports/xtensor/CONTROL @@ -1,6 +1,7 @@ Source: xtensor
-Version: 0.20.7 +Version: 0.20.7-1
Description: C++ tensors with broadcasting and lazy computing
+Homepage: https://quantstack.net/xtensor
Build-Depends: nlohmann-json, xtl
Feature: xsimd
diff --git a/ports/xtensor/portfile.cmake b/ports/xtensor/portfile.cmake index 51e24c6e9..9c8b3b63e 100644 --- a/ports/xtensor/portfile.cmake +++ b/ports/xtensor/portfile.cmake @@ -5,29 +5,20 @@ include(vcpkg_common_functions) vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO QuantStack/xtensor
- REF 0.20.7 + REF 0.20.7
SHA512 de09900d0934f9b10453f16e43d1c3af28503f365224f9c6789b88a0cf00db820ca31e12099df1a2e3aafa73d7d83223df82f01b7611c1addb48367f936e5122
HEAD_REF master
)
-if("xsimd" IN_LIST FEATURES)
- set(XTENSOR_USE_XSIMD ON)
-else()
- set(XTENSOR_USE_XSIMD OFF)
-endif()
-
-if("tbb" IN_LIST FEATURES)
- set(XTENSOR_USE_TBB ON)
-else()
- set(XTENSOR_USE_TBB OFF)
-endif()
+vcpkg_check_features(
+ xsimd XTENSOR_USE_XSIMD
+ tbb XTENSOR_USE_TBB
+)
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
- -DXTENSOR_USE_XSIMD=${XTENSOR_USE_XSIMD}
- -DXTENSOR_USE_TBB=${XTENSOR_USE_TBB}
-DXTENSOR_ENABLE_ASSERT=OFF
-DXTENSOR_CHECK_DIMENSION=OFF
-DBUILD_TESTS=OFF
@@ -36,6 +27,7 @@ vcpkg_configure_cmake( -DDOWNLOAD_GBENCHMARK=OFF
-DDEFAULT_COLUMN_MAJOR=OFF
-DDISABLE_VS2017=OFF
+ ${FEATURE_OPTIONS}
)
vcpkg_install_cmake()
diff --git a/scripts/cmake/vcpkg_check_features.cmake b/scripts/cmake/vcpkg_check_features.cmake new file mode 100644 index 000000000..c8848e987 --- /dev/null +++ b/scripts/cmake/vcpkg_check_features.cmake @@ -0,0 +1,82 @@ +## # vcpkg_check_features +## +## Check if one or more features are part of the package installation. +## +## ## Usage +## ```cmake +## vcpkg_check_features( +## <feature1> <output_variable1> +## [<feature2> <output_variable2>] +## ... +## ) +## ``` +## +## `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` 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} +## PREFER_NINJA +## OPTIONS +## -DBUILD_TESTING=ON +## ${FEATURE_OPTIONS} +## ) +## ``` +## +## ## Notes +## `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) +## * [xtensor](https://github.com/microsoft/vcpkg/blob/master/ports/xtensor/portfile.cmake) +function(vcpkg_check_features) + cmake_parse_arguments(_vcf "" "" "" ${ARGN}) + + list(LENGTH ARGN _vcf_ARGC) + math(EXPR _vcf_INCORRECT_ARGN "${_vcf_ARGC} % 2") + + if(_vcf_INCORRECT_ARGN) + message(FATAL_ERROR "Called with incorrect number of arguments.") + endif() + + set(_vcf_IS_FEATURE_ARG ON) + set(_vcf_FEATURE_OPTIONS) + + # Process (feature, output_var) pairs + foreach(_vcf_ARG ${ARGN}) + if(_vcf_IS_FEATURE_ARG) + set(_vcf_FEATURE ${_vcf_ARG}) + + if(NOT ${_vcf_FEATURE} IN_LIST ALL_FEATURES) + message(FATAL_ERROR "Unknown feature: ${_vcf_FEATURE}") + endif() + + set(_vcf_IS_FEATURE_ARG OFF) + else() + set(_vcf_FEATURE_VAR ${_vcf_ARG}) + + if(${_vcf_FEATURE} IN_LIST FEATURES) + set(${_vcf_FEATURE_VAR} ON PARENT_SCOPE) + else() + set(${_vcf_FEATURE_VAR} OFF PARENT_SCOPE) + endif() + + list(APPEND _vcf_FEATURE_OPTIONS "-D${_vcf_FEATURE_VAR}=${${_vcf_FEATURE_VAR}}") + + set(_vcf_IS_FEATURE_ARG ON) + endif() + endforeach() + + if(DEFINED FEATURE_OPTIONS) + message(WARNING "FEATURE_OPTIONS is already defined and will be overwritten.") + endif() + + set(FEATURE_OPTIONS ${_vcf_FEATURE_OPTIONS} PARENT_SCOPE) +endfunction() diff --git a/scripts/cmake/vcpkg_common_functions.cmake b/scripts/cmake/vcpkg_common_functions.cmake index b99f8bee8..827d43abe 100644 --- a/scripts/cmake/vcpkg_common_functions.cmake +++ b/scripts/cmake/vcpkg_common_functions.cmake @@ -1,5 +1,6 @@ include(vcpkg_acquire_msys) include(vcpkg_add_to_path) +include(vcpkg_check_features) include(vcpkg_check_linkage) include(vcpkg_clean_msbuild) include(vcpkg_download_distfile) |
