mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-27 10:21:07 +08:00
[vcpkg_check_features] Set output variable explicitly and allow reverse-logic check (#7558)
* [vcpkg_check_features] Set OUT_EXPAND_OPTIONS explicitly * [vcpkg_check_features] Allow reverse logic for features * [vcpkg_check_features] Document new parameters * [vcpkg_check_features] Remove unnecessary logging * Do not create variables for each feature only set OUT_FEATURE_OPTIONS * Improve documentation * Update ports that use vcpkg_check_features() * Missing documentation updates * [pcl] Fix tools feature * [opencv,opencv4] Fix usage of vcpkg_check_features() * [opencv4] Fix typo
This commit is contained in:
parent
e6a21e1b42
commit
a3a6530631
@ -24,4 +24,5 @@
|
||||
- [vcpkg\_from\_gitlab](vcpkg_from_gitlab.md)
|
||||
- [vcpkg\_install\_cmake](vcpkg_install_cmake.md)
|
||||
- [vcpkg\_install\_msbuild](vcpkg_install_msbuild.md)
|
||||
- [vcpkg\_prettify\_command](vcpkg_prettify_command.md)
|
||||
- [vcpkg\_test\_cmake](vcpkg_test_cmake.md)
|
||||
|
@ -1,71 +1,148 @@
|
||||
# vcpkg_check_features
|
||||
|
||||
Check if one or more features are a part of the package installation.
|
||||
Check if one or more features are a part of a package installation.
|
||||
|
||||
## Usage
|
||||
```cmake
|
||||
vcpkg_check_features(
|
||||
<feature1> <output_variable1>
|
||||
[<feature2> <output_variable2>]
|
||||
...
|
||||
OUT_FEATURE_OPTIONS <FEATURE_OPTIONS>
|
||||
[FEATURES
|
||||
<cuda> <WITH_CUDA>
|
||||
[<opencv> <WITH_OPENCV>]
|
||||
...]
|
||||
[INVERTED_FEATURES
|
||||
<cuda> <IGNORE_PACKAGE_CUDA>
|
||||
[<opencv> <IGNORE_PACKAGE_OPENCV>]
|
||||
...]
|
||||
)
|
||||
```
|
||||
`vcpkg_check_features()` accepts these parameters:
|
||||
|
||||
`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`.
|
||||
* `OUT_FEATURE_OPTIONS`:
|
||||
An output variable, the function will clear the variable passed to `OUT_FEATURE_OPTIONS`
|
||||
and then set it to contain a list of option definitions (`-D<OPTION_NAME>=ON|OFF`).
|
||||
|
||||
This should be set to `FEATURE_OPTIONS` by convention.
|
||||
|
||||
* `FEATURES`:
|
||||
A list of (`FEATURE_NAME`, `OPTION_NAME`) pairs.
|
||||
For each `FEATURE_NAME` a definition is added to `OUT_FEATURE_OPTIONS` in the form of:
|
||||
|
||||
* `-D<OPTION_NAME>=ON`, if a feature is specified for installation,
|
||||
* `-D<OPTION_NAME>=OFF`, otherwise.
|
||||
|
||||
* `INVERTED_FEATURES`:
|
||||
A list of (`FEATURE_NAME`, `OPTION_NAME`) pairs, uses reversed logic from `FEATURES`.
|
||||
For each `FEATURE_NAME` a definition is added to `OUT_FEATURE_OPTIONS` in the form of:
|
||||
|
||||
* `-D<OPTION_NAME>=OFF`, if a feature is specified for installation,
|
||||
* `-D<OPTION_NAME>=ON`, otherwise.
|
||||
|
||||
`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
|
||||
```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.
|
||||
The `FEATURES` name parameter can be omitted if no `INVERTED_FEATURES` are used.
|
||||
|
||||
At least one (`FEATURE_NAME`, `OPTION_NAME`) pair must be passed to the function call.
|
||||
|
||||
Arguments passed to `FEATURES` and `INVERTED_FEATURES` are not validated to prevent duplication.
|
||||
If the same (`FEATURE_NAME`, `OPTION_NAME`) pair is passed to both lists,
|
||||
two conflicting definitions are added to `OUT_FEATURE_OPTIONS`.
|
||||
|
||||
`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)
|
||||
* [xsimd](https://github.com/microsoft/vcpkg/blob/master/ports/xsimd/portfile.cmake)
|
||||
* [xtensor](https://github.com/microsoft/vcpkg/blob/master/ports/xtensor/portfile.cmake)
|
||||
### Example 1: Regular features
|
||||
|
||||
```cmake
|
||||
$ ./vcpkg install mimalloc[asm,secure]
|
||||
|
||||
# ports/mimalloc/portfile.cmake
|
||||
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
||||
# Keyword FEATURES is optional if INVERTED_FEATURES are not used
|
||||
asm MI_SEE_ASM
|
||||
override MI_OVERRIDE
|
||||
secure MI_SECURE
|
||||
)
|
||||
|
||||
vcpkg_configure_cmake(
|
||||
SOURCE_PATH ${SOURCE_PATH}
|
||||
PREFER_NINJA
|
||||
OPTIONS
|
||||
# Expands to "-DMI_SEE_ASM=ON; -DMI_OVERRIDE=OFF; -DMI_SECURE=ON"
|
||||
${FEATURE_OPTIONS}
|
||||
)
|
||||
```
|
||||
|
||||
### Example 2: Inverted features
|
||||
|
||||
```cmake
|
||||
$ ./vcpkg install cpprestsdk[websockets]
|
||||
|
||||
# ports/cpprestsdk/portfile.cmake
|
||||
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
||||
INVERTED_FEATURES # <- Keyword INVERTED_FEATURES required
|
||||
brotli CPPREST_EXCLUDE_BROTLI
|
||||
websockets CPPREST_EXCLUDE_WEBSOCKETS
|
||||
)
|
||||
|
||||
vcpkg_configure_cmake(
|
||||
SOURCE_PATH ${SOURCE_PATH}
|
||||
PREFER_NINJA
|
||||
OPTIONS
|
||||
# Expands to "-DCPPREST_EXCLUDE_BROTLI=ON; -DCPPREST_EXCLUDE_WEBSOCKETS=OFF"
|
||||
${FEATURE_OPTIONS}
|
||||
)
|
||||
```
|
||||
|
||||
### Example 3: Set multiple options for same feature
|
||||
|
||||
```cmake
|
||||
$ ./vcpkg install pcl[cuda]
|
||||
|
||||
# ports/pcl/portfile.cmake
|
||||
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
||||
cuda WITH_CUDA
|
||||
cuda BUILD_CUDA
|
||||
cuda BUILD_GPU
|
||||
)
|
||||
|
||||
vcpkg_configure_cmake(
|
||||
SOURCE_PATH ${SOURCE_PATH}
|
||||
PREFER_NINJA
|
||||
OPTIONS
|
||||
# Expands to "-DWITH_CUDA=ON; -DBUILD_CUDA=ON; -DBUILD_GPU=ON"
|
||||
${FEATURE_OPTIONS}
|
||||
)
|
||||
```
|
||||
|
||||
### Example 4: Use regular and inverted features
|
||||
|
||||
```cmake
|
||||
$ ./vcpkg install rocksdb[tbb]
|
||||
|
||||
# ports/rocksdb/portfile.cmake
|
||||
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
||||
FEATURES # <- Keyword FEATURES is required because INVERTED_FEATURES are being used
|
||||
tbb WITH_TBB
|
||||
INVERTED_FEATURES
|
||||
tbb ROCKSDB_IGNORE_PACKAGE_TBB
|
||||
)
|
||||
|
||||
vcpkg_configure_cmake(
|
||||
SOURCE_PATH ${SOURCE_PATH}
|
||||
PREFER_NINJA
|
||||
OPTIONS
|
||||
# Expands to "-DWITH_TBB=ON; -DROCKSDB_IGNORE_PACKAGE_TBB=OFF"
|
||||
${FEATURE_OPTIONS}
|
||||
)
|
||||
```
|
||||
|
||||
## Examples in portfiles
|
||||
|
||||
* [cpprestsdk](https://github.com/microsoft/vcpkg/blob/master/ports/cpprestsdk/portfile.cmake)
|
||||
* [pcl](https://github.com/microsoft/vcpkg/blob/master/ports/pcl/portfile.cmake)
|
||||
* [rocksdb](https://github.com/microsoft/vcpkg/blob/master/ports/rocksdb/portfile.cmake)
|
||||
|
||||
|
||||
## Source
|
||||
[scripts/cmake/vcpkg_check_features.cmake](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_check_features.cmake)
|
||||
|
@ -18,14 +18,15 @@ vcpkg_configure_cmake(
|
||||
|
||||
## Parameters
|
||||
### SOURCE_PATH
|
||||
Specifies the directory containing the `CMakeLists.txt`. By convention, this is usually set in the portfile as the variable `SOURCE_PATH`.
|
||||
Specifies the directory containing the `CMakeLists.txt`.
|
||||
By convention, this is usually set in the portfile as the variable `SOURCE_PATH`.
|
||||
|
||||
### PREFER_NINJA
|
||||
Indicates that, when available, Vcpkg should use Ninja to perform the build. This should be specified unless the port is known to not work under Ninja.
|
||||
Indicates that, when available, Vcpkg should use Ninja to perform the build.
|
||||
This should be specified unless the port is known to not work under Ninja.
|
||||
|
||||
### DISABLE_PARALLEL_CONFIGURE
|
||||
Disables running the CMake configure step in parallel.
|
||||
|
||||
This is needed for libraries which write back into their source directory during configure.
|
||||
|
||||
### NO_CHARSET_FLAG
|
||||
@ -36,7 +37,8 @@ This is needed for libraries that set their own source code's character set.
|
||||
### GENERATOR
|
||||
Specifies the precise generator to use.
|
||||
|
||||
This is useful if some project-specific buildsystem has been wrapped in a cmake script that won't perform an actual build. If used for this purpose, it should be set to "NMake Makefiles".
|
||||
This is useful if some project-specific buildsystem has been wrapped in a cmake script that won't perform an actual build.
|
||||
If used for this purpose, it should be set to "NMake Makefiles".
|
||||
|
||||
### OPTIONS
|
||||
Additional options passed to CMake during the configuration.
|
||||
|
17
docs/maintainers/vcpkg_prettify_command.md
Normal file
17
docs/maintainers/vcpkg_prettify_command.md
Normal file
@ -0,0 +1,17 @@
|
||||
# vcpkg_prettify_command
|
||||
|
||||
Turns list of command arguments into a formatted string.
|
||||
|
||||
## Usage
|
||||
```cmake
|
||||
vcpkg_prettify_command()
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
* `scripts/cmake/vcpkg_execute_build_process.cmake`
|
||||
* `scripts/cmake/vcpkg_execute_required_process.cmake`
|
||||
* `scripts/cmake/vcpkg_execute_required_process_repeat.cmake`
|
||||
|
||||
## Source
|
||||
[scripts/cmake/vcpkg_prettify_command.cmake](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_prettify_command.cmake)
|
@ -1,5 +1,5 @@
|
||||
Source: czmq
|
||||
Version: 2019-06-10-1
|
||||
Version: 2019-06-10-2
|
||||
Build-Depends: zeromq
|
||||
Description: High-level C binding for ZeroMQ
|
||||
Homepage: https://github.com/zeromq/czmq
|
||||
|
@ -27,13 +27,13 @@ endforeach()
|
||||
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" BUILD_SHARED)
|
||||
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" BUILD_STATIC)
|
||||
|
||||
vcpkg_check_features(
|
||||
draft ENABLE_DRAFTS
|
||||
tool BUILD_TOOLS
|
||||
curl CZMQ_WITH_LIBCURL
|
||||
httpd CZMQ_WITH_LIBMICROHTTPD
|
||||
lz4 CZMQ_WITH_LZ4
|
||||
uuid CZMQ_WITH_UUID
|
||||
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
||||
draft ENABLE_DRAFTS
|
||||
tool BUILD_TOOLS
|
||||
curl CZMQ_WITH_LIBCURL
|
||||
httpd CZMQ_WITH_LIBMICROHTTPD
|
||||
lz4 CZMQ_WITH_LZ4
|
||||
uuid CZMQ_WITH_UUID
|
||||
)
|
||||
|
||||
vcpkg_configure_cmake(
|
||||
|
@ -1,5 +1,5 @@
|
||||
Source: darknet
|
||||
Version: 0.2.5-5
|
||||
Version: 0.2.5-6
|
||||
Description: Darknet is an open source neural network framework written in C and CUDA. You only look once (YOLO) is a state-of-the-art, real-time object detection system, best example of darknet functionalities.
|
||||
Build-Depends: pthreads (windows), stb
|
||||
Default-Features: weights
|
||||
@ -19,5 +19,5 @@ Feature: weights-train
|
||||
Description: Download pre-built weights for training
|
||||
|
||||
Feature: opencv-cuda
|
||||
Build-Depends: opencv[ffmpeg], opencv[cuda]
|
||||
Build-Depends: darknet[opencv], darknet[cuda]
|
||||
Description: Build darknet with support for a CUDA-enabled OpenCV
|
||||
|
@ -16,17 +16,12 @@ vcpkg_from_github(
|
||||
HEAD_REF master
|
||||
)
|
||||
|
||||
vcpkg_check_features(
|
||||
"cuda" ENABLE_CUDA
|
||||
"opencv" ENABLE_OPENCV
|
||||
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
||||
"cuda" ENABLE_CUDA
|
||||
"opencv" ENABLE_OPENCV
|
||||
)
|
||||
|
||||
if("opencv-cuda" IN_LIST FEATURES)
|
||||
set(ENABLE_OPENCV ON)
|
||||
set(ENABLE_CUDA ON)
|
||||
endif()
|
||||
|
||||
if (ENABLE_CUDA)
|
||||
if ("cuda" IN_LIST FEATURES)
|
||||
if (NOT VCPKG_CMAKE_SYSTEM_NAME AND NOT ENV{CUDACXX})
|
||||
#CMake looks for nvcc only in PATH and CUDACXX env vars for the Ninja generator. Since we filter path on vcpkg and CUDACXX env var is not set by CUDA installer on Windows, CMake cannot find CUDA when using Ninja generator, so we need to manually enlight it if necessary (https://gitlab.kitware.com/cmake/cmake/issues/19173). Otherwise we could just disable Ninja and use MSBuild, but unfortunately CUDA installer does not integrate with some distributions of MSBuild (like the ones inside Build Tools), making CUDA unavailable otherwise in those cases, which we want to avoid
|
||||
set(ENV{CUDACXX} "$ENV{CUDA_PATH}/bin/nvcc.exe")
|
||||
@ -80,8 +75,7 @@ vcpkg_configure_cmake(
|
||||
OPTIONS
|
||||
-DINSTALL_BIN_DIR:STRING=bin
|
||||
-DINSTALL_LIB_DIR:STRING=lib
|
||||
-DENABLE_CUDA=${ENABLE_CUDA}
|
||||
-DENABLE_OPENCV=${ENABLE_OPENCV}
|
||||
${FEATURE_OPTIONS}
|
||||
)
|
||||
|
||||
vcpkg_install_cmake()
|
||||
|
@ -12,11 +12,11 @@ vcpkg_from_github(
|
||||
|
||||
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" RDKAFKA_BUILD_STATIC)
|
||||
|
||||
vcpkg_check_features(
|
||||
lz4 ENABLE_LZ4_EXT
|
||||
ssl WITH_SSL
|
||||
zlib WITH_ZLIB
|
||||
zstd WITH_ZSTD
|
||||
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
||||
lz4 ENABLE_LZ4_EXT
|
||||
ssl WITH_SSL
|
||||
zlib WITH_ZLIB
|
||||
zstd WITH_ZSTD
|
||||
snappy WITH_SNAPPY
|
||||
)
|
||||
|
||||
@ -50,7 +50,7 @@ vcpkg_fixup_cmake_targets(
|
||||
TARGET_PATH share/rdkafka
|
||||
)
|
||||
|
||||
if(ENABLE_LZ4_EXT)
|
||||
if("lz4" IN_LIST FEATURES)
|
||||
vcpkg_replace_string(
|
||||
${CURRENT_PACKAGES_DIR}/share/rdkafka/RdKafkaConfig.cmake
|
||||
"find_dependency(LZ4)"
|
||||
|
@ -1,5 +1,5 @@
|
||||
Source: mimalloc
|
||||
Version: 2019-06-25
|
||||
Version: 2019-06-25-1
|
||||
Description: Compact general purpose allocator with excellent performance
|
||||
Homepage: https://github.com/microsoft/mimalloc
|
||||
|
||||
|
@ -10,10 +10,10 @@ vcpkg_from_github(
|
||||
fix-cmake.patch
|
||||
)
|
||||
|
||||
vcpkg_check_features(
|
||||
asm MI_SEE_ASM
|
||||
secure MI_SECURE
|
||||
override MI_OVERRIDE
|
||||
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
||||
asm MI_SEE_ASM
|
||||
secure MI_SECURE
|
||||
override MI_OVERRIDE
|
||||
)
|
||||
|
||||
vcpkg_configure_cmake(
|
||||
@ -24,11 +24,9 @@ vcpkg_configure_cmake(
|
||||
OPTIONS_RELEASE
|
||||
-DMI_CHECK_FULL=OFF
|
||||
OPTIONS
|
||||
-DMI_OVERRIDE=${MI_OVERRIDE}
|
||||
-DMI_INTERPOSE=ON
|
||||
-DMI_SEE_ASM=${MI_SEE_ASM}
|
||||
-DMI_USE_CXX=OFF
|
||||
-DMI_SECURE=${MI_SECURE}
|
||||
${FEATURE_OPTIONS}
|
||||
)
|
||||
|
||||
vcpkg_install_cmake()
|
||||
|
@ -1,5 +1,5 @@
|
||||
Source: mongo-c-driver
|
||||
Version: 1.14.0-3
|
||||
Version: 1.14.0-3-1
|
||||
Build-Depends: libbson, openssl (!windows), zlib
|
||||
Description: Client library written in C for MongoDB.
|
||||
Homepage: https://github.com/mongodb/mongo-c-driver
|
||||
|
@ -10,8 +10,8 @@ vcpkg_from_github(
|
||||
PATCHES fix-uwp.patch
|
||||
)
|
||||
|
||||
vcpkg_check_features(
|
||||
"snappy" MONGO_ENABLE_SNAPPY
|
||||
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
||||
"snappy" ENABLE_SNAPPY
|
||||
)
|
||||
|
||||
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
|
||||
@ -38,8 +38,8 @@ vcpkg_configure_cmake(
|
||||
-DENABLE_SSL=${ENABLE_SSL}
|
||||
-DENABLE_ZLIB=SYSTEM
|
||||
-DENABLE_STATIC=${ENABLE_STATIC}
|
||||
-DENABLE_SNAPPY=${MONGO_ENABLE_SNAPPY}
|
||||
-DBUILD_VERSION=${BUILD_VERSION}
|
||||
${FEATURE_OPTIONS}
|
||||
)
|
||||
|
||||
vcpkg_install_cmake()
|
||||
|
@ -1,5 +1,5 @@
|
||||
Source: oniguruma
|
||||
Version: 6.9.2-2
|
||||
Version: 6.9.2-3
|
||||
Description: Modern and flexible regular expressions library
|
||||
Homepage: https://github.com/kkos/oniguruma
|
||||
|
||||
|
@ -8,17 +8,16 @@ 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(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
||||
INVERTED_FEATURES
|
||||
"non-posix" ENABLE_POSIX_API
|
||||
)
|
||||
|
||||
vcpkg_configure_cmake(
|
||||
SOURCE_PATH ${SOURCE_PATH}
|
||||
PREFER_NINJA
|
||||
OPTIONS
|
||||
-DENABLE_POSIX_API=${ENABLE_POSIX_API}
|
||||
${FEATURE_OPTIONS}
|
||||
)
|
||||
|
||||
vcpkg_install_cmake()
|
||||
|
@ -1,8 +1,9 @@
|
||||
Source: opencv
|
||||
Version: 4.1.1
|
||||
Version: 4.1.1-1
|
||||
Homepage: https://github.com/opencv/opencv
|
||||
Description: Computer vision library
|
||||
Build-Depends: opencv4
|
||||
Build-Depends: opencv4[core]
|
||||
Default-Features: dnn, jpeg, opengl, png, tiff, webp
|
||||
|
||||
Feature: nonfree
|
||||
Build-Depends: opencv4[nonfree]
|
||||
|
@ -1,5 +1,5 @@
|
||||
Source: opencv4
|
||||
Version: 4.1.1
|
||||
Version: 4.1.1-1
|
||||
Build-Depends: protobuf, zlib
|
||||
Description: computer vision library
|
||||
Default-Features: dnn, jpeg, opengl, png, tiff, webp
|
||||
|
@ -27,34 +27,53 @@ string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" BUILD_WITH_STATIC_CRT)
|
||||
|
||||
set(ADE_DIR ${CURRENT_INSTALLED_DIR}/share/ade CACHE PATH "Path to existing ADE CMake Config file")
|
||||
|
||||
vcpkg_check_features(
|
||||
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
||||
"ade" WITH_ADE
|
||||
"contrib" WITH_CONTRIB
|
||||
"cuda" WITH_CUDA
|
||||
"cuda" WITH_CUBLAS
|
||||
"dnn" BUILD_opencv_dnn
|
||||
"eigen" WITH_EIGEN
|
||||
"ffmpeg" WITH_FFMPEG
|
||||
"gdcm" WITH_GDCM
|
||||
"halide" WITH_HALIDE
|
||||
"ipp" WITH_IPP
|
||||
"jasper" WITH_JASPER
|
||||
"jpeg" WITH_JPEG
|
||||
"nonfree" OPENCV_ENABLE_NONFREE
|
||||
"openexr" WITH_OPENEXR
|
||||
"opengl" WITH_OPENGL
|
||||
"openmp" WITH_OPENMP
|
||||
"ovis" BUILD_opencv_ovis
|
||||
"png" WITH_PNG
|
||||
"qt" WITH_QT
|
||||
"sfm" BUILD_opencv_sfm
|
||||
"tbb" WITH_TBB
|
||||
"tiff" WITH_TIFF
|
||||
"vtk" WITH_VTK
|
||||
"webp" WITH_WEBP
|
||||
"world" BUILD_opencv_world
|
||||
)
|
||||
|
||||
if(WITH_CUDA)
|
||||
# Cannot use vcpkg_check_features() for "ipp", "ovis", "tbb", and "vtk".
|
||||
# As the respective value of their variables can be unset conditionally.
|
||||
set(WITH_IPP OFF)
|
||||
if("ipp" IN_LIST FEATURES)
|
||||
set(WITH_IPP ON)
|
||||
endif()
|
||||
|
||||
set(BUILD_opencv_ovis OFF)
|
||||
if("ovis" IN_LIST FEATURES)
|
||||
set(BUILD_opencv_ovis ON)
|
||||
endif()
|
||||
|
||||
set(WITH_TBB OFF)
|
||||
if("tbb" IN_LIST FEATURES)
|
||||
set(WITH_TBB ON)
|
||||
endif()
|
||||
|
||||
set(WITH_VTK OFF)
|
||||
if("vtk" IN_LIST FEATURES)
|
||||
set(WITH_VTK ON)
|
||||
endif()
|
||||
|
||||
if("cuda" IN_LIST FEATURES)
|
||||
vcpkg_download_distfile(OCV_DOWNLOAD
|
||||
URLS "https://github.com/NVIDIA/NVIDIAOpticalFlowSDK/archive/79c6cee80a2df9a196f20afd6b598a9810964c32.zip"
|
||||
FILENAME "opencv-cache/nvidia_optical_flow/ca5acedee6cb45d0ec610a6732de5c15-79c6cee80a2df9a196f20afd6b598a9810964c32.zip"
|
||||
@ -64,7 +83,7 @@ endif()
|
||||
|
||||
# Build image quality module when building with 'contrib' feature and not UWP.
|
||||
set(BUILD_opencv_quality OFF)
|
||||
if(WITH_CONTRIB)
|
||||
if("contrib" IN_LIST FEATURES)
|
||||
if (VCPKG_TARGET_IS_UWP)
|
||||
set(BUILD_opencv_quality OFF)
|
||||
message(WARNING "The image quality module (quality) does not build for UWP, the module has been disabled.")
|
||||
@ -144,7 +163,7 @@ if(WITH_CONTRIB)
|
||||
set(BUILD_WITH_CONTRIB_FLAG "-DOPENCV_EXTRA_MODULES_PATH=${CONTRIB_SOURCE_PATH}/modules")
|
||||
endif()
|
||||
|
||||
if(BUILD_opencv_dnn)
|
||||
if("dnn" IN_LIST FEATURES)
|
||||
vcpkg_download_distfile(TINYDNN_ARCHIVE
|
||||
URLS "https://github.com/tiny-dnn/tiny-dnn/archive/v1.0.0a3.tar.gz"
|
||||
FILENAME "opencv-cache/tiny_dnn/adb1c512e09ca2c7a6faef36f9c53e59-v1.0.0a3.tar.gz"
|
||||
@ -238,7 +257,6 @@ vcpkg_configure_cmake(
|
||||
-DOPENCV_FFMPEG_USE_FIND_PACKAGE=FFMPEG
|
||||
-DCMAKE_DEBUG_POSTFIX=d
|
||||
###### Ungrouped Entries
|
||||
-DOPENCV_ENABLE_NONFREE=${OPENCV_ENABLE_NONFREE}
|
||||
-DBUILD_opencv_java=OFF
|
||||
-Dade_DIR=${ADE_DIR}
|
||||
###### Disable build 3rd party libs
|
||||
@ -285,34 +303,17 @@ vcpkg_configure_cmake(
|
||||
${BUILD_WITH_CONTRIB_FLAG}
|
||||
-DOPENCV_OTHER_INSTALL_PATH=share/opencv
|
||||
###### customized properties
|
||||
-DWITH_ADE=${WITH_ADE}
|
||||
-DWITH_CUBLAS=${WITH_CUDA}
|
||||
-DWITH_CUDA=${WITH_CUDA}
|
||||
-DWITH_EIGEN=${WITH_EIGEN}
|
||||
-DWITH_FFMPEG=${WITH_FFMPEG}
|
||||
-DWITH_GDCM=${WITH_GDCM}
|
||||
-DWITH_HALIDE=${WITH_HALIDE}
|
||||
## Options from vcpkg_check_features()
|
||||
${FEATURE_OPTIONS}
|
||||
-DWITH_IPP=${WITH_IPP}
|
||||
-DWITH_JASPER=${WITH_JASPER}
|
||||
-DWITH_JPEG=${WITH_JPEG}
|
||||
-DWITH_MSMF=${WITH_MSMF}
|
||||
-DWITH_OPENEXR=${WITH_OPENEXR}
|
||||
-DWITH_OPENGL=${WITH_OPENGL}
|
||||
-DWITH_OPENMP=${WITH_OPENMP}
|
||||
-DWITH_PNG=${WITH_PNG}
|
||||
-DWITH_PROTOBUF=ON
|
||||
-DWITH_QT=${WITH_QT}
|
||||
-DWITH_TBB=${WITH_TBB}
|
||||
-DWITH_TIFF=${WITH_TIFF}
|
||||
-DWITH_VTK=${WITH_VTK}
|
||||
-DWITH_WEBP=${WITH_WEBP}
|
||||
###### WITH PROPERTIES explicitly disabled, they have problems with libraries if already installed by user and that are "involuntarily" found during install
|
||||
-DWITH_LAPACK=OFF
|
||||
###### BUILD_options (mainly modules which require additional libraries)
|
||||
-DBUILD_opencv_ovis=${BUILD_opencv_ovis}
|
||||
-DBUILD_opencv_sfm=${BUILD_opencv_sfm}
|
||||
-DBUILD_opencv_dnn=${BUILD_opencv_dnn}
|
||||
-DBUILD_opencv_world=${BUILD_opencv_world}
|
||||
###### The following modules are disabled for UWP
|
||||
-DBUILD_opencv_quality=${BUILD_opencv_quality}
|
||||
)
|
||||
@ -356,7 +357,7 @@ find_package(VTK QUIET)
|
||||
find_package(OpenMP QUIET)
|
||||
find_package(GDCM QUIET)" OPENCV_MODULES "${OPENCV_MODULES}")
|
||||
|
||||
if(WITH_OPENMP)
|
||||
if("openmp" IN_LIST FEATURES)
|
||||
string(REPLACE "set_target_properties(opencv_core PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES \""
|
||||
"set_target_properties(opencv_core PROPERTIES
|
||||
|
@ -1,5 +1,5 @@
|
||||
Source: paho-mqttpp3
|
||||
Version: 1.0.1
|
||||
Version: 1.0.1-1
|
||||
Description: Paho project provides open-source C++ wrapper for Paho C library
|
||||
Build-Depends: paho-mqtt
|
||||
Default-Features: ssl
|
||||
|
@ -9,7 +9,9 @@ vcpkg_from_github(
|
||||
HEAD_REF master
|
||||
)
|
||||
|
||||
vcpkg_check_features("ssl" PAHO_WITH_SSL)
|
||||
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
||||
"ssl" PAHO_WITH_SSL
|
||||
)
|
||||
|
||||
# Link with 'paho-mqtt3as' library
|
||||
set(PAHO_C_LIBNAME paho-mqtt3as)
|
||||
@ -48,8 +50,8 @@ vcpkg_configure_cmake(
|
||||
OPTIONS
|
||||
-DPAHO_BUILD_STATIC=${PAHO_MQTTPP3_STATIC}
|
||||
-DPAHO_BUILD_SHARED=${PAHO_MQTTPP3_SHARED}
|
||||
-DPAHO_WITH_SSL=${PAHO_WITH_SSL}
|
||||
-DPAHO_MQTT_C_INCLUDE_DIRS=${PAHO_C_INC}
|
||||
${FEATURE_OPTIONS}
|
||||
${PAHO_OPTIONS}
|
||||
)
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
Source: pcl
|
||||
Version: 1.9.1-6
|
||||
Version: 1.9.1-7
|
||||
Homepage: https://github.com/PointCloudLibrary/pcl
|
||||
Description: Point Cloud Library (PCL) is open source library for 2D/3D image and point cloud processing.
|
||||
Build-Depends: eigen3, flann, qhull, vtk, libpng, boost-system, boost-filesystem, boost-thread, boost-date-time, boost-iostreams, boost-random, boost-foreach, boost-dynamic-bitset, boost-property-map, boost-graph, boost-multi-array, boost-signals2, boost-ptr-container, boost-uuid, boost-interprocess, boost-asio
|
||||
|
@ -18,13 +18,15 @@ file(REMOVE ${SOURCE_PATH}/cmake/Modules/FindFLANN.cmake)
|
||||
|
||||
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" PCL_SHARED_LIBS)
|
||||
|
||||
vcpkg_check_features(
|
||||
openni2 WITH_OPENNI2
|
||||
qt WITH_QT
|
||||
pcap WITH_PCAP
|
||||
cuda WITH_CUDA
|
||||
tools BUILD_TOOLS
|
||||
opengl WITH_OPENGL
|
||||
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
||||
openni2 WITH_OPENNI2
|
||||
qt WITH_QT
|
||||
pcap WITH_PCAP
|
||||
cuda WITH_CUDA
|
||||
cuda BUILD_CUDA
|
||||
cuda BUILD_GPU
|
||||
tools BUILD_tools
|
||||
opengl WITH_OPENGL
|
||||
)
|
||||
|
||||
vcpkg_configure_cmake(
|
||||
@ -33,24 +35,18 @@ vcpkg_configure_cmake(
|
||||
OPTIONS
|
||||
# BUILD
|
||||
-DBUILD_surface_on_nurbs=ON
|
||||
-DBUILD_tools=${BUILD_TOOLS}
|
||||
-DBUILD_CUDA=${WITH_CUDA}
|
||||
-DBUILD_GPU=${WITH_CUDA} # build GPU when use CUDA
|
||||
# PCL
|
||||
-DPCL_BUILD_WITH_BOOST_DYNAMIC_LINKING_WIN32=${PCL_SHARED_LIBS}
|
||||
-DPCL_BUILD_WITH_FLANN_DYNAMIC_LINKING_WIN32=${PCL_SHARED_LIBS}
|
||||
-DPCL_BUILD_WITH_QHULL_DYNAMIC_LINKING_WIN32=${PCL_SHARED_LIBS}
|
||||
-DPCL_SHARED_LIBS=${PCL_SHARED_LIBS}
|
||||
# WITH
|
||||
-DWITH_CUDA=${WITH_CUDA}
|
||||
-DWITH_LIBUSB=OFF
|
||||
-DWITH_OPENNI2=${WITH_OPENNI2}
|
||||
-DWITH_PCAP=${WITH_PCAP}
|
||||
-DWITH_PNG=ON
|
||||
-DWITH_QHULL=ON
|
||||
-DWITH_QT=${WITH_QT}
|
||||
-DWITH_VTK=ON
|
||||
-DWITH_OPENGL=${WITH_OPENGL}
|
||||
# FEATURES
|
||||
${FEATURE_OPTIONS}
|
||||
)
|
||||
|
||||
vcpkg_install_cmake()
|
||||
|
@ -28,44 +28,22 @@ string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "dynamic" WITH_MD_LIBRARY)
|
||||
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" ROCKSDB_DISABLE_INSTALL_SHARED_LIB)
|
||||
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" ROCKSDB_DISABLE_INSTALL_STATIC_LIB)
|
||||
|
||||
set(WITH_LZ4 OFF)
|
||||
if("lz4" IN_LIST FEATURES)
|
||||
set(WITH_LZ4 ON)
|
||||
endif()
|
||||
|
||||
set(WITH_SNAPPY OFF)
|
||||
if("snappy" IN_LIST FEATURES)
|
||||
set(WITH_SNAPPY ON)
|
||||
endif()
|
||||
|
||||
set(WITH_ZLIB OFF)
|
||||
if("zlib" IN_LIST FEATURES)
|
||||
set(WITH_ZLIB ON)
|
||||
endif()
|
||||
|
||||
set(WITH_ZLIB OFF)
|
||||
if("zstd" IN_LIST FEATURES)
|
||||
set(WITH_ZLIB ON)
|
||||
endif()
|
||||
|
||||
set(WITH_TBB OFF)
|
||||
set(ROCKSDB_IGNORE_PACKAGE_TBB TRUE)
|
||||
if("tbb" IN_LIST FEATURES)
|
||||
set(WITH_TBB ON)
|
||||
set(ROCKSDB_IGNORE_PACKAGE_TBB FALSE)
|
||||
endif()
|
||||
|
||||
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
||||
FEATURES
|
||||
"lz4" WITH_LZ4
|
||||
"snappy" WITH_SNAPPY
|
||||
"zlib" WITH_ZLIB
|
||||
"zstd" WITH_ZSTD
|
||||
"tbb" WITH_TBB
|
||||
INVERTED_FEATURES
|
||||
"tbb" CMAKE_DISABLE_FIND_PACKAGE_TBB
|
||||
)
|
||||
|
||||
vcpkg_configure_cmake(
|
||||
SOURCE_PATH ${SOURCE_PATH}
|
||||
PREFER_NINJA
|
||||
OPTIONS
|
||||
-DWITH_GFLAGS=0
|
||||
-DWITH_SNAPPY=${WITH_SNAPPY}
|
||||
-DWITH_LZ4=${WITH_LZ4}
|
||||
-DWITH_ZLIB=${WITH_ZLIB}
|
||||
-DWITH_TBB=${WITH_TBB}
|
||||
-DWITH_ZSTD=${WITH_ZSTD}
|
||||
-DWITH_TESTS=OFF
|
||||
-DUSE_RTTI=1
|
||||
-DROCKSDB_INSTALL_ON_WINDOWS=ON
|
||||
@ -75,10 +53,10 @@ vcpkg_configure_cmake(
|
||||
-DCMAKE_DEBUG_POSTFIX=d
|
||||
-DROCKSDB_DISABLE_INSTALL_SHARED_LIB=${ROCKSDB_DISABLE_INSTALL_SHARED_LIB}
|
||||
-DROCKSDB_DISABLE_INSTALL_STATIC_LIB=${ROCKSDB_DISABLE_INSTALL_STATIC_LIB}
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_TBB=${ROCKSDB_IGNORE_PACKAGE_TBB}
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_NUMA=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_gtest=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_Git=TRUE
|
||||
${FEATURE_OPTIONS}
|
||||
)
|
||||
|
||||
vcpkg_install_cmake()
|
||||
|
@ -1,5 +1,5 @@
|
||||
Source: xsimd
|
||||
Version: 7.2.3-1
|
||||
Version: 7.2.3-2
|
||||
Description: Modern, portable C++ wrappers for SIMD intrinsics
|
||||
Homepage: https://github.com/QuantStack/xsimd
|
||||
|
||||
|
@ -10,16 +10,18 @@ vcpkg_from_github(
|
||||
HEAD_REF master
|
||||
)
|
||||
|
||||
vcpkg_check_features(xcomplex ENABLE_XTL_COMPLEX)
|
||||
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
||||
xcomplex ENABLE_XTL_COMPLEX
|
||||
)
|
||||
|
||||
vcpkg_configure_cmake(
|
||||
SOURCE_PATH ${SOURCE_PATH}
|
||||
PREFER_NINJA
|
||||
OPTIONS
|
||||
-DENABLE_FALLBACK=OFF
|
||||
-DENABLE_XTL_COMPLEX=${ENABLE_XTL_COMPLEX}
|
||||
-DBUILD_TESTS=OFF
|
||||
-DDOWNLOAD_GTEST=OFF
|
||||
${FEATURE_OPTIONS}
|
||||
)
|
||||
|
||||
vcpkg_install_cmake()
|
||||
|
@ -1,5 +1,5 @@
|
||||
Source: xtensor
|
||||
Version: 0.20.7-1
|
||||
Version: 0.20.7-2
|
||||
Description: C++ tensors with broadcasting and lazy computing
|
||||
Homepage: https://quantstack.net/xtensor
|
||||
Build-Depends: nlohmann-json, xtl
|
||||
|
@ -10,7 +10,7 @@ vcpkg_from_github(
|
||||
HEAD_REF master
|
||||
)
|
||||
|
||||
vcpkg_check_features(
|
||||
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
||||
xsimd XTENSOR_USE_XSIMD
|
||||
tbb XTENSOR_USE_TBB
|
||||
)
|
||||
|
@ -1,5 +1,5 @@
|
||||
Source: zeromq
|
||||
Version: 2019-07-09
|
||||
Version: 2019-07-09-1
|
||||
Homepage: https://github.com/zeromq/libzmq
|
||||
Description: The ZeroMQ lightweight messaging kernel is a library which extends the standard socket interfaces with features traditionally provided by specialised messaging middleware products
|
||||
|
||||
|
@ -11,7 +11,9 @@ vcpkg_from_github(
|
||||
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" BUILD_STATIC)
|
||||
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" BUILD_SHARED)
|
||||
|
||||
vcpkg_check_features(sodium WITH_LIBSODIUM)
|
||||
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
||||
sodium WITH_LIBSODIUM
|
||||
)
|
||||
|
||||
vcpkg_configure_cmake(
|
||||
SOURCE_PATH ${SOURCE_PATH}
|
||||
@ -21,8 +23,8 @@ vcpkg_configure_cmake(
|
||||
-DPOLLER=select
|
||||
-DBUILD_STATIC=${BUILD_STATIC}
|
||||
-DBUILD_SHARED=${BUILD_SHARED}
|
||||
-DWITH_LIBSODIUM=${WITH_LIBSODIUM}
|
||||
-DWITH_PERF_TOOL=OFF
|
||||
${FEATURE_OPTIONS}
|
||||
OPTIONS_DEBUG
|
||||
"-DCMAKE_PDB_OUTPUT_DIRECTORY=${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg"
|
||||
)
|
||||
|
@ -1,112 +1,191 @@
|
||||
## # vcpkg_check_features
|
||||
##
|
||||
## Check if one or more features are a part of the package installation.
|
||||
##
|
||||
## Check if one or more features are a part of a package installation.
|
||||
##
|
||||
## ## Usage
|
||||
## ```cmake
|
||||
## vcpkg_check_features(
|
||||
## <feature1> <output_variable1>
|
||||
## [<feature2> <output_variable2>]
|
||||
## ...
|
||||
## OUT_FEATURE_OPTIONS <FEATURE_OPTIONS>
|
||||
## [FEATURES
|
||||
## <cuda> <WITH_CUDA>
|
||||
## [<opencv> <WITH_OPENCV>]
|
||||
## ...]
|
||||
## [INVERTED_FEATURES
|
||||
## <cuda> <IGNORE_PACKAGE_CUDA>
|
||||
## [<opencv> <IGNORE_PACKAGE_OPENCV>]
|
||||
## ...]
|
||||
## )
|
||||
## ```
|
||||
##
|
||||
## `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`:
|
||||
## ```cmake
|
||||
## vcpkg_config_cmake(
|
||||
## SOURCE_PATH ${SOURCE_PATH}
|
||||
## PREFER_NINJA
|
||||
## OPTIONS
|
||||
## -DBUILD_TESTING=ON
|
||||
## ${FEATURE_OPTIONS}
|
||||
## )
|
||||
## ```
|
||||
##
|
||||
## `vcpkg_check_features()` accepts these parameters:
|
||||
##
|
||||
## * `OUT_FEATURE_OPTIONS`:
|
||||
## An output variable, the function will clear the variable passed to `OUT_FEATURE_OPTIONS`
|
||||
## and then set it to contain a list of option definitions (`-D<OPTION_NAME>=ON|OFF`).
|
||||
##
|
||||
## This should be set to `FEATURE_OPTIONS` by convention.
|
||||
##
|
||||
## * `FEATURES`:
|
||||
## A list of (`FEATURE_NAME`, `OPTION_NAME`) pairs.
|
||||
## For each `FEATURE_NAME` a definition is added to `OUT_FEATURE_OPTIONS` in the form of:
|
||||
##
|
||||
## * `-D<OPTION_NAME>=ON`, if a feature is specified for installation,
|
||||
## * `-D<OPTION_NAME>=OFF`, otherwise.
|
||||
##
|
||||
## * `INVERTED_FEATURES`:
|
||||
## A list of (`FEATURE_NAME`, `OPTION_NAME`) pairs, uses reversed logic from `FEATURES`.
|
||||
## For each `FEATURE_NAME` a definition is added to `OUT_FEATURE_OPTIONS` in the form of:
|
||||
##
|
||||
## * `-D<OPTION_NAME>=OFF`, if a feature is specified for installation,
|
||||
## * `-D<OPTION_NAME>=ON`, otherwise.
|
||||
##
|
||||
##
|
||||
## ## Notes
|
||||
## ```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.
|
||||
##
|
||||
##
|
||||
## The `FEATURES` name parameter can be omitted if no `INVERTED_FEATURES` are used.
|
||||
##
|
||||
## At least one (`FEATURE_NAME`, `OPTION_NAME`) pair must be passed to the function call.
|
||||
##
|
||||
## Arguments passed to `FEATURES` and `INVERTED_FEATURES` are not validated to prevent duplication.
|
||||
## If the same (`FEATURE_NAME`, `OPTION_NAME`) pair is passed to both lists,
|
||||
## two conflicting definitions are added to `OUT_FEATURE_OPTIONS`.
|
||||
##
|
||||
##
|
||||
## ## Examples
|
||||
##
|
||||
## * [czmq](https://github.com/microsoft/vcpkg/blob/master/ports/czmq/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)
|
||||
##
|
||||
## ### Example 1: Regular features
|
||||
##
|
||||
## ```cmake
|
||||
## $ ./vcpkg install mimalloc[asm,secure]
|
||||
##
|
||||
## # ports/mimalloc/portfile.cmake
|
||||
## vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
||||
## # Keyword FEATURES is optional if INVERTED_FEATURES are not used
|
||||
## asm MI_SEE_ASM
|
||||
## override MI_OVERRIDE
|
||||
## secure MI_SECURE
|
||||
## )
|
||||
##
|
||||
## vcpkg_configure_cmake(
|
||||
## SOURCE_PATH ${SOURCE_PATH}
|
||||
## PREFER_NINJA
|
||||
## OPTIONS
|
||||
## # Expands to "-DMI_SEE_ASM=ON; -DMI_OVERRIDE=OFF; -DMI_SECURE=ON"
|
||||
## ${FEATURE_OPTIONS}
|
||||
## )
|
||||
## ```
|
||||
##
|
||||
## ### Example 2: Inverted features
|
||||
##
|
||||
## ```cmake
|
||||
## $ ./vcpkg install cpprestsdk[websockets]
|
||||
##
|
||||
## # ports/cpprestsdk/portfile.cmake
|
||||
## vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
||||
## INVERTED_FEATURES # <- Keyword INVERTED_FEATURES required
|
||||
## brotli CPPREST_EXCLUDE_BROTLI
|
||||
## websockets CPPREST_EXCLUDE_WEBSOCKETS
|
||||
## )
|
||||
##
|
||||
## vcpkg_configure_cmake(
|
||||
## SOURCE_PATH ${SOURCE_PATH}
|
||||
## PREFER_NINJA
|
||||
## OPTIONS
|
||||
## # Expands to "-DCPPREST_EXCLUDE_BROTLI=ON; -DCPPREST_EXCLUDE_WEBSOCKETS=OFF"
|
||||
## ${FEATURE_OPTIONS}
|
||||
## )
|
||||
## ```
|
||||
##
|
||||
## ### Example 3: Set multiple options for same feature
|
||||
##
|
||||
## ```cmake
|
||||
## $ ./vcpkg install pcl[cuda]
|
||||
##
|
||||
## # ports/pcl/portfile.cmake
|
||||
## vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
||||
## cuda WITH_CUDA
|
||||
## cuda BUILD_CUDA
|
||||
## cuda BUILD_GPU
|
||||
## )
|
||||
##
|
||||
## vcpkg_configure_cmake(
|
||||
## SOURCE_PATH ${SOURCE_PATH}
|
||||
## PREFER_NINJA
|
||||
## OPTIONS
|
||||
## # Expands to "-DWITH_CUDA=ON; -DBUILD_CUDA=ON; -DBUILD_GPU=ON"
|
||||
## ${FEATURE_OPTIONS}
|
||||
## )
|
||||
## ```
|
||||
##
|
||||
## ### Example 4: Use regular and inverted features
|
||||
##
|
||||
## ```cmake
|
||||
## $ ./vcpkg install rocksdb[tbb]
|
||||
##
|
||||
## # ports/rocksdb/portfile.cmake
|
||||
## vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
||||
## FEATURES # <- Keyword FEATURES is required because INVERTED_FEATURES are being used
|
||||
## tbb WITH_TBB
|
||||
## INVERTED_FEATURES
|
||||
## tbb ROCKSDB_IGNORE_PACKAGE_TBB
|
||||
## )
|
||||
##
|
||||
## vcpkg_configure_cmake(
|
||||
## SOURCE_PATH ${SOURCE_PATH}
|
||||
## PREFER_NINJA
|
||||
## OPTIONS
|
||||
## # Expands to "-DWITH_TBB=ON; -DROCKSDB_IGNORE_PACKAGE_TBB=OFF"
|
||||
## ${FEATURE_OPTIONS}
|
||||
## )
|
||||
## ```
|
||||
##
|
||||
## ## Examples in portfiles
|
||||
##
|
||||
## * [cpprestsdk](https://github.com/microsoft/vcpkg/blob/master/ports/cpprestsdk/portfile.cmake)
|
||||
## * [pcl](https://github.com/microsoft/vcpkg/blob/master/ports/pcl/portfile.cmake)
|
||||
## * [rocksdb](https://github.com/microsoft/vcpkg/blob/master/ports/rocksdb/portfile.cmake)
|
||||
##
|
||||
function(vcpkg_check_features)
|
||||
cmake_parse_arguments(_vcf "" "" "" ${ARGN})
|
||||
cmake_parse_arguments(_vcf "" "OUT_FEATURE_OPTIONS" "FEATURES;INVERTED_FEATURES" ${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.")
|
||||
if (NOT DEFINED _vcf_OUT_FEATURE_OPTIONS)
|
||||
message(FATAL_ERROR "OUT_FEATURE_OPTIONS must be specified.")
|
||||
endif()
|
||||
|
||||
set(_vcf_IS_FEATURE_ARG ON)
|
||||
macro(_check_features _vcf_ARGUMENT _set_if _set_else)
|
||||
list(LENGTH ${_vcf_ARGUMENT} FEATURES_SET_LEN)
|
||||
math(EXPR _vcf_INCORRECT_ARGN "${FEATURES_SET_LEN} % 2")
|
||||
if(_vcf_INCORRECT_ARGN)
|
||||
message(FATAL_ERROR "Called with incorrect number of arguments.")
|
||||
endif()
|
||||
|
||||
set(_vcf_IS_FEATURE_NAME_ARG ON)
|
||||
foreach(_vcf_ARG ${${_vcf_ARGUMENT}})
|
||||
if(_vcf_IS_FEATURE_NAME_ARG)
|
||||
set(_vcf_FEATURE_NAME ${_vcf_ARG})
|
||||
if(NOT ${_vcf_FEATURE_NAME} IN_LIST ALL_FEATURES)
|
||||
message(FATAL_ERROR "Unknown feature: ${_vcf_FEATURE_NAME}")
|
||||
endif()
|
||||
set(_vcf_IS_FEATURE_NAME_ARG OFF)
|
||||
else()
|
||||
set(_vcf_FEATURE_VARIABLE ${_vcf_ARG})
|
||||
if(${_vcf_FEATURE_NAME} IN_LIST FEATURES)
|
||||
list(APPEND _vcf_FEATURE_OPTIONS "-D${_vcf_FEATURE_VARIABLE}=${_set_if}")
|
||||
else()
|
||||
list(APPEND _vcf_FEATURE_OPTIONS "-D${_vcf_FEATURE_VARIABLE}=${_set_else}")
|
||||
endif()
|
||||
set(_vcf_IS_FEATURE_NAME_ARG ON)
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
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)
|
||||
list(APPEND _vcf_FEATURE_OPTIONS "-D${_vcf_FEATURE_VAR}=ON")
|
||||
else()
|
||||
set(${_vcf_FEATURE_VAR} OFF PARENT_SCOPE)
|
||||
list(APPEND _vcf_FEATURE_OPTIONS "-D${_vcf_FEATURE_VAR}=OFF")
|
||||
endif()
|
||||
|
||||
set(_vcf_IS_FEATURE_ARG ON)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(DEFINED FEATURE_OPTIONS)
|
||||
message(WARNING "FEATURE_OPTIONS is already defined and will be overwritten.")
|
||||
if (DEFINED _vcf_FEATURES OR DEFINED _vcf_INVERTED_FEATURES)
|
||||
_check_features(_vcf_FEATURES ON OFF)
|
||||
_check_features(_vcf_INVERTED_FEATURES OFF ON)
|
||||
else()
|
||||
# Skip arguments that correspond to OUT_FEATURE_OPTIONS and its value.
|
||||
list(SUBLIST ARGN 2 -1 _vcf_ARGN)
|
||||
_check_features(_vcf_ARGN ON OFF)
|
||||
endif()
|
||||
|
||||
set(FEATURE_OPTIONS ${_vcf_FEATURE_OPTIONS} PARENT_SCOPE)
|
||||
set(${_vcf_OUT_FEATURE_OPTIONS} "${_vcf_FEATURE_OPTIONS}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
@ -8,6 +8,7 @@
|
||||
## SOURCE_PATH <${SOURCE_PATH}>
|
||||
## [PREFER_NINJA]
|
||||
## [DISABLE_PARALLEL_CONFIGURE]
|
||||
## [NO_CHARSET_FLAG]
|
||||
## [GENERATOR <"NMake Makefiles">]
|
||||
## [OPTIONS <-DUSE_THIS_IN_ALL_BUILDS=1>...]
|
||||
## [OPTIONS_RELEASE <-DOPTIMIZE=1>...]
|
||||
@ -28,6 +29,11 @@
|
||||
## Disables running the CMake configure step in parallel.
|
||||
## This is needed for libraries which write back into their source directory during configure.
|
||||
##
|
||||
## ### NO_CHARSET_FLAG
|
||||
## Disables passing `utf-8` as the default character set to `CMAKE_C_FLAGS` and `CMAKE_CXX_FLAGS`.
|
||||
##
|
||||
## This is needed for libraries that set their own source code's character set.
|
||||
##
|
||||
## ### GENERATOR
|
||||
## Specifies the precise generator to use.
|
||||
##
|
||||
|
Loading…
x
Reference in New Issue
Block a user