Commit 1257fa14 authored by Rosen Matev's avatar Rosen Matev
Browse files

Modernize cmake and adapt to DDG4 build in Gaussino

parent 65752deb
Pipeline #2480224 passed with stage
in 15 seconds
......@@ -8,7 +8,7 @@
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
###############################################################################
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
CMAKE_MINIMUM_REQUIRED(VERSION 3.15)
#---------------------------------------------------------------
# Load macros and functions for Gaudi-based projects
......@@ -47,22 +47,18 @@ macro(AddHepMC3)
endmacro()
macro(AddDD4hepDDG4)
include_directories(SYSTEM ${Gaussino_DIR}/include)
link_directories(${Gaussino_DIR}/lib)
set(DD4hepDDG4_LIBRARIES
#-lDDG4LCIO
-lDDG4Legacy
-lDDG4Plugins
-lDDG4Python
-lDDG4
-lDDPython)
add_library(DD4hep::DDG4 SHARED IMPORTED)
set_target_properties(DD4hep::DDG4 PROPERTIES IMPORTED_LOCATION ${Gaussino_DIR}/lib/libDDG4.so)
target_include_directories(DD4hep::DDG4 SYSTEM INTERFACE ${Gaussino_DIR}/include)
endmacro()
# make sure pkg-config looks for packages on CMAKE_PREFIX_PATH and system
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON)
list(APPEND CMAKE_PREFIX_PATH /usr)
# Make sure we set CMAKE_BUILD_TYPE before DD4hepBuild.cmake rudely forces
# it on us. (Happens through the Detector or the direct dependency.)
include(GaudiBuildFlags)
# Declare project name and version
gaudi_project(Gauss v60r0
FORTRAN
......
......@@ -40,10 +40,7 @@ include_directories(SYSTEM ${Boost_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${Geant4_
FindG4libs(digits_hits event geometry global graphics_reps materials
particles processes run tracking track)
message(STATUS "DD4hepDDG4_INCLUDE_DIRS: ${DD4hepDDG4_INCLUDE_DIRS}")
message(STATUS "DD4hepDDG4_LIBRARIES: ${DD4hepDDG4_LIBRARIES}")
gaudi_add_module(DD4hepCnv
src/component/*.cpp
INCLUDE_DIRS Tools/ClhepTools GiGaMTGeo LbDD4hep DD4hep
LINK_LIBRARIES ${GEANT4_LIBS} DD4hep ${DD4hep_COMPONENT_LIBRARIES} ROOT GiGaMTCoreRunLib GiGaMTDD4hepLib GaussTrackerLib)
LINK_LIBRARIES ${GEANT4_LIBS} DD4hep ${DD4hep_COMPONENT_LIBRARIES} ROOT GiGaMTCoreRunLib GiGaMTDD4hepLib GaussTrackerLib)
......@@ -33,6 +33,6 @@ add_definitions(-DG4USE_STD11)
gaudi_add_module(GaussCalo
src/*.cpp
INCLUDE_DIRS AIDA GiGaMTFactories DD4hep
LINK_LIBRARIES CaloDetLib MCEvent LHCbKernel GiGaMTCoreTruthLib GaudiAlgLib ${DD4hepDDG4_LIBRARIES})
LINK_LIBRARIES CaloDetLib MCEvent LHCbKernel GiGaMTCoreTruthLib GaudiAlgLib DD4hep::DDG4)
gaudi_env(SET GAUSSCALOOPTS \${GAUSSCALOROOT}/options)
###############################################################################
# (c) Copyright 2000-2020 CERN for the benefit of the LHCb Collaboration #
# #
# This software is distributed under the terms of the GNU General Public #
# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". #
# #
# 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. #
###############################################################################
cmake_minimum_required(VERSION 3.6)
set(LCG_LAYER LHCB_5 CACHE STRING "Specific set of version to use")
option(LCG_USE_GENERATORS "enable/disable use of LCG generators" ON)
if(NOT DEFINED GAUDI_OLD_STYLE_PROJECT)
file(STRINGS "${PROJECT_SOURCE_DIR}/CMakeLists.txt" _top_cmakelists)
set(GAUDI_OLD_STYLE_PROJECT NO)
foreach(_line IN LISTS _top_cmakelists)
if(_line MATCHES "^[^#]*gaudi_project")
set(GAUDI_OLD_STYLE_PROJECT YES)
break()
endif()
endforeach()
set(GAUDI_OLD_STYLE_PROJECT ${GAUDI_OLD_STYLE_PROJECT} CACHE BOOL "true if the top level CMakeLists file contains a call to gaudi_project")
endif()
if(NOT GAUDI_OLD_STYLE_PROJECT AND "$ENV{GAUDI_OLD_STYLE_PROJECT}" STREQUAL "")
# for new style CMake projects, or vanilla CMake projects
if("$ENV{BINARY_TAG}" STREQUAL "" OR "$ENV{LCG_VERSION}" STREQUAL "")
message(FATAL_ERROR "The environment variables BINARY_TAG and LCG_VERSION mut be set for new style CMake projects")
endif()
find_file(LCG_TOOLCHAIN NAMES $ENV{BINARY_TAG}.cmake PATH_SUFFIXES lcg-toolchains/LCG_$ENV{LCG_VERSION})
if(LCG_TOOLCHAIN)
include(${LCG_TOOLCHAIN})
# after including the toolchain, set some LHCb defaults
find_program(CCACHE_COMMAND NAMES ccache)
if(CCACHE_COMMAND)
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_COMMAND}" CACHE PATH "...")
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_COMMAND}" CACHE PATH "...")
endif()
if(NOT DEFINED GAUDI_USE_INTELAMPLIFIER)
set(GAUDI_USE_INTELAMPLIFIER "YES" CACHE BOOL "...")
endif()
if(NOT DEFINED GAUDI_LEGACY_CMAKE_SUPPORT)
set(GAUDI_LEGACY_CMAKE_SUPPORT "YES" CACHE BOOL "...")
endif()
if(NOT DEFINED CMAKE_INSTALL_PREFIX OR CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/InstallArea/$ENV{BINARY_TAG}" CACHE BOOL "...")
endif()
else()
message(FATAL_ERROR "Cannot find LCG $ENV{LCG_VERSION} $ENV{BINARY_TAG} toolchain")
endif()
else()
# this check is needed because the toolchain is called when checking the
# compiler (without the proper cache)
if(NOT CMAKE_SOURCE_DIR MATCHES "CMakeTmp")
# Avoid using Gaudi's get_host_binary_tag.py script as it doesn't support Python 3.8
# https://gitlab.cern.ch/gaudi/Gaudi/-/issues/123
execute_process(COMMAND "lb-host-binary-tag"
OUTPUT_VARIABLE HOST_BINARY_TAG
RESULT_VARIABLE HOST_BINARY_RETURN
ERROR_VARIABLE HOST_BINARY_ERROR
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(HOST_BINARY_TAG ${HOST_BINARY_TAG} CACHE STRING "BINARY_TAG of the host")
if(HOST_BINARY_RETURN OR NOT HOST_BINARY_TAG)
message(FATAL_ERROR "Error getting host binary tag\nFailed to execute ${HOST_BINARY_TAG_COMMAND}\n"
"HOST_BINARY_TAG value: ${HOST_BINARY_TAG}\n"
"Program Return Value: ${HOST_BINARY_RETURN}\n"
"Error Message: ${HOST_BINARY_ERROR}\n")
endif()
find_file(default_toolchain NAMES GaudiDefaultToolchain.cmake
HINTS ${CMAKE_SOURCE_DIR}/cmake
${CMAKE_CURRENT_LIST_DIR}/cmake)
if(default_toolchain)
include(${default_toolchain})
if(NOT DEFINED CMAKE_USE_CCACHE)
set(CMAKE_USE_CCACHE "YES" CACHE BOOL "...")
endif()
else()
message(FATAL_ERROR "Cannot find GaudiDefaultToolchain.cmake")
endif()
# FIXME: make sure we do not pick up unwanted/problematic projects from LCG
if(CMAKE_PREFIX_PATH)
# - ninja (it requires LD_LIBRARY_PATH set to run)
# - Gaudi (we do not want to use it from LCG)
# - xenv (conflicts with the version in the build environment)
list(FILTER CMAKE_PREFIX_PATH EXCLUDE REGEX "(LCG_|lcg/nightlies).*(ninja|Gaudi|xenv)")
endif()
# Make sure that when the toolchain is invoked again it uses this branch
set(ENV{GAUDI_OLD_STYLE_PROJECT} "${CMAKE_SOURCE_DIR}")
endif()
endif()
find_file(inherit_heptools_module InheritHEPTools.cmake)
# this check is needed because the toolchain is called when checking the
# compiler (without the proper cache)
if(NOT CMAKE_SOURCE_DIR MATCHES "CMakeTmp")
# Avoid using Gaudi's get_host_binary_tag.py script as it doesn't support Python 3.8
# https://gitlab.cern.ch/gaudi/Gaudi/-/issues/123
execute_process(COMMAND "lb-host-binary-tag"
OUTPUT_VARIABLE HOST_BINARY_TAG
RESULT_VARIABLE HOST_BINARY_RETURN
ERROR_VARIABLE HOST_BINARY_ERROR
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(HOST_BINARY_TAG ${HOST_BINARY_TAG} CACHE STRING "BINARY_TAG of the host")
if(HOST_BINARY_RETURN OR NOT HOST_BINARY_TAG)
message(FATAL_ERROR "Error getting host binary tag\nFailed to execute ${HOST_BINARY_TAG_COMMAND}\n"
"HOST_BINARY_TAG value: ${HOST_BINARY_TAG}\n"
"Program Return Value: ${HOST_BINARY_RETURN}\n"
"Error Message: ${HOST_BINARY_ERROR}\n")
endif()
# Prefer GaudiProjectConfig.cmake from LbDevTools
execute_process(COMMAND "python" "-c"
"
try:
import LbDevTools
print(LbDevTools.DATA_DIR)
except:
pass
"
OUTPUT_VARIABLE DEVTOOLS_DATA_DIR
RESULT_VARIABLE DEVTOOLS_DATA_DIR_RETURN
ERROR_VARIABLE DEVTOOLS_DATA_DIR_ERROR
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (NOT DEVTOOLS_DATA_DIR_RETURN AND NOT DEVTOOLS_DATA_DIR STREQUAL "" AND EXISTS "${DEVTOOLS_DATA_DIR}/cmake/GaudiProjectConfig.cmake")
set(GaudiProject_DIR "${DEVTOOLS_DATA_DIR}/cmake")
message(STATUS "Setting GaudiProject_DIR to ${GaudiProject_DIR}")
endif()
find_file(default_toolchain NAMES GaudiDefaultToolchain.cmake
HINTS ${CMAKE_SOURCE_DIR}/cmake
${CMAKE_CURRENT_LIST_DIR}/cmake)
if(default_toolchain)
include(${default_toolchain})
if(NOT DEFINED CMAKE_USE_CCACHE)
set(CMAKE_USE_CCACHE "YES" CACHE BOOL "...")
endif()
else()
message(FATAL_ERROR "Cannot find GaudiDefaultToolchain.cmake")
endif()
# FIXME: make sure we do not pick up unwanted/problematic projects from LCG
if(CMAKE_PREFIX_PATH)
# - ninja (it requires LD_LIBRARY_PATH set to run)
# - Gaudi (we do not want to use it from LCG)
# - Geant4 (we do not want to use it from LCG)
# - xenv (conflicts with the version in the build environment)
list(FILTER CMAKE_PREFIX_PATH EXCLUDE REGEX "(LCG_|lcg/nightlies).*(ninja|Gaudi|Geant4|xenv|git)/")
endif()
# special handling for LBENV_CURRENT_WORKSPACE location
if(IS_DIRECTORY "$ENV{LBENV_CURRENT_WORKSPACE}")
file(GLOB workspace_dirs "$ENV{LBENV_CURRENT_WORKSPACE}/*/InstallArea/${BINARY_TAG}")
if(workspace_dirs)
list(INSERT CMAKE_PREFIX_PATH 0 ${workspace_dirs})
endif()
endif()
endif()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment