libcpr / cpr

C++ Requests: Curl for People, a spiritual port of Python Requests.
https://docs.libcpr.org/
Other
6.29k stars 903 forks source link

zlib ignores --prefix/CMAKE_INSTALL_PREFIX when using cpr as external dependency #1028

Closed samueldaniel closed 4 months ago

samueldaniel commented 4 months ago

Description

I am pulling cpr into my project in what seems to be a standard manner:

set(CPR_ENABLE_SSL ON)
set(CPR_BUILD_TESTS OFF)
set(CPR_BUILD_TESTS_SSL OFF) 
include(FetchContent)
FetchContent_Declare(cpr GIT_REPOSITORY https://github.com/libcpr/cpr.git
                                             GIT_TAG 340acc5cdad624b9398827eec2832fe2fd05f966)
FetchContent_MakeAvailable(cpr)

After building the project successfully, I try to install it to some prefix:

$ cmake --install build/x86_64-linux-gnu/ --prefix /home/sam/repos/project/install

And the installation fails trying to copy libz.a to /usr/local/lib:

CMake Error at build/x86_64-linux-gnu/_deps/zlib-build/cmake_install.cmake:54 (file):
  file INSTALL cannot copy file
  "/home/sam/repos/project/build/x86_64-linux-gnu/_deps/zlib-build/libz.a"
  to "/usr/local/lib/libz.a": Permission denied.
Call Stack (most recent call first):
  build/x86_64-linux-gnu/_deps/cpr-build/cmake_install.cmake:47 (include)
  build/x86_64-linux-gnu/extern/cmake_install.cmake:47 (include)
  build/x86_64-linux-gnu/cmake_install.cmake:52 (include)

Example/How to Reproduce

Use cpr as an external dependency and try to install it (and your project) to some non-standard prefix.

Possible Fix

No response

Where did you get it from?

GitHub (branch e.g. master)

Additional Context/Your Environment

samueldaniel commented 4 months ago

This is only a problem with zlib enabled. If I set set(CURL_ZLIB OFF) then this problem does not occur.

nevermind - I cannot reproduce this

samueldaniel commented 4 months ago

This seems to be a known issue with zlib itself: