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. 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, :
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:
# 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
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.