# \[C++\] Configuring the CPR library in cmake

**URL:** <https://forum.codecrafters.io/t/c-configuring-the-cpr-library-in-cmake/12533>\
**Category:** Challenges\
**Tags:** challenge:git\
**Created:** [June 23, 2025, 2:37pm UTC](https://forum.codecrafters.io/t/c-configuring-the-cpr-library-in-cmake/12533 "2025-06-23T14:37:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahhmed-hassan](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/ahhmed-hassan/32/11024_2.png) [@ahhmed-hassan](https://forum.codecrafters.io/u/ahhmed-hassan)\
**Post date:** [June 23, 2025, 2:37pm UTC](https://forum.codecrafters.io/t/c-configuring-the-cpr-library-in-cmake/12533/1 "2025-06-23T14:37:55Z")

</div>

I’m stuck on Stage #(6) for clone. It is more a question about CMake itself but this is the first time I needed to make HTTP request.

I’ve tried different things related to this PR request [cpr-config.cmake for find\_package · Issue #455 · libcpr/cpr](https://github.com/libcpr/cpr/issues/455). But it always still doesn’t work.

I locally don’t run CMake as I have windows and work on .vcxproj prjects.  
So I just did vcpkg integrate install and I was already ready to work with all the libraries I added in the vcpkg.json.

Here are my (parts) of the logs from the server, :

```auto
remote: [compile] CMake Error at /vcpkg/scripts/buildsystems/vcpkg.cmake:894 (_find_package):
remote: [compile] By not providing "FindCPR.cmake" in CMAKE_MODULE_PATH this project has
remote: [compile] asked CMake to find a package configuration file provided by "CPR", but
remote: [compile] CMake did not find one.
remote: [compile]
remote: [compile] Could not find a package configuration file provided by "CPR" with any of
remote: [compile] the following names:
remote: [compile]
remote: [compile] CPRConfig.cmake
remote: [compile] cpr-config.cmake
remote: [compile]
remote: [compile] Add the installation prefix of "CPR" to CMAKE_PREFIX_PATH or set "CPR_DIR"
remote: [compile] to a directory containing one of the above files. If "CPR" provides a
remote: [compile] separate development package or SDK, be sure it has been installed.
remote: [compile] Call Stack (most recent call first):
remote: [compile] CMakeLists.txt:18 (find_package)

```

And here’s CMakeLists.txt:

```python

# Minimum required version of CMake
cmake_minimum_required(VERSION 3.20)

# Project name and settings
project(git-starter-cpp)

set(CMAKE_CXX_STANDARD 23) # Enable the C++23 standard

# Add path for custom Find modules
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})

# Set options if needed (e.g., USE_SYSTEM_GTEST)
set(USE_SYSTEM_GTEST ON CACHE BOOL "Use system-installed GTest")

# Locate dependencies
find_package(OpenSSL REQUIRED)
find_package(ZLIB REQUIRED)
find_package(CPR REQUIRED)

# Include directories provided by dependencies
include_directories(${CPR_INCLUDE_DIRS})

# Source files globbing (adjust paths as needed)
file(GLOB_RECURSE SOURCE_FILES src/*.cpp src/*.hpp)

# Define executable target and link libraries
add_executable(git ${SOURCE_FILES})
target_link_libraries(git PRIVATE OpenSSL::Crypto ZLIB::ZLIB ${CPR_LIBRARIES})

```

And also the findcpr.cmake I found here [Findcpr.cmake](https://gitlab.com/kazv/libkazv/-/blob/servant/cmake/Findcpr.cmake)

```python
find_path(cpr_INCLUDE_DIR
  NAMES cpr.h
  PATH_SUFFIXES cpr
)
find_library(cpr_LIBRARY
  NAMES cpr
  )

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(cpr
  FOUND_VAR cpr_FOUND
  REQUIRED_VARS
    cpr_LIBRARY
    cpr_INCLUDE_DIR
)
if(cpr_FOUND AND NOT TARGET cpr::cpr)
  add_library(cpr::cpr UNKNOWN IMPORTED)
  set_target_properties(cpr::cpr PROPERTIES
    IMPORTED_LOCATION "${cpr_LIBRARY}"
    INTERFACE_INCLUDE_DIRECTORIES "${cpr_INCLUDE_DIR};${cpr_INCLUDE_DIR}/.."
    )
  message(STATUS "cpr include dir: ${cpr_INCLUDE_DIR}")
endif()

```

Maybe someone that has used cpr library can help?  
Thanks in Advance.

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [June 24, 2025, 4:22pm UTC](https://forum.codecrafters.io/t/c-configuring-the-cpr-library-in-cmake/12533/4 "2025-06-24T16:22:44Z")

</div>

Hey @ahhmed-hassan, mind giving this a try?

```auto
find_package(cpr CONFIG REQUIRED)
target_link_libraries(git PRIVATE cpr::cpr)

```

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/f/f930c597e6c5370489bca57b85eac92083697beb.png)

---

<div class="post-metadata">

**Author:** ![ahhmed-hassan](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/ahhmed-hassan/32/11024_2.png) [@ahhmed-hassan](https://forum.codecrafters.io/u/ahhmed-hassan)\
**Post date:** [June 24, 2025, 5:29pm UTC](https://forum.codecrafters.io/t/c-configuring-the-cpr-library-in-cmake/12533/6 "2025-06-24T17:29:10Z")

</div>

Hi @andy1li !  
Thank your for answering.  
It is my mistake not to state that I have tried that already at first but sadly was no success and gave the exact same error output from the server.

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [June 24, 2025, 5:37pm UTC](https://forum.codecrafters.io/t/c-configuring-the-cpr-library-in-cmake/12533/7 "2025-06-24T17:37:45Z")

</div>

@ahhmed-hassan Would you mind trying again using lowercase **cpr** instead of CPR?

```auto
find_package(cpr CONFIG REQUIRED)

```

---

<div class="post-metadata">

**Author:** ![ahhmed-hassan](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/ahhmed-hassan/32/11024_2.png) [@ahhmed-hassan](https://forum.codecrafters.io/u/ahhmed-hassan)\
**Post date:** [June 24, 2025, 8:49pm UTC](https://forum.codecrafters.io/t/c-configuring-the-cpr-library-in-cmake/12533/8 "2025-06-24T20:49:25Z")

</div>

@andy1li  
Thank you for replying.  
It has finally worked!  
I would never had though that the solution would be that simple haha.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [June 29, 2025, 8:50pm UTC](https://forum.codecrafters.io/t/c-configuring-the-cpr-library-in-cmake/12533/9 "2025-06-29T20:50:07Z")

</div>

Closed on June 29, 2025, 8:50pm UTC

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.
