0

Based on this question CMake cpprestsdk I tried to create a specific target from cpprestsdk source code. First, I cloned the github project into /home/user/git/cpprestsdk

Then, I created the CmakeLists.txt file

project(ProjectName) find_package(cpprestsdk CONFIG REQUIRED) target_link_libraries(ProjectName PRIVATE cpprestsdk::cpprestsdk_boost_internal) 

and the cmake command:

cmake -DCMAKE_PREFIX_PATH=/home/user/git/cpprestsdk/Release/src . 

and got the following error:

CMake Error at cpprestsdk/Release/src/cpprestsdk-config.cmake:25 (include): include could not find load file: /home/ebalbar/git/cpprestsdk/Release/src/cpprestsdk-targets.cmake Call Stack (most recent call first): CMakeLists.txt:2 (find_package) CMake Error at CMakeLists.txt:3 (target_link_libraries): Cannot specify link libraries for target "ProjectName" which is not built by this project. 

The target file can be found under /home/user/git/cpprestsdk/Release/src/CMakeFiles/Export/lib/cmake/cpprestsdk/cpprestsdk-targets.cmake

So the question is how to build cpprestsdk::cpprestsdk_boost_internal target?

Thanks in advance!

1
  • 1
    "First, I cloned the github project into /home/user/git/cpprestsdk" - Then you should built the project and install it. And CMAKE_PREFIX_PATH should contain the installation prefix which you have passed when installing the project. Only after that find_package(cpprestsdk) will work. Commented Nov 14, 2024 at 15:14

1 Answer 1

0

as @Tsyvarev pointed out first the library should be built and installed.

cmake . cmake --build . cmake --install . --prefix <install_folder> 

Then, the application CMakeList.txt should look like this:

cmake_minimum_required(VERSION 3.16) # In your project's CMakeLists.txt project(ProjectName) set(CMAKE_PREFIX_PATH "<install_folder>") find_package(cpprestsdk REQUIRED) add_library(my_target SHARED main.cpp) # Link to `cpprestsdk::cpprestsdk_openssl_internal` in your target target_link_libraries(my_target cpprestsdk::cpprestsdk_openssl_internal) 

then I could build the application with the following cmake commands:

cmake . cmake --build . 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.