diff --git a/CMakeLists.txt b/CMakeLists.txt index 8cc6c44d14cae837607dd3e25cc6ab2d2a68972d..1d59c11d2b9fbb1ab80207c90457607b261cf2a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ project( "GeoModel" VERSION 1.0.0 LANGUAGES CXX ) # === Project wide setup === -# Make the module directory visible to CMake. +# Make the 'cmake' module directory visible to CMake. list( APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ) # Define color codes for CMake messages include( cmake_colors_defs ) @@ -21,7 +21,9 @@ include( BuildType ) include( PrintBuildInfo ) # === Externally provided content === -add_subdirectory(dependencies) +# Make the 'dependencies' module directory visible to CMake. +list( APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/dependencies ) +include(Dependencies) # === Main targets built by this project === diff --git a/GeoModelTools/CMakeLists.txt b/GeoModelTools/CMakeLists.txt index b54f5613a8ab31dcd9d5bea3f6e79aeb59f11503..659797c1c86a05d2be816fae559e3a23fd00080a 100644 --- a/GeoModelTools/CMakeLists.txt +++ b/GeoModelTools/CMakeLists.txt @@ -1,7 +1,6 @@ # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration # Set up the project. -# cmake_minimum_required( VERSION 3.1 ) project( "GeoModelTools" VERSION 4.0.0 LANGUAGES CXX ) # Set default build options. @@ -9,19 +8,9 @@ set( CMAKE_BUILD_TYPE "Release" CACHE STRING "CMake build mode to use" ) set( CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard used for the build" ) set( CMAKE_CXX_EXTENSIONS FALSE CACHE BOOL "(Dis)allow using GNU extensions" ) -# # Make the module directory visible to CMake. +# Make the module directory visible to CMake. list( APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ) # -# # Use the GNU install directory names. -# include( GNUInstallDirs ) -# -# # Set up the "optional" dependencies. -# include( SetupXercesC ) -# include( SetupJSON ) -# -# # Find the externals needed by the project. -# find_package( GeoModelCore 3.2.0 REQUIRED ) -# find_package( GeoModelIO 3.2.0 REQUIRED ) find_package( XercesC ) # Set up the build of the libraries of the project. diff --git a/GeoModelTools/GeoModelJSONParser/CMakeLists.txt b/GeoModelTools/GeoModelJSONParser/CMakeLists.txt index 479bc0de16e36c4c0933a66bd44b56ccf0d7d995..140b8418f641e229428250b1caaf4dd27f61bb45 100644 --- a/GeoModelTools/GeoModelJSONParser/CMakeLists.txt +++ b/GeoModelTools/GeoModelJSONParser/CMakeLists.txt @@ -22,15 +22,7 @@ endif() # installed with Homebrew on macOS). # This is not needed if the single-header library is installed in a regular # system include folder (e.g., '/usr/local/include', '/usr/include', ...) -# Also, note that nlohmann_json has been found (or not) at the root level already, -# but apparently it needs to be "found" here again, -# otherwise the nlohmann_json CMake config file is not found properly. -# Thus, in case SetupJSON.cmake finds it at root level, the variable -# SetupJSON_nlohmann_json_FOUND is set to true, and here we "find" nlohmann_json -# again. (TODO: to be investigated if we can simplify all that: ideally, -# finding it at root level inside SetupJSON.cmake should be enough.) -if ( nlohmann_json_FOUND OR SetupJSON_nlohmann_json_FOUND ) - find_package(nlohmann_json QUIET) +if ( nlohmann_json_FOUND ) target_link_libraries( GeoModelJSONParser PUBLIC nlohmann_json::nlohmann_json ) endif() diff --git a/GeoModelVisualization/GXClashPointSystems/CMakeLists.txt b/GeoModelVisualization/GXClashPointSystems/CMakeLists.txt index 60c0147220ea611bbdc5b3a893dd583f70ede8f3..ad1ee5450a9b5641aae45d2409916779b99e3aad 100644 --- a/GeoModelVisualization/GXClashPointSystems/CMakeLists.txt +++ b/GeoModelVisualization/GXClashPointSystems/CMakeLists.txt @@ -66,11 +66,12 @@ endif() target_link_libraries (GXClashPointSystems PRIVATE SoQt::SoQt Coin::Coin ${Qt5Core_LIBRARIES} GXGui GXBase GXHEPVis ${SoQt_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5PrintSupport_LIBRARIES} ) - -# 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 ) +# We link to `nlohmann_json` only if we use a version of nlohmann_json +# that provides a CMake config file (i.e., either built from source, or also +# installed with Homebrew on macOS). +# This is not needed if the single-header library is installed in a regular +# system include folder (e.g., '/usr/local/include', '/usr/include', ...) +if ( nlohmann_json_FOUND ) target_link_libraries( GXClashPointSystems PUBLIC nlohmann_json::nlohmann_json ) endif() diff --git a/GeoModelVisualization/VP1GeometrySystems/CMakeLists.txt b/GeoModelVisualization/VP1GeometrySystems/CMakeLists.txt index 5235058f8fb64e606b08e80652e76bdac06ab61d..50d638538466db9ee97b3008f0d7e91ebbc26662 100644 --- a/GeoModelVisualization/VP1GeometrySystems/CMakeLists.txt +++ b/GeoModelVisualization/VP1GeometrySystems/CMakeLists.txt @@ -62,10 +62,12 @@ include_directories(${SoQt_INCLUDE_DIRS} ) include_directories(${VP1HEPVis_INCLUDE_DIRS} ) -# 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 ) +# We link to `nlohmann_json` only if we use a version of nlohmann_json +# that provides a CMake config file (i.e., either built from source, or also +# installed with Homebrew on macOS). +# This is not needed if the single-header library is installed in a regular +# system include folder (e.g., '/usr/local/include', '/usr/include', ...) +if ( nlohmann_json_FOUND ) target_link_libraries( GXGeometrySystems nlohmann_json::nlohmann_json ) endif() @@ -79,8 +81,8 @@ endif() # Set a variable storing the CMake install prefix. # -- It is passed to the C++ preprocessor to load, from the C++ code, -# -- the JSON files storing the default materials and volume attributes -# -- for Coin3D. +# the JSON files storing the default materials and volume attributes +# for Coin3D. add_definitions ( -DGEOMODEL_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}) diff --git a/dependencies/CMakeLists.txt b/dependencies/Dependencies.cmake similarity index 100% rename from dependencies/CMakeLists.txt rename to dependencies/Dependencies.cmake diff --git a/dependencies/SetupJSON.cmake b/dependencies/SetupJSON.cmake index e97dde92f010f55a0eaf9e2ce7593972c53cfcbb..9b5c5ca7e959391137997a0fd6aaa566f93e31dd 100644 --- a/dependencies/SetupJSON.cmake +++ b/dependencies/SetupJSON.cmake @@ -59,7 +59,7 @@ else() message(STATUS "SetupJSON - 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.") else() message(STATUS "SetupJSON - Found 'nlohmann_json' at: ${nlohmann_json_DIR}") - set( SetupJSON_nlohmann_json_FOUND TRUE CACHE BOOL "True if nlohmann_json has been found by the SetupJSON module" FORCE ) + # set( SetupJSON_nlohmann_json_FOUND TRUE CACHE BOOL "True if nlohmann_json has been found by the SetupJSON module" FORCE ) endif() endif()