Issue
Hy i prepared a project on mac now i continued developing on windows.
- Project
- include
- HttpClient.h
- src
- HttpClient.cpp
- CMakeLists.txt
- CMakeLists.txt
- main.cpp
- curl-8.5.0
- ....
- include
My base CMakeLists.txt Looks like this:
cmake_minimum_required(VERSION 3.22)
project(ReadPr)
# Add the src folder to the list of directories containing source files
add_subdirectory(src)
# Add the include folder to the list of directories containing header files
include_directories(include)
# Find the curl package
find_package(CURL REQUIRED)
# Add the executable and link it with the source files, curl library
add_executable(readPr main.cpp)
# Link the executable with the target in the src directory
target_link_libraries(readPr ReadPrSrc)
# Link the executable with the curl library
target_link_libraries(readPr ${CURL_LIBRARIES})
# Include the curl and jsoncpp headers
include_directories(${CURL_INCLUDE_DIRS})
but in my header i can not find the #include <curl/curl.h>. I am confused why the same configuration works on mac but on windows not.
I also tried to make this change but it did not worked:
# Set the path to the libcurl root directory
set(CURL_ROOT "${CMAKE_SOURCE_DIR}/curl-8.5.0")
# Find the curl package
find_package(CURL REQUIRED)
can someone give me a suggestion.
Solution
@Botje Thanks for the tip I feel so silly now I change my cmake to download the lib now directly from the repo to avoid this problem for this I changed the import to this:
include(FetchContent)
FetchContent_Declare(curl
URL https://curl.se/download/curl-8.5.0.tar.gz
DOWNLOAD_EXTRACT_TIMESTAMP true
)
FetchContent_MakeAvailable(curl)
Answered By - samann Answer Checked By - Senaida (WPSolving Volunteer)