diff --git a/GeoModelJSONParser/CMakeLists.txt b/GeoModelJSONParser/CMakeLists.txt index 03f7a90fbcab87520a3540695df10b905b087ac1..595d0ca3f105b9e0c837fba108bbec402a3a4117 100644 --- a/GeoModelJSONParser/CMakeLists.txt +++ b/GeoModelJSONParser/CMakeLists.txt @@ -6,7 +6,12 @@ file( GLOB HEADERS GeoModelJSONParser/*.h ) # Create the library. add_library( GeoModelJSONParser SHARED ${HEADERS} ${SOURCES} ) -target_link_libraries( GeoModelJSONParser PUBLIC nlohmann_json::nlohmann_json ) +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') + 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}> ) diff --git a/cmake/SetupJSON.cmake b/cmake/SetupJSON.cmake index 3bd3539dc2f18fc31bf5f1ade670f004c6f8d3b1..6e77d8a70fa6b5c51770ab4117dddd1539217b1c 100644 --- a/cmake/SetupJSON.cmake +++ b/cmake/SetupJSON.cmake @@ -13,7 +13,7 @@ option( GEOMODEL_USE_BUILTIN_JSON if( GEOMODEL_USE_BUILTIN_JSON ) # Tell the user what's happening. - message( STATUS "Building nlohmann_json as part of the project" ) + message( STATUS "'GEOMODEL_USE_BUILTIN_JSON' was set to 'true' ==> Building nlohmann_json as part of the project" ) # The include directory and library that will be produced. set( nlohmann_json_INCLUDE_DIR @@ -50,6 +50,9 @@ if( GEOMODEL_USE_BUILTIN_JSON ) else() # Just find an existing installation of nlohmann_json. - find_package( nlohmann_json ) + find_package( nlohmann_json QUIET) + if( NOT nlohmann_json_FOUND ) + message(STATUS "WARNING! 'nlohmann_json' was not found by CMake!! However, if you installed this single-header library in a standard system include dir (e.g., '/usr/local/include'), I will be able to use it.") + endif() endif()