Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use forward decls for nlohmann/json types. #9278

Merged
merged 6 commits into from
Nov 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions builtins/nlohmann/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,10 @@ add_custom_command(
COMMENT "Copying nlohmann/json.hpp header to ${CMAKE_BINARY_DIR}/include"
DEPENDS ${CMAKE_SOURCE_DIR}/builtins/nlohmann/json.hpp)

add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/include/nlohmann/json_fwd.hpp
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/builtins/nlohmann/json_fwd.hpp ${CMAKE_BINARY_DIR}/include/nlohmann/json_fwd.hpp
COMMENT "Copying nlohmann/json_fwd.hpp header to ${CMAKE_BINARY_DIR}/include"
DEPENDS ${CMAKE_SOURCE_DIR}/builtins/nlohmann/json_fwd.hpp)

add_custom_target(builtin_nlohmann_json_incl
DEPENDS ${CMAKE_BINARY_DIR}/include/nlohmann/json.hpp ${CMAKE_BINARY_DIR}/include/nlohmann/json_fwd.hpp)
add_custom_target(builtin_nlohmann_json_incl DEPENDS ${CMAKE_BINARY_DIR}/include/nlohmann/json.hpp)

set_property(GLOBAL APPEND PROPERTY ROOT_HEADER_TARGETS builtin_nlohmann_json_incl)

install(FILES ${CMAKE_SOURCE_DIR}/builtins/nlohmann/json.hpp ${CMAKE_SOURCE_DIR}/builtins/nlohmann/json_fwd.hpp
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nlohmann/)
install(FILES ${CMAKE_SOURCE_DIR}/builtins/nlohmann/json.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nlohmann/)


78 changes: 0 additions & 78 deletions builtins/nlohmann/json_fwd.hpp

This file was deleted.

6 changes: 3 additions & 3 deletions cmake/modules/SearchInstalledSoftware.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ if(NOT builtin_nlohmannjson)
else()
find_package(nlohmann_json QUIET)
if(nlohmann_json_FOUND)
get_target_property(_nlohmann_json_inlc nlohmann_json::nlohmann_json INTERFACE_INCLUDE_DIRECTORIES)
message(STATUS "Found nlohmann/json.hpp in ${_nlohmann_json_inlc} (found version ${nlohmann_json_VERSION})")
get_target_property(_nlohmann_json_incl nlohmann_json::nlohmann_json INTERFACE_INCLUDE_DIRECTORIES)
message(STATUS "Found nlohmann/json.hpp in ${_nlohmann_json_incl} (found version ${nlohmann_json_VERSION})")
else()
message(STATUS "nlohmann/json.hpp not found. Switching on builtin_nlohmannjson option")
set(builtin_nlohmannjson ON CACHE BOOL "Enabled because nlohmann/json.hpp not found" FORCE)
Expand Down Expand Up @@ -965,7 +965,7 @@ if(xrootd AND NOT builtin_xrootd)
if(NOT XROOTD_FOUND)
if(fail-on-missing)
message(FATAL_ERROR "XROOTD not found. Set environment variable XRDSYS to point to your XROOTD installation, "
"or inlcude the installation of XROOTD in the CMAKE_PREFIX_PATH. "
"or include the installation of XROOTD in the CMAKE_PREFIX_PATH. "
"Alternatively, you can also enable the option 'builtin_xrootd' to build XROOTD internally")
else()
message(STATUS "XROOTD not found, enabling 'builtin_xrootd' option")
Expand Down
4 changes: 1 addition & 3 deletions core/clingutils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ set(clinginclude ${CMAKE_SOURCE_DIR}/interpreter/cling/include)

set(custom_modulemaps)
if (runtime_cxxmodules)
set(custom_modulemaps boost.modulemap tinyxml2.modulemap cuda.modulemap
module.modulemap.build
json.modulemap)
set(custom_modulemaps boost.modulemap tinyxml2.modulemap cuda.modulemap module.modulemap.build)
# FIXME: We should install vc.modulemap only when Vc is found (Vc_FOUND) but
# some systems install it under /usr/include/Vc/Vc which allows rootcling to
# discover it and assert that the modulemap is not found.
Expand Down
17 changes: 0 additions & 17 deletions graf3d/eve7/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ ROOT_STANDARD_LIBRARY_PACKAGE(ROOTEve
src/REveViewer.cxx
src/REveVSD.cxx
src/REveVSDStructs.cxx
DICTIONARY_OPTIONS
-mByproduct Json
DEPENDENCIES
Core
Geom
Expand All @@ -138,23 +136,8 @@ ROOT_STANDARD_LIBRARY_PACKAGE(ROOTEve

if(builtin_nlohmannjson)
target_include_directories(ROOTEve PRIVATE ${CMAKE_SOURCE_DIR}/builtins)
target_compile_definitions(ROOTEve INTERFACE NLOHMANN_JSON_PROVIDES_FWD_HPP)
else()
target_link_libraries(ROOTEve PUBLIC nlohmann_json::nlohmann_json)

get_target_property(inc_dirs nlohmann_json::nlohmann_json INTERFACE_INCLUDE_DIRECTORIES)
foreach(dir ${inc_dirs})
if(EXISTS "${dir}/nlohmann/json_fwd.hpp")
set(found_fwd true)
endif()
endforeach()

if(found_fwd)
target_compile_definitions(ROOTEve INTERFACE NLOHMANN_JSON_PROVIDES_FWD_HPP)
else()
message("-- missing nlohmann/json_fwd.hpp required by eve7")
endif()

endif()

# this is required for glew
Expand Down
22 changes: 16 additions & 6 deletions graf3d/eve7/inc/ROOT/REveElement.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,26 @@
#include <ROOT/REveVector.hxx>
#include <ROOT/REveProjectionBases.hxx>

#include <map>
#include <memory>

#ifdef NLOHMANN_JSON_PROVIDES_FWD_HPP
#include <nlohmann/json_fwd.hpp>
#else
#include <nlohmann/json.hpp>
#endif

class TGeoMatrix;

namespace nlohmann {
template<typename T, typename SFINAE>
struct adl_serializer;

template <template <typename U, typename V, typename... Args> class ObjectType,
template <typename U, typename... Args> class ArrayType, class StringType, class BooleanType,
class NumberIntegerType, class NumberUnsignedType, class NumberFloatType,
template <typename U> class AllocatorType, template <typename T, typename SFINAE = void> class JSONSerializer,
class BinaryType>
class basic_json;

using json = basic_json<std::map, std::vector, std::string, bool, std::int64_t, std::uint64_t, double, std::allocator,
adl_serializer, std::vector<std::uint8_t>>;
} // namespace nlohmann

namespace ROOT {
namespace Experimental {

Expand Down
2 changes: 2 additions & 0 deletions graf3d/eve7/src/REveViewer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <ROOT/REveManager.hxx>
#include <ROOT/REveSelection.hxx>

#include <nlohmann/json.hpp>

using namespace ROOT::Experimental;
namespace REX = ROOT::Experimental;

Expand Down
4 changes: 0 additions & 4 deletions interpreter/cling/include/cling/json.modulemap

This file was deleted.

6 changes: 0 additions & 6 deletions interpreter/cling/lib/Interpreter/CIFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,6 @@ namespace {
llvm::SmallString<256> tinyxml2IncLoc(getIncludePathForHeader(HS, "tinyxml2.h"));
llvm::SmallString<256> cudaIncLoc(getIncludePathForHeader(HS, "cuda.h"));
llvm::SmallString<256> vcVcIncLoc(getIncludePathForHeader(HS, "Vc/Vc"));
llvm::SmallString<256> jsonIncLoc(getIncludePathForHeader(HS, "nlohmann/json.hpp"));
llvm::SmallString<256> clingIncLoc(getIncludePathForHeader(HS,
"cling/Interpreter/RuntimeUniverse.h"));

Expand Down Expand Up @@ -706,11 +705,6 @@ namespace {
clingIncLoc.str(), MOverlay,
/*RegisterModuleMap=*/ true,
/*AllowModulemapOverride=*/ false);
if (!jsonIncLoc.empty())
maybeAppendOverlayEntry(jsonIncLoc.str(), "json.modulemap",
clingIncLoc.str(), MOverlay,
/*RegisterModuleMap=*/ true,
/*AllowModulemapOverride=*/ false);
if (!boostIncLoc.empty()) {
// Add the modulemap in the include/boost folder not in include.
llvm::sys::path::append(boostIncLoc, "boost");
Expand Down