diff --git a/GeoModelJSONParser/CMakeLists.txt b/GeoModelJSONParser/CMakeLists.txt index 595d0ca3f105b9e0c837fba108bbec402a3a4117..fe03ee152c78ddf8f0ea8f178edec6e1b565529a 100644 --- a/GeoModelJSONParser/CMakeLists.txt +++ b/GeoModelJSONParser/CMakeLists.txt @@ -6,12 +6,19 @@ file( GLOB HEADERS GeoModelJSONParser/*.h ) # Create the library. add_library( GeoModelJSONParser SHARED ${HEADERS} ${SOURCES} ) -if (nlohmann_json_FOUND) - # we link to nlohmann_json only if we use a version of nlohmann_json installed through CMake; - # this is not needed if the single-header library is installed in a regular - # system include folder (e.g., '/usr/local/include') + +# If we use standalone-build of nlohmann_json parser +if( GEOMODEL_USE_BUILTIN_JSON ) + add_dependencies( GeoModelJSONParser JSON ) +endif() + +# We link to `nlohmann_json` only if we use a version of nlohmann_json installed through CMake; +# this is not needed if the single-header library is installed in a regular +# system include folder (e.g., '/usr/local/include') +if ( nlohmann_json_FOUND OR GEOMODEL_USE_BUILTIN_JSON ) target_link_libraries( GeoModelJSONParser PUBLIC nlohmann_json::nlohmann_json ) endif() + target_include_directories( GeoModelJSONParser PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> ) @@ -20,9 +27,6 @@ source_group( "src" FILES ${SOURCES} ) set_target_properties( GeoModelJSONParser PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} ) -if( GEOMODEL_USE_BUILTIN_JSON ) - add_dependencies( GeoModelJSONParser JSON ) -endif() # Install the library. install( TARGETS GeoModelJSONParser diff --git a/GeoModelJSONParser/GeoModelJSONParser/JSONHandler.h b/GeoModelJSONParser/GeoModelJSONParser/JSONHandler.h index d5e4a310c208d98fa10aa53dd70a47327880152d..fdbc05cf2d20f4c795be20cac4bea8555957e0f1 100644 --- a/GeoModelJSONParser/GeoModelJSONParser/JSONHandler.h +++ b/GeoModelJSONParser/GeoModelJSONParser/JSONHandler.h @@ -4,7 +4,7 @@ #include <map> #include <string> -#include "nlohmann/json.hpp" +#include <nlohmann/json.hpp> using nlohmann::json; diff --git a/GeoModelJSONParser/src/handlerStore.cxx b/GeoModelJSONParser/src/handlerStore.cxx index bf609211df0be53dceda57436b1dd3d4b1ca56e6..d3e3693387a7ed9139e2626392939622f3afd70d 100644 --- a/GeoModelJSONParser/src/handlerStore.cxx +++ b/GeoModelJSONParser/src/handlerStore.cxx @@ -1,13 +1,13 @@ #include "GeoModelJSONParser/handlerStore.h" #include "GeoModelJSONParser/JSONHandler.h" - -handlerStore* handlerStore::getHandlerStore() + +handlerStore* handlerStore::getHandlerStore() { static handlerStore *theStore=new handlerStore(); return theStore; } -void handlerStore::registerHandler(JSONHandler* h) +void handlerStore::registerHandler(JSONHandler* h) { std::cout<<"registering JSONHandler "<<h->name()<<std::endl; store[h->name()]=h; @@ -20,7 +20,7 @@ JSONHandler* handlerStore::getHandler(std::string name) std::cout<<" JSONHandler "<<name<<" not found in store!!"<<std::endl; return 0; } - + } void handlerStore::listHandlers() { diff --git a/cmake/SetupJSON.cmake b/cmake/SetupJSON.cmake index 6e77d8a70fa6b5c51770ab4117dddd1539217b1c..359a92851721d6727c36b59ba66d1a02d6dc8ecc 100644 --- a/cmake/SetupJSON.cmake +++ b/cmake/SetupJSON.cmake @@ -19,6 +19,7 @@ if( GEOMODEL_USE_BUILTIN_JSON ) set( nlohmann_json_INCLUDE_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/JSONInstall/${CMAKE_INSTALL_INCLUDEDIR}" ) set( nlohmann_json_INCLUDE_DIRS "${nlohmann_json_INCLUDE_DIR}" ) + message(STATUS "Installing the built-in 'nlohmann_json' in: ${nlohmann_json_INCLUDE_DIR}") # Create the include directory already, otherwise CMake refuses to # create the imported target.