我在 mac 上准备了一个项目,现在我继续在 windows 上开发。
我的项目有这样的结构:
我的基础 CMakeLists.txt 看起来像这样:
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})
但在我的标题中我找不到#include
我也尝试过进行此更改,但没有成功:
# 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)
有人可以给我建议吗。
@Botje 感谢您的提示,我现在感觉很傻,我更改我的 cmake 现在直接从存储库下载库以避免此问题,为此我将导入更改为:
include(FetchContent)
FetchContent_Declare(curl
URL https://curl.se/download/curl-8.5.0.tar.gz
DOWNLOAD_EXTRACT_TIMESTAMP true
)
FetchContent_MakeAvailable(curl)