3 The latest version of this document lives in the [vcpkg repo](https://github.com/Microsoft/vcpkg/blob/master/docs/maintainers/vcpkg_check_features.md).
4 Check if one or more features are a part of a package installation.
8 OUT_FEATURE_OPTIONS <out-var>
11 [<feature-name> <feature-var>]...
14 [<feature-name> <feature-var>]...
19 The `<out-var>` should be set to `FEATURE_OPTIONS` by convention.
21 `vcpkg_check_features()` will:
23 - for each `<feature-name>` passed in `FEATURES`:
24 - if the feature is set, add `-D<feature-var>=ON` to `<out-var>`,
25 and set `<prefix>_<feature-var>` to ON.
26 - if the feature is not set, add `-D<feature-var>=OFF` to `<out-var>`,
27 and set `<prefix>_<feature-var>` to OFF.
28 - for each `<feature-name>` passed in `INVERTED_FEATURES`:
29 - if the feature is set, add `-D<feature-var>=OFF` to `<out-var>`,
30 and set `<prefix>_<feature-var>` to OFF.
31 - if the feature is not set, add `-D<feature-var>=ON` to `<out-var>`,
32 and set `<prefix>_<feature-var>` to ON.
34 If `<prefix>` is not passed, then the feature vars set are simply `<feature-var>`,
37 If `INVERTED_FEATURES` is not passed, then the `FEATURES` keyword is optional.
38 This behavior is deprecated.
40 If the same `<feature-var>` is passed multiple times,
41 then `vcpkg_check_features` will cause a fatal error,
46 ### Example 1: Regular features
49 $ ./vcpkg install mimalloc[asm,secure]
51 # ports/mimalloc/portfile.cmake
52 vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
59 vcpkg_configure_cmake(
60 SOURCE_PATH ${SOURCE_PATH}
63 # Expands to "-DMI_SEE_ASM=ON;-DMI_OVERRIDE=OFF;-DMI_SECURE=ON"
68 ### Example 2: Inverted features
71 $ ./vcpkg install cpprestsdk[websockets]
73 # ports/cpprestsdk/portfile.cmake
76 brotli CPPREST_EXCLUDE_BROTLI
77 websockets CPPREST_EXCLUDE_WEBSOCKETS
80 vcpkg_configure_cmake(
81 SOURCE_PATH ${SOURCE_PATH}
84 # Expands to "-DCPPREST_EXCLUDE_BROTLI=ON;-DCPPREST_EXCLUDE_WEBSOCKETS=OFF"
89 ### Example 3: Set multiple options for same feature
92 $ ./vcpkg install pcl[cuda]
94 # ports/pcl/portfile.cmake
102 vcpkg_configure_cmake(
103 SOURCE_PATH ${SOURCE_PATH}
106 # Expands to "-DWITH_CUDA=ON;-DBUILD_CUDA=ON;-DBUILD_GPU=ON"
111 ### Example 4: Use regular and inverted features
114 $ ./vcpkg install rocksdb[tbb]
116 # ports/rocksdb/portfile.cmake
117 vcpkg_check_features(
121 tbb ROCKSDB_IGNORE_PACKAGE_TBB
124 vcpkg_configure_cmake(
125 SOURCE_PATH ${SOURCE_PATH}
128 # Expands to "-DWITH_TBB=ON;-DROCKSDB_IGNORE_PACKAGE_TBB=OFF"
133 ## Examples in portfiles
135 * [cpprestsdk](https://github.com/microsoft/vcpkg/blob/master/ports/cpprestsdk/portfile.cmake)
136 * [pcl](https://github.com/microsoft/vcpkg/blob/master/ports/pcl/portfile.cmake)
137 * [rocksdb](https://github.com/microsoft/vcpkg/blob/master/ports/rocksdb/portfile.cmake)
140 [scripts/cmake/vcpkg\_check\_features.cmake](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_check_features.cmake)