Comments (2)
@LunarWatcher confirmed. Thanks for reporting!
from cpr.
I ran into a variant of this problem independently with liblzma in a different project. That patch was more complex because libarchive overrides the CMAKE_MODULE_PATH
; curl does not, which means overriding FindZLIB.cmake
is a lot more easy. Made a quick try at making the same general approach work:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 66a064b..0b9adaf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -205,7 +205,7 @@ else()
# -DCURL_ZLIB=OFF
# * from CMake script:
if (CURL_ZLIB OR CURL_ZLIB STREQUAL AUTO OR NOT DEFINED CACHE{CURL_ZLIB})
- include(cmake/zlib_external.cmake)
+ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/zlib")
endif()
if (CPR_ENABLE_CURL_HTTP_ONLY)
diff --git a/cmake/zlib_external.cmake b/cmake/zlib/FindZLIB.cmake
similarity index 74%
rename from cmake/zlib_external.cmake
rename to cmake/zlib/FindZLIB.cmake
index 1a8eea0..e2f389f 100644
--- a/cmake/zlib_external.cmake
+++ b/cmake/zlib/FindZLIB.cmake
@@ -20,3 +20,13 @@ if(WIN32 AND BUILD_SHARED_LIBS)
set_target_properties(zlib PROPERTIES DEBUG_POSTFIX "")
set_target_properties(zlib PROPERTIES SUFFIX ".dll")
endif()
+
+# Required to force in a CMake >3.4-compatible ZLIB::ZLIB target
+add_library(ZLIB::ZLIB ALIAS zlib)
+
+# Required for compatibility with the built-in FindZLIB
+set(ZLIB_FOUND TRUE)
+set(ZLIB_INCLUDE_DIRS ${zlib_SOURCE_DIR})
+set(ZLIB_LIBRARY zlib)
+set(ZLIB_LIBARARIES ${ZLIB_LIBARY})
+
Note that the subfolder isn't required, it was just a quick hack to avoid forcing an external zlib on dependencies by scoping it outside the default CMAKE_MODULE_PATH
. There's probably more stuff that could be done here with respecting system dependencies if enabled, but that is a problem for later.
Unfortunately, it doesn't work because
CMake Error in build/_deps/curl-src/lib/CMakeLists.txt:
export called with target "libcurl_shared" which requires target "zlib"
that is not in any export set.
A couple very quick tries with a separate EXPORT
target failed (most likely because I have no idea what I'm doing when it comes to install
). There's probably a trick to it that I'll try looking at Later:tm:, but me and install have never gotten along, so it'll have to be when I have more time to kill. I'm leaving this here in case someone else wants to poke at it in the meanwhile
This does make it correctly find the targets at least. Compiling is still blocked by install()
from cpr.
Related Issues (20)
- put cpr into a cmake project and error while loading shared libraries: libinih.so: cannot open shared object file: No such file or directory HOT 1
- Cmake cache generation fails. HOT 1
- Response.GetCertInfos() is not const HOT 2
- WriteCallback should take a string_view as argument instead of a std::string to avoid a copy HOT 2
- install cpr, but the dependencies of cpr (curl) can not be installed to the correct path HOT 2
- can cpr set keepalive writetimeout readtimeout when sending a post request? HOT 5
- Set propper runtime library for use in msvc project HOT 5
- C++20 ixx Module | unresolved external symbol _Cnd_timedwait_for HOT 7
- Fully featured Url parser HOT 1
- When is the time for threadpool creation? HOT 2
- Resolving linker errors with nuget package? HOT 1
- Build failure: `httpServer.cpp: error: overflow in conversion from 'long long int' to 'time_t' {aka 'long int'} changes value from '3905119080' to '-389848216' [-Werror=overflow]` HOT 2
- Some tests fail on PowerPC [84% tests passed, 4 tests failed out of 25] HOT 10
- Build failure on macOS 10.15: `error: no viable constructor or deduction guide for deduction of template arguments of 'function'` HOT 1
- Automatically manage cookies like c # CookieContainer
- cpr::ProgressCallback in combination with cpr::Download has the values of up- and download switched HOT 1
- libcpr static build option HOT 4
- Can't use CPR in my Visual Studio project HOT 4
- Response.status_code is 0 and response.text is empty for some of my users
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cpr.