cpr icon indicating copy to clipboard operation
cpr copied to clipboard

Can't build target with CMake when cpr compiled to static library

Open Cornpop456 opened this issue 1 year ago • 1 comments

Description

I compiled cpr statically as was explained in README

git clone https://github.com/libcpr/cpr.git
cd cpr && mkdir build && cd build
cmake .. -DCPR_USE_SYSTEM_CURL=ON -DBUILD_SHARED_LIBS=OFF
cmake --build . --parallel
sudo cmake --install .

And when i tried to build my program i had the following error in terminal

2024-10-14_18-47-51

My cmakefile 2024-10-14_18-48-28

And that problem was not occurred when i compiled cpr as a shared library

Example/How to Reproduce

Install cpr as a static library Add to cmakefile

find_package(cpr REQUIRED)
target_link_libraries(main PRIVATE  cpr::cpr)

Possible Fix

I could fix it only when add next line to cmakefile find_package(OpenSSL REQUIRED)

Where did you get it from?

GitHub (branch e.g. master)

Additional Context/Your Environment

  • OS: Windows 11 (wsl 2 ubuntu 24.04)
  • Version: 1.11.0

Cornpop456 avatar Oct 14 '24 16:10 Cornpop456

@Cornpop456 Without looking too deep into it, I guess our cpr-config.cmake is not correct. It perhaps should include the find_package(OpenSSL REQUIRED) if cpr was build with OpenSSL enabled.

Sadly I won't have too much time this week to further investigate this.

COM8 avatar Oct 14 '24 17:10 COM8