Skip to content

Commit 6bc4371

Browse files
committed
feat cmake: fix CURL from CPM + installed libnghttp2 configuration
commit_hash:a451be0a100297156566d4faf581e9ed70e60d43
1 parent 3d92690 commit 6bc4371

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

cmake/SetupCURL.cmake

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ if(NOT USERVER_FORCE_DOWNLOAD_CURL)
3333
message(
3434
FATAL_ERROR
3535
"libcurl versions from 7.88.0 to 8.1.2 may crash on HTTP/2 "
36-
"requests and thus are unsupported, upgrade or turn on " "USERVER_DOWNLOAD_PACKAGE_CURL"
36+
"requests and thus are unsupported, upgrade or turn on USERVER_DOWNLOAD_PACKAGE_CURL"
3737
)
3838
endif()
3939
else()
@@ -42,9 +42,15 @@ if(NOT USERVER_FORCE_DOWNLOAD_CURL)
4242
endif()
4343
endif()
4444

45-
set(CURL_LTO_OPTION)
45+
set(CURL_EXTRA_OPTIONS)
4646
if(USERVER_LTO)
47-
set(CURL_LTO_OPTION "CURL_LTO ON")
47+
list(APPEND CURL_EXTRA_OPTIONS "CURL_LTO ON")
48+
endif()
49+
50+
find_package(libnghttp2 REQUIRED)
51+
52+
if(CPM_PACKAGE_libnghttp2_SOURCE_DIR)
53+
list(APPEND CURL_EXTRA_OPTIONS "NGHTTP2_INCLUDE_DIR ${NGHTTP2_INCLUDE_DIR}" "NGHTTP2_LIBRARY ${NGHTTP2_LIBRARY}")
4854
endif()
4955

5056
include(DownloadUsingCPM)
@@ -55,8 +61,7 @@ cpmaddpackage(
5561
GIT_TAG curl-7_81_0
5662
GIT_SHALLOW TRUE
5763
OPTIONS "BUILD_CURL_EXE OFF" "BUILD_SHARED_LIBS OFF" "CURL_DISABLE_TESTS ON" "CURL_DISABLE_LDAP ON"
58-
"HAVE_DLOPEN TRUE" "USE_NGHTTP2 TRUE"
59-
"NGHTTP2_INCLUDE_DIR ${NGHTTP2_INCLUDE_DIR}" "NGHTTP2_LIBRARY ${NGHTTP2_LIBRARY}" ${CURL_LTO_OPTION}
64+
"HAVE_DLOPEN TRUE" "USE_NGHTTP2 TRUE" ${CURL_EXTRA_OPTIONS}
6065
)
6166

6267
mark_targets_as_system("${CURL_SOURCE_DIR}")

0 commit comments

Comments
 (0)