Newer
Older
#####################################################################################
# (c) Copyright 2020-2021 CERN for the benefit of the LHCb and ATLAS collaborations #
# #
# This software is distributed under the terms of the Apache version 2 licence, #
# copied verbatim in the file "LICENSE". #
# #
# In applying this licence, CERN does not waive the privileges and immunities #
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
#####################################################################################
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#[========================================================================[.rst:
GaudiDependencies
-----------------
This file gather all the calls to find_package() used by Gaudi to find all
the third party libraries needed to build it.
Why a separate file?
^^^^^^^^^^^^^^^^^^^^
This dependency lookup is in a separate file so that it can be installed.
This way it can be included by GaudiConfig.cmake to perform the same lookup in
downstream projects.
Usage
^^^^^
First include the file GaudiToolbox.cmake and set the options GAUDI_USE_*,
then include this file.
It will search the dependencies with respect to these options.
If you are building Gaudi as a sub-project of a stack of projects,
remember that find_package() is local to the project, the third
party libraries searched in this file will not be available in other
projects of the stack.
.. code-block:: cmake
if(NOT TARGET Gaudi::GaudiPluginService) # (because targets are global)
find_package(Gaudi REQUIRED) # Imports targets, functions and dependencies of Gaudi
endif()
find_package(...) # other dependencies of the project
What is searched?
^^^^^^^^^^^^^^^^^
* Boost>=1.70
* Python>=2.7.15
* ROOT>=6.18
* UUID
* TBB>=2019.0.11007.2
* Threads
* ZLIB>=1.2.11
* Rangev3
* nosetests
Depending on what was used to build Gaudi:
* AIDA
* XercesC
* CLHEP>=2.4.1.0
* HepPDT
* CppUnit
* unwind
* gperftools>=2.7.0
* Doxygen>=1.8.15
* IntelAmplifier
* jemalloc
Depending on the platform:
* Linux
- rt
* MacOS
- Foundation
Variables to modify the configuration
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Set this variable to TRUE before including this file:
* ``GAUDI_DEPENDENCIES_FIND_QUIETLY``: pass QUIET to all calls to find_package()
NB: It has no effect on Boost because its config file is badly written.
#]========================================================================]
set(__quiet)
if(GAUDI_DEPENDENCIES_FIND_QUIETLY)
set(__quiet QUIET)
endif()
# Note: this must be set before the first `find_package`
set(THREADS_PREFER_PTHREAD_FLAG YES)
set(Boost_USE_STATIC_LIBS OFF)
set(OLD_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) # FIXME: the day BoostConfig.cmake handles Boost_USE_STATIC_LIBS correctly
set(BUILD_SHARED_LIBS ON)
find_package(Boost 1.70 ${__quiet} CONFIG REQUIRED system filesystem regex
thread python unit_test_framework program_options log log_setup graph)
set(BUILD_SHARED_LIBS ${OLD_BUILD_SHARED_LIBS})
mark_as_advanced(Boost_DIR) # FIXME: the day Boost correctly marks as advanced its variables
foreach(component IN ITEMS system filesystem regex thread python unit_test_framework
program_options log log_setup graph atomic chrono
date_time headers)
mark_as_advanced(boost_${component}_DIR)
endforeach()
if(GAUDI_USE_PYTHON_MAJOR STREQUAL "2")
set(_gaudi_Python_MIN_VERSION 2.7.15)
elseif(GAUDI_USE_PYTHON_MAJOR STREQUAL "3")
set(_gaudi_Python_MIN_VERSION 3.7)
else()
message(FATAL_ERROR "Invalid value for GAUDI_USE_PYTHON_MAJOR (${GAUDI_USE_PYTHON_MAJOR}), only 2 and 3 are supported")
endif()
find_package(Python ${_gaudi_Python_MIN_VERSION} ${__quiet} REQUIRED Interpreter Development)
find_package(ROOT 6.18 ${__quiet} CONFIG REQUIRED Core RIO Hist Thread Matrix
MathCore Net XMLIO Tree TreePlayer Graf3d Graf Gpad)
mark_as_advanced(ROOT_DIR ROOT_genmap_CMD ROOT_rootdraw_CMD)
# FIXME: the day ROOTConfig.cmake displays at least that it was found remove these lines
if(NOT GAUDI_DEPENDENCIES_FIND_QUIETLY)
message(STATUS "Found ROOT: ${ROOT_DIR} (found version ${ROOT_VERSION})")
endif()
find_package(TBB 2019.0.11007.2 CONFIG REQUIRED ${__quiet})
set(_gaudi_ZLIB_MIN_VERSION 1.2.11)
foreach(dep IN ITEMS UUID Threads ZLIB Rangev3 cppgsl fmt nlohmann_json)
find_package(${dep} ${_gaudi_${dep}_MIN_VERSION} REQUIRED ${__quiet})
endforeach()
set(_gaudi_CLHEP_MIN_VERSION 2.4.0.1)
set(_gaudi_Doxygen_MIN_VERSION 1.8.15)
set(CLHEP_FORCE_MODE CONFIG)
set(deps AIDA HepPDT CLHEP gperftools IntelAmplifier jemalloc unwind XercesC)
if(NOT CMAKE_FIND_PACKAGE_NAME)
# these build-time only dependencies are not needed downstream
list(APPEND deps CppUnit Doxygen)
endif()
# Identify dependencies using pkgconfig (by the pkgconfig module to use)
set(gperftools_pkgconfig_module "libprofiler>=2.7.0")
option(GAUDI_ENABLE_GAUDIALG "Build the subdirectory GaudiAlg" YES)
foreach(dep IN LISTS deps)
if(NOT CMAKE_FIND_PACKAGE_NAME)
# if we are not in GaudiConfig.cmake, we define the options
if(dep STREQUAL "IntelAmplifier")
set(default NO)
else()
set(default YES)
endif()
option(GAUDI_USE_${DEP} "Enable the dependency ${dep}" ${default})
# this is to record in GaudiConfig.cmake what was enabled at build time
string(APPEND GAUDI_OPTIONAL_DEPENDENCIES "set(GAUDI_USE_${DEP} ${GAUDI_USE_${DEP}})\n")
endif()
# if the lookup is performed from GaudiConfig.cmake
# then, all enabled "optional" dependencies become RECOMMENDED
# (except AIDA that is required downstream if used at build time)
if(NOT CMAKE_FIND_PACKAGE_NAME OR dep STREQUAL "AIDA")
set(is_required REQUIRED)
else()
set(is_required)
find_package(PkgConfig REQUIRED)
endif()
pkg_check_modules(${dep} "${${dep}_pkgconfig_module}" ${is_required} ${__quiet} IMPORTED_TARGET)
else()
find_package(${dep} ${_gaudi_${dep}_MIN_VERSION} ${${dep}_FORCE_MODE} ${is_required} ${__quiet})
endif()
endif()
endforeach()
# Make sure platform specific system libraries are available
if(UNIX AND NOT APPLE)
find_library(rt_LIBRARY rt)
mark_as_advanced(rt_LIBRARY)
if(NOT rt_LIBRARY)
message(FATAL_ERROR "rt was not found")
endif()
endif()
if(APPLE)
find_library(Foundation_FRAMEWORK Foundation)
mark_as_advanced(Foundation_FRAMEWORK)
if(NOT Foundation_FRAMEWORK)
message(FATAL_ERROR "Foundation framework was not found")
endif()
endif()