Skip to content
Snippets Groups Projects
Commit 0e9d84e3 authored by Riccardo Maria Bianchi's avatar Riccardo Maria Bianchi :sunny:
Browse files

Simplifying and centralizing CMake setup for external dependencies

parent ef4341ba
Branches
Tags
No related merge requests found
...@@ -7,7 +7,7 @@ project( "GeoModel" VERSION 1.0.0 LANGUAGES CXX ) ...@@ -7,7 +7,7 @@ project( "GeoModel" VERSION 1.0.0 LANGUAGES CXX )
# === Project wide setup === # === 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 ) list( APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake )
# Define color codes for CMake messages # Define color codes for CMake messages
include( cmake_colors_defs ) include( cmake_colors_defs )
...@@ -21,7 +21,9 @@ include( BuildType ) ...@@ -21,7 +21,9 @@ include( BuildType )
include( PrintBuildInfo ) include( PrintBuildInfo )
# === Externally provided content === # === 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 === # === Main targets built by this project ===
......
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
# Set up the project. # Set up the project.
# cmake_minimum_required( VERSION 3.1 )
project( "GeoModelTools" VERSION 4.0.0 LANGUAGES CXX ) project( "GeoModelTools" VERSION 4.0.0 LANGUAGES CXX )
# Set default build options. # Set default build options.
...@@ -12,16 +11,6 @@ set( CMAKE_CXX_EXTENSIONS FALSE CACHE BOOL "(Dis)allow using GNU extensions" ) ...@@ -12,16 +11,6 @@ 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 ) 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 ) find_package( XercesC )
# Set up the build of the libraries of the project. # Set up the build of the libraries of the project.
......
...@@ -22,15 +22,7 @@ endif() ...@@ -22,15 +22,7 @@ endif()
# installed with Homebrew on macOS). # installed with Homebrew on macOS).
# This is not needed if the single-header library is installed in a regular # This is not needed if the single-header library is installed in a regular
# system include folder (e.g., '/usr/local/include', '/usr/include', ...) # 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, if ( nlohmann_json_FOUND )
# 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)
target_link_libraries( GeoModelJSONParser PUBLIC nlohmann_json::nlohmann_json ) target_link_libraries( GeoModelJSONParser PUBLIC nlohmann_json::nlohmann_json )
endif() endif()
......
...@@ -71,15 +71,7 @@ target_link_libraries (GXClashPointSystems PRIVATE SoQt::SoQt Coin::Coin ${Qt5C ...@@ -71,15 +71,7 @@ target_link_libraries (GXClashPointSystems PRIVATE SoQt::SoQt Coin::Coin ${Qt5C
# installed with Homebrew on macOS). # installed with Homebrew on macOS).
# This is not needed if the single-header library is installed in a regular # This is not needed if the single-header library is installed in a regular
# system include folder (e.g., '/usr/local/include', '/usr/include', ...) # 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, if ( nlohmann_json_FOUND )
# 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)
target_link_libraries( GXClashPointSystems PUBLIC nlohmann_json::nlohmann_json ) target_link_libraries( GXClashPointSystems PUBLIC nlohmann_json::nlohmann_json )
endif() endif()
......
...@@ -67,15 +67,7 @@ include_directories(${VP1HEPVis_INCLUDE_DIRS} ) ...@@ -67,15 +67,7 @@ include_directories(${VP1HEPVis_INCLUDE_DIRS} )
# installed with Homebrew on macOS). # installed with Homebrew on macOS).
# This is not needed if the single-header library is installed in a regular # This is not needed if the single-header library is installed in a regular
# system include folder (e.g., '/usr/local/include', '/usr/include', ...) # 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, if ( nlohmann_json_FOUND )
# 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)
target_link_libraries( GXGeometrySystems nlohmann_json::nlohmann_json ) target_link_libraries( GXGeometrySystems nlohmann_json::nlohmann_json )
endif() endif()
...@@ -89,8 +81,8 @@ endif() ...@@ -89,8 +81,8 @@ endif()
# Set a variable storing the CMake install prefix. # Set a variable storing the CMake install prefix.
# -- It is passed to the C++ preprocessor to load, from the C++ code, # -- It is passed to the C++ preprocessor to load, from the C++ code,
# -- the JSON files storing the default materials and volume attributes # the JSON files storing the default materials and volume attributes
# -- for Coin3D. # for Coin3D.
add_definitions ( -DGEOMODEL_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}) add_definitions ( -DGEOMODEL_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX})
......
File moved
...@@ -59,7 +59,7 @@ else() ...@@ -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.") 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() else()
message(STATUS "SetupJSON - Found 'nlohmann_json' at: ${nlohmann_json_DIR}") 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()
endif() endif()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment