Skip to content

Commit 3e287b3

Browse files
authored
Provide a CMake option to disable C++ exceptions (#1580)
This allows disabling the use of C++ exceptions at CMake configure time. The value is encoded in the generated httplibTargets.cmake file and will be used by CMake projects that import it.
1 parent 4f33637 commit 3e287b3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ string(REGEX MATCH "([0-9]+\\.?)+" _httplib_version "${_raw_version_string}")
7575

7676
project(httplib VERSION ${_httplib_version} LANGUAGES CXX)
7777

78+
# Lets you disable C++ exception during CMake configure time.
79+
# The value is used in the install CMake config file.
80+
option(HTTPLIB_NO_EXCEPTIONS "Disable the use of C++ exceptions" OFF)
81+
7882
# Change as needed to set an OpenSSL minimum version.
7983
# This is used in the installed Cmake config file.
8084
set(_HTTPLIB_OPENSSL_MIN_VER "1.1.1")
@@ -229,6 +233,7 @@ target_link_libraries(${PROJECT_NAME} ${_INTERFACE_OR_PUBLIC}
229233

230234
# Set the definitions to enable optional features
231235
target_compile_definitions(${PROJECT_NAME} ${_INTERFACE_OR_PUBLIC}
236+
$<$<BOOL:${HTTPLIB_NO_EXCEPTIONS}>:CPPHTTPLIB_NO_EXCEPTIONS>
232237
$<$<BOOL:${HTTPLIB_IS_USING_BROTLI}>:CPPHTTPLIB_BROTLI_SUPPORT>
233238
$<$<BOOL:${HTTPLIB_IS_USING_ZLIB}>:CPPHTTPLIB_ZLIB_SUPPORT>
234239
$<$<BOOL:${HTTPLIB_IS_USING_OPENSSL}>:CPPHTTPLIB_OPENSSL_SUPPORT>

0 commit comments

Comments
 (0)