@@ -26,14 +26,21 @@ if(NOT USE_SYSTEM_CPR)
26
26
27
27
# if a system provided installed libcurl is too "new", we want to have CPR build its own
28
28
# otherwise, we want to use the system provided library
29
- # this way, we can build against a system-wide libcurl on older systems (e.g., Ubuntu focal) while allowing development on newer systems
30
- # see
31
- find_package (CURL)
32
- if (CURL_FOUND)
33
- message (STATUS "Found libcurl ${CURL_VERSION_STRING} " )
29
+ # this way, we can build against a system-wide libcurl on older systems (e.g., Ubuntu focal) while
30
+ # allowing development on newer systems
31
+ # see https://github.com/libcpr/cpr/issues/804
32
+ # note: don't use find_package(CURL), for some reason it'd cause zsync2 to link to the system libcurl in
33
+ # addition to the statically linked CPR; we just need the version
34
+ find_package (PkgConfig REQUIRED)
35
+ pkg_search_module(PKGCONFIG_CURL libcurl)
36
+ set (PKGCONFIG_CURL_FOUND ${PKGCONFIG_CURL_FOUND} PARENT_SCOPE)
37
+ set (PKGCONFIG_CURL_VERSION ${PKGCONFIG_CURL_VERSION} PARENT_SCOPE)
38
+
39
+ if (PKGCONFIG_CURL_FOUND)
40
+ message (STATUS "Found libcurl ${PKGCONFIG_CURL_VERSION} " )
34
41
35
42
if (NOT DEFINED CPR_FORCE_USE_SYSTEM_CURL)
36
- if (CURL_VERSION_STRING VERSION_LESS_EQUAL 7.80.0)
43
+ if (PKGCONFIG_CURL_VERSION VERSION_LESS_EQUAL 7.80.0)
37
44
message (STATUS "libcurl is old enough to work with CPR, so we use the system one (use -DCPR_FORCE_USE_SYSTEM_CURL=OFF to change this behavior)" )
38
45
set (CPR_FORCE_USE_SYSTEM_CURL ON )
39
46
else ()
@@ -43,6 +50,8 @@ if(NOT USE_SYSTEM_CPR)
43
50
else ()
44
51
message (WARNING "CPR_FORCE_USE_SYSTEM_CURL is set to ${CPR_FORCE_USE_SYSTEM_CURL} by the user" )
45
52
endif ()
53
+ else ()
54
+ message (WARNING "Could not find libcurl with pkg-config, relying on CPR auto-configuration" )
46
55
endif ()
47
56
48
57
include (FetchContent)
0 commit comments