|
9 | 9 | * HTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN (default on) |
10 | 10 | * HTTPLIB_REQUIRE_BROTLI (default off) |
11 | 11 | * HTTPLIB_COMPILE (default off) |
| 12 | + * HTTPLIB_INSTALL (default on) |
12 | 13 | * HTTPLIB_TEST (default off) |
13 | 14 | * BROTLI_USE_STATIC_LIBS - tells Cmake to use the static Brotli libs (only works if you have them installed). |
14 | 15 | * OPENSSL_USE_STATIC_LIBS - tells Cmake to use the static OpenSSL libs (only works if you have them installed). |
@@ -87,6 +88,8 @@ option(HTTPLIB_USE_OPENSSL_IF_AVAILABLE "Uses OpenSSL (if available) to enable H |
87 | 88 | option(HTTPLIB_USE_ZLIB_IF_AVAILABLE "Uses ZLIB (if available) to enable Zlib compression support." ON) |
88 | 89 | # Lets you compile the program as a regular library instead of header-only |
89 | 90 | option(HTTPLIB_COMPILE "If ON, uses a Python script to split the header into a compilable header & source file (requires Python v3)." OFF) |
| 91 | +# Lets you disable the installation (useful when fetched from another CMake project) |
| 92 | +option(HTTPLIB_INSTALL "Enables the installation target" ON) |
90 | 93 | # Just setting this variable here for people building in-tree |
91 | 94 | if(HTTPLIB_COMPILE) |
92 | 95 | set(HTTPLIB_IS_COMPILED TRUE) |
@@ -262,31 +265,33 @@ else() |
262 | 265 | ) |
263 | 266 | endif() |
264 | 267 |
|
265 | | -# Creates the export httplibTargets.cmake |
266 | | -# This is strictly what holds compilation requirements |
267 | | -# and linkage information (doesn't find deps though). |
268 | | -install(TARGETS ${PROJECT_NAME} |
269 | | - EXPORT httplibTargets |
270 | | -) |
| 268 | +if(HTTPLIB_INSTALL) |
| 269 | + # Creates the export httplibTargets.cmake |
| 270 | + # This is strictly what holds compilation requirements |
| 271 | + # and linkage information (doesn't find deps though). |
| 272 | + install(TARGETS ${PROJECT_NAME} |
| 273 | + EXPORT httplibTargets |
| 274 | + ) |
271 | 275 |
|
272 | | -install(FILES "${_httplib_build_includedir}/httplib.h" TYPE INCLUDE) |
| 276 | + install(FILES "${_httplib_build_includedir}/httplib.h" TYPE INCLUDE) |
273 | 277 |
|
274 | | -install(FILES |
| 278 | + install(FILES |
275 | 279 | "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" |
276 | 280 | "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" |
277 | 281 | # Install it so it can be used later by the httplibConfig.cmake file. |
278 | 282 | # Put it in the same dir as our config file instead of a global path so we don't potentially stomp on other packages. |
279 | 283 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindBrotli.cmake" |
280 | | - DESTINATION ${_TARGET_INSTALL_CMAKEDIR} |
281 | | -) |
| 284 | + DESTINATION ${_TARGET_INSTALL_CMAKEDIR} |
| 285 | + ) |
282 | 286 |
|
283 | | -# NOTE: This path changes depending on if it's on Windows or Linux |
284 | | -install(EXPORT httplibTargets |
285 | | - # Puts the targets into the httplib namespace |
286 | | - # So this makes httplib::httplib linkable after doing find_package(httplib) |
287 | | - NAMESPACE ${PROJECT_NAME}:: |
288 | | - DESTINATION ${_TARGET_INSTALL_CMAKEDIR} |
289 | | -) |
| 287 | + # NOTE: This path changes depending on if it's on Windows or Linux |
| 288 | + install(EXPORT httplibTargets |
| 289 | + # Puts the targets into the httplib namespace |
| 290 | + # So this makes httplib::httplib linkable after doing find_package(httplib) |
| 291 | + NAMESPACE ${PROJECT_NAME}:: |
| 292 | + DESTINATION ${_TARGET_INSTALL_CMAKEDIR} |
| 293 | + ) |
| 294 | +endif() |
290 | 295 |
|
291 | 296 | if(HTTPLIB_TEST) |
292 | 297 | include(CTest) |
|
0 commit comments