cpr icon indicating copy to clipboard operation
cpr copied to clipboard

CMake `cmake install` failed

Open L-Super opened this issue 1 year ago • 4 comments

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

  • OS: Windows
  • Version: latest

L-Super avatar Aug 28 '24 15:08 L-Super

But without CLion it installs in the correct directory?

COM8 avatar Aug 28 '24 16:08 COM8

But without CLion it installs in the correct directory?

The command in bash is the same as in Clion.

L-Super avatar Aug 28 '24 16:08 L-Super

Can confirm. There is something wrong. Especially in regards to zlib. When setting -DCMAKE_BUILD_TYPE=Release it tries to install zlib from the Debug directory and vise versa. How critical is this bug to you?

COM8 avatar Sep 22 '24 16:09 COM8

Can confirm. There is something wrong. Especially in regards to zlib. When setting -DCMAKE_BUILD_TYPE=Release it tries to install zlib from the Debug directory and vise versa. How critical is this bug to you?

It will prevent me from using cmake install to install dependencies, which may later affect CI/CD automatic packaging into an executable file.

L-Super avatar Sep 27 '24 05:09 L-Super