diff --git a/CMakeLists.txt b/CMakeLists.txt index d9632df926c..2549e3a0fb9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,7 @@ option(USE_VENDORED_PYBIND11 "Use vendored 'pybind11' Python library" ON) option(USE_VENDORED_SPDLOG "Use vendored 'spdlog' library" ON) option(USE_VENDORED_QUAZIP "Use vendored 'quazip' library" ON) option(USE_VENDORED_IGRAPH "Use vendored 'igraph' library" ON) +option(USE_VENDORED_NLOHMANN_JSON "Use vendored 'nlohmann_json' library" ON) option(BUILD_ALL_PLUGINS "Build all available plugins" OFF) option(BUILD_TESTS "Enable test builds" OFF) option(BUILD_COVERAGE "Enable code coverage build" OFF) diff --git a/cmake/detect_dependencies.cmake b/cmake/detect_dependencies.cmake index ce1dda8d011..20a19cab1c0 100644 --- a/cmake/detect_dependencies.cmake +++ b/cmake/detect_dependencies.cmake @@ -214,11 +214,21 @@ set_target_properties(subprocess::subprocess PROPERTIES # ############################### # #### nlohmann_json # ############################### -message(STATUS "using nlohmann_json from deps") -add_library(nlohmann_json::nlohmann_json INTERFACE IMPORTED) -set_target_properties(nlohmann_json::nlohmann_json PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/deps/nlohmann_json" -) +if(USE_VENDORED_NLOHMANN_JSON) + message(STATUS "using nlohmann_json from deps") + add_library(nlohmann_json::nlohmann_json INTERFACE IMPORTED) + set_target_properties(nlohmann_json::nlohmann_json PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/deps/nlohmann_json" + ) +else() + find_package(nlohmann_json REQUIRED) + if(nlohmann_json_FOUND) + get_target_property(NLOHMANN_JSON_HEADERS_DIR nlohmann_json::nlohmann_json INTERFACE_INCLUDE_DIRECTORIES) + message(STATUS "Using system's nlohmann_json headers at ${NLOHMANN_JSON_HEADERS_DIR}") + else() + message(FATAL_ERROR "nlohmann_json was not found and USE_VENDORED_NLOHMANN_JSON is OFF") + endif() +endif() # ############################### # #### Graphviz diff --git a/deps/nlohmann_json/nlohmann_json/json.hpp b/deps/nlohmann_json/nlohmann/json.hpp similarity index 100% rename from deps/nlohmann_json/nlohmann_json/json.hpp rename to deps/nlohmann_json/nlohmann/json.hpp diff --git a/plugins/graph_algorithm/CMakeLists.txt b/plugins/graph_algorithm/CMakeLists.txt index 5db5f4a6c1a..c5ddc362014 100644 --- a/plugins/graph_algorithm/CMakeLists.txt +++ b/plugins/graph_algorithm/CMakeLists.txt @@ -14,6 +14,8 @@ if(PL_GRAPH_ALGORITHM OR BUILD_ALL_PLUGINS) LINK_LIBRARIES PUBLIC ${igraph_LIBRARIES} ) -add_dependencies(graph_algorithm igraph_0_10) +if(USE_VENDORED_IGRAPH) + add_dependencies(graph_algorithm igraph_0_10) +endif() endif() diff --git a/plugins/module_identification/include/module_identification/utils/statistics.h b/plugins/module_identification/include/module_identification/utils/statistics.h index 5b52fd8cea6..fe3130f9a69 100644 --- a/plugins/module_identification/include/module_identification/utils/statistics.h +++ b/plugins/module_identification/include/module_identification/utils/statistics.h @@ -4,7 +4,7 @@ #include "module_identification/candidates/base_candidate.h" #include "module_identification/candidates/functional_candidate.h" #include "module_identification/types/candidate_types.h" -#include "nlohmann_json/json.hpp" +#include "nlohmann/json.hpp" #include #include diff --git a/plugins/netlist_preprocessing/src/netlist_preprocessing.cpp b/plugins/netlist_preprocessing/src/netlist_preprocessing.cpp index f78892c196e..1ad79725dc7 100644 --- a/plugins/netlist_preprocessing/src/netlist_preprocessing.cpp +++ b/plugins/netlist_preprocessing/src/netlist_preprocessing.cpp @@ -11,7 +11,7 @@ #include "hal_core/netlist/net.h" #include "hal_core/netlist/netlist.h" #include "hal_core/utilities/token_stream.h" -#include "nlohmann_json/json.hpp" +#include "nlohmann/json.hpp" #include "rapidjson/document.h" #include "resynthesis/resynthesis.h" #include "z3_utils/netlist_comparison.h" diff --git a/plugins/z3_utils/src/netlist_comparison.cpp b/plugins/z3_utils/src/netlist_comparison.cpp index 215839d4955..1a0aa47059d 100644 --- a/plugins/z3_utils/src/netlist_comparison.cpp +++ b/plugins/z3_utils/src/netlist_comparison.cpp @@ -8,7 +8,7 @@ #include "hal_core/netlist/net.h" #include "hal_core/netlist/netlist.h" #include "hal_core/utilities/log.h" -#include "nlohmann_json/json.hpp" +#include "nlohmann/json.hpp" #include "z3_utils/z3_utils.h" namespace hal