Bug Report
- What is the issue you have?
I have nlohmann/json library added using ExternalProject_Add in CMakeLists.txt.
In my project, the <INSTALL_DIR>/include/ folder is added as the system include directories.
During compilation, I've an error of missing json_fwd.hpp included from detail/meta.cpp.
The file json_fwd.hpp is "missing" because it is located in include/nlohmann and only include/ is added to 'global' include path.
I'm using JSON_MultipleHeaders=ON flag in CMake.
- Please describe the steps to reproduce the issue. Can you provide a small but working code example?
File CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(jj)
include(ExternalProject)
ExternalProject_Add(json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG develop
INSTALL_DIR ${PROJECT_BINARY_DIR}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -DBUILD_TESTING=0 -DJSON_MultipleHeaders=ON
UPDATE_COMMAND ""
)
include_directories(SYSTEM ${PROJECT_BINARY_DIR}/include)
add_executable(jj src/test.cpp)
add_dependencies(jj json)
File src/test.cpp:
#include <nlohmann/json.hpp>
int main() {
return 0;
}
-
What is the expected behavior?
json_fwd.hpp should be visible for files in detail/ of the json library.
-
And what is the actual behavior instead?
The relative path in meta.cpp to the json_fwd.hpp doesn't allow to compile.
During compilation, I've got the following error:
In file included from /home/przemkovv/projects/sandbox/json_bug/src/test.cpp:2:
In file included from /home/przemkovv/projects/sandbox/json_bug/build/include/nlohmann/json.hpp:46:
/home/przemkovv/projects/sandbox/json_bug/build/include/nlohmann/detail/meta.hpp:9:10: fatal error: 'json_fwd.hpp' file not found
#include "json_fwd.hpp"
^~~~~~~~~~~~~~
-
Which compiler and operating system are you using? Is it a supported compiler?
Arch Linux, Clang 7.0.0
-
Did you use a released version of the library or the version from the develop branch?
develop
-
If you experience a compilation error: can you compile and run the unit tests?
Cannot compile.
Bug Report
I have nlohmann/json library added using
ExternalProject_AddinCMakeLists.txt.In my project, the
<INSTALL_DIR>/include/folder is added as the system include directories.During compilation, I've an error of missing
json_fwd.hppincluded fromdetail/meta.cpp.The file
json_fwd.hppis "missing" because it is located ininclude/nlohmannand onlyinclude/is added to 'global' include path.I'm using
JSON_MultipleHeaders=ONflag in CMake.File
CMakeLists.txtFile
src/test.cpp:What is the expected behavior?
json_fwd.hppshould be visible for files indetail/of the json library.And what is the actual behavior instead?
The relative path in
meta.cppto the json_fwd.hppdoesn't allow to compile.During compilation, I've got the following error:
Which compiler and operating system are you using? Is it a supported compiler?
Arch Linux, Clang 7.0.0
Did you use a released version of the library or the version from the
developbranch?develop
If you experience a compilation error: can you compile and run the unit tests?
Cannot compile.