ArthurSonzogni / nlohmann_json_cmake_fetchcontent

A lightweight Release-tracking repository for nlohmann/json. Suitable for CMake fetchcontent. Automatically upgraded every weeks.
MIT License
79 stars 25 forks source link

JSON_MultipleHeaders is turned on by default, but include folder is not there #13

Closed b1f6c1c4 closed 1 year ago

b1f6c1c4 commented 1 year ago

Given the following CMakeLists.txt:

include(FetchContent)

FetchContent_Declare(json
        GIT_REPOSITORY https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent
        GIT_PROGRESS TRUE
        GIT_SHALLOW TRUE
        GIT_TAG v3.11.2)
FetchContent_MakeAvailable(json)

target_link_libraries(MineSweeperSolver PRIVATE nlohmann_json::nlohmann_json)

I saw this error:

[1/10] Building CXX object CMakeFiles/MineSweeperSolver.dir/main.cpp.o
FAILED: CMakeFiles/MineSweeperSolver.dir/main.cpp.o 
/usr/bin/c++  -I/home/b1f6c1c4/MineSweeperProb/MineSweeperSolver/cmake-build-debug/_deps/json-src/include -g -flto -fno-fat-lto-objects -march=znver3 -Wall -Wextra -Werror -Wno-parentheses -Wno-missing-field-initializers -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unknown-pragmas -Wno-sign-compare -std=gnu++23 -MD -MT CMakeFiles/MineSweeperSolver.dir/main.cpp.o -MF CMakeFiles/MineSweeperSolver.dir/main.cpp.o.d -o CMakeFiles/MineSweeperSolver.dir/main.cpp.o -c /home/b1f6c1c4/MineSweeperProb/MineSweeperSolver/main.cpp
/home/b1f6c1c4/MineSweeperProb/MineSweeperSolver/main.cpp:7:10: fatal error: nlohmann/json.hpp: No such file or directory
    7 | #include <nlohmann/json.hpp>
      |          ^~~~~~~~~~~~~~~~~~~
compilation terminated.
[9/10] Building CXX object CMakeFiles/MineSweeperSolver.dir/BinomialHelper.cpp.o
ninja: build stopped: subcommand failed.

Looking into cmake-build-debug/_deps/json-src/ I could not find the include folder.

The fix should be adding the following to CMakeLists.txt:

set(JSON_MultipleHeaders OFF)
ArthurSonzogni commented 1 year ago

It sounds like it broke when updating automatically to this version: https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent/commit/6e3045ea3cc4ae4836e68906c0ac132a861268ae

Yes, it needs to be fixed.

ArthurSonzogni commented 1 year ago

I fixed the issue!