FetchContent does not work? #4325
Answered
by
nlohmann
taehyounpark
asked this question in
Q&A
-
Sorry if this is actually a general CMake question than the library itself. I'm trying to follow the FetchContent way to pull # nlohmann::json
include(FetchContent)
FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz)
FetchContent_MakeAvailable(json)
target_link_libraries(
queryosity_extensions
INTERFACE queryosity::queryosity
PRIVATE nlohmann_json::nlohmann_json
) But this does not allow the headers to be found. Only when I also do: target_include_directories(
queryosity_extensions
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${nlohmann_json_SOURCE_DIR}/include
) the compilation works. It was my understanding that the full library name |
Beta Was this translation helpful? Give feedback.
Answered by
nlohmann
Mar 29, 2024
Replies: 1 comment 1 reply
-
This is how I use the library in a project: cmake_minimum_required(VERSION 3.20)
project(json_test)
include(FetchContent)
FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.2/json.tar.xz)
FetchContent_MakeAvailable(json)
add_executable(json_test main.cpp)
target_link_libraries(json_test PUBLIC nlohmann_json::nlohmann_json) and then in #include <nlohmann/json.hpp> |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
taehyounpark
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is how I use the library in a project:
and then in
main.cpp