libcpr / cpr

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

CMake `cmake install` failed #1103

Open L-Super opened 2 weeks ago

L-Super commented 2 weeks ago

Description

When I install cpr library by IDE, it was wrong. cmake install output message:

[0/1] Install the project...
CMake Error at _deps/zlib-build/cmake_install.cmake:41 (file):
  file cannot create directory: C:/Program Files (x86)/FLowD/lib.  Maybe need
  administrative privileges.
Call Stack (most recent call first):
  _deps/cpr-build/cmake_install.cmake:42 (include)
  src/cmake_install.cmake:62 (include)
  cmake_install.cmake:42 (include)

-- Install configuration: "Debug"
FAILED: CMakeFiles/install.util 
C:\WINDOWS\system32\cmd.exe /C "cd /D F:\Code\CppProjects\FlowD\cmake-build-debug && "D:\Program Files\JetBrains\CLion 2023.3.4\bin\cmake\win\x64\bin\cmake.exe" -P cmake_install.cmake"
ninja: build stopped: subcommand failed.

It seems to be installed by default on the C drive, but my CMakeLists.txt is:

if(WIN32) # Install dlls in the same directory as the executable on Windows
    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/src)
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/src)
endif()

include(FetchContent)
FetchContent_Declare(cpr GIT_REPOSITORY https://github.com/libcpr/cpr.git
        GIT_TAG aa581c9d8060b2502707ad96a04f4829cc524fcb)
FetchContent_MakeAvailable(cpr)

target_link_libraries(${PROJECT_NAME} PRIVATE
        Qt${QT_VERSION_MAJOR}::Core
        Qt${QT_VERSION_MAJOR}::Gui
        Qt${QT_VERSION_MAJOR}::Widgets
        cpr::cpr

)

The same as https://github.com/libcpr/example-cmake-fetch-content/blob/a733fb21fda0f17051fa319c4075649823f04226/CMakeLists.txt#L25-L28

Example/How to Reproduce

  1. CLion IDE
  2. Build - Install

Possible Fix

No response

Where did you get it from?

GitHub (branch e.g. master)

Additional Context/Your Environment

COM8 commented 2 weeks ago

But without CLion it installs in the correct directory?

L-Super commented 2 weeks ago

But without CLion it installs in the correct directory?

The command in bash is the same as in Clion.