From 21180c32390f87f460221c78c398086835811233 Mon Sep 17 00:00:00 2001 From: Marco Clemencic <marco.clemencic@cern.ch> Date: Fri, 9 Jul 2021 13:13:52 +0200 Subject: [PATCH] Rewrite CMake configuration in "modern CMake" also update version to 53.0 and constraint on Phys version --- .gitlab-ci.yml | 8 +-- CMakeLists.txt | 50 ++++++++++-------- Hlt/Hlt1Conf/CMakeLists.txt | 17 +++---- Hlt/Hlt2Conf/CMakeLists.txt | 17 +++---- Hlt/Moore/CMakeLists.txt | 17 +++---- Hlt/RecoConf/CMakeLists.txt | 7 ++- MooreCache/CMakeLists.txt | 96 +++++++++++++++++++---------------- cmake/MooreDependencies.cmake | 47 +++++++++++++++++ doc/Makefile | 2 +- lhcbproject.yml | 6 +++ 10 files changed, 165 insertions(+), 102 deletions(-) create mode 100644 cmake/MooreDependencies.cmake create mode 100644 lhcbproject.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a0fa626c3b5..726ffdd8b9a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,6 +18,7 @@ variables: TARGET_BRANCH: master # Parameters for downloading nightlies and building Moore BINARY_TAG: x86_64_v2-centos7-gcc10-opt + LCG_VERSION: 100 NO_LBLOGIN: "1" # prevent lbdocker containers to start LbLogin/LbEnv LB_NIGHTLY_SLOT: lhcb-head @@ -26,7 +27,7 @@ check-copyright: image: gitlab-registry.cern.ch/ci-tools/ci-worker:cc7 script: - curl -o lb-check-copyright "https://gitlab.cern.ch/lhcb-core/LbDevTools/raw/master/LbDevTools/SourceTools.py?inline=false" - - python lb-check-copyright origin/${TARGET_BRANCH} + - python lb-check-copyright origin/${TARGET_BRANCH} --exclude lhcbproject.yml check-formatting: stage: check @@ -62,9 +63,8 @@ build: script: - . /cvmfs/lhcb.cern.ch/lib/LbEnv.sh - . /cvmfs/lhcbdev.cern.ch/nightlies/${LB_NIGHTLY_SLOT}/latest/setupSearchPath.sh - # Pick up the Phys and Allen builds from the nightly - - sed -i 's/USE Phys v.*/USE Phys HEAD/' CMakeLists.txt - - sed -i 's/Allen v.*/Allen HEAD/' CMakeLists.txt + # setupSearchPath.sh only sets CMTPROJECTPATH but we need CMAKE_PREFIX_PATH + - export CMAKE_PREFIX_PATH=${CMTPROJECTPATH}:${CMAKE_PREFIX_PATH} - lb-project-init - make CMAKEFLAGS=-DLOKI_BUILD_FUNCTOR_CACHE=OFF - ln -s ./build.$BINARY_TAG/run run diff --git a/CMakeLists.txt b/CMakeLists.txt index 8753f50ce4d..b7a39a72d7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2000-2021 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". # @@ -8,28 +8,34 @@ # granted to it by virtue of its status as an Intergovernmental Organization # # or submit itself to any jurisdiction. # ############################################################################### -CMAKE_MINIMUM_REQUIRED(VERSION 3.14) -project(Moore LANGUAGES CXX) -#--------------------------------------------------------------- -# Load macros and functions for Gaudi-based projects -find_package(GaudiProject) -#--------------------------------------------------------------- +cmake_minimum_required(VERSION 3.15) -set(USE_DD4HEP "OFF" CACHE BOOL "Controls whether DD4hep is used for the subdetectors supporting it") -if (USE_DD4HEP) - add_compile_definitions(USE_DD4HEP) -endif() +project(Moore VERSION 53.0 + LANGUAGES CXX) -# Declare project name and version +# Enable testing with CTest/CDash +include(CTest) +# CTest module adds a default timeout of 1500 seconds, but our tests may take more time. +set(DART_TESTING_TIMEOUT 0 CACHE STRING + "Maximum time allowed before CTest will kill the test." + FORCE) -gaudi_project(Moore v52r2 - USE Phys v33r0 - Allen v1r4 - DATA AppConfig VERSION v3r* - FieldMap VERSION v5r* - PRConfig VERSION v1r* - ParamFiles VERSION v8r* - RawEventFormat - TCK/HltTCK VERSION v3r* - TMVAWeights VERSION v1r*) +list(PREPEND CMAKE_MODULE_PATH + ${PROJECT_SOURCE_DIR}/cmake +) + +# Dependencies +set(WITH_Moore_PRIVATE_DEPENDENCIES TRUE) +include(MooreDependencies) + +# -- Subdirectories +lhcb_add_subdirectories( + Hlt/Hlt1Conf + Hlt/Hlt2Conf + Hlt/Moore + Hlt/RecoConf + MooreCache +) + +lhcb_finalize_configuration(NO_EXPORT) diff --git a/Hlt/Hlt1Conf/CMakeLists.txt b/Hlt/Hlt1Conf/CMakeLists.txt index dfee583acb3..48f0e8f1492 100644 --- a/Hlt/Hlt1Conf/CMakeLists.txt +++ b/Hlt/Hlt1Conf/CMakeLists.txt @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2000-2021 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". # @@ -8,13 +8,12 @@ # granted to it by virtue of its status as an Intergovernmental Organization # # or submit itself to any jurisdiction. # ############################################################################### -gaudi_subdir(Hlt1Conf) +#[=======================================================================[.rst: +Hlt/Hlt1Conf +------------ +#]=======================================================================] -find_package(pytools) +gaudi_install(PYTHON) -gaudi_install_python_modules() - -gaudi_add_test(pytests - COMMAND python -m pytest -v --doctest-modules - ${CMAKE_CURRENT_SOURCE_DIR}/python) -gaudi_add_test(QMTest QMTEST) +gaudi_add_tests(pytest ${CMAKE_CURRENT_SOURCE_DIR}/python) +gaudi_add_tests(QMTest) diff --git a/Hlt/Hlt2Conf/CMakeLists.txt b/Hlt/Hlt2Conf/CMakeLists.txt index 3d1bbef7293..4584eddc043 100644 --- a/Hlt/Hlt2Conf/CMakeLists.txt +++ b/Hlt/Hlt2Conf/CMakeLists.txt @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2000-2021 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". # @@ -8,13 +8,12 @@ # granted to it by virtue of its status as an Intergovernmental Organization # # or submit itself to any jurisdiction. # ############################################################################### -gaudi_subdir(Hlt2Conf) +#[=======================================================================[.rst: +Hlt/Hlt2Conf +------------ +#]=======================================================================] -find_package(pytools) +gaudi_install(PYTHON) -gaudi_install_python_modules() - -gaudi_add_test(pytests - COMMAND python -m pytest -v --doctest-modules - ${CMAKE_CURRENT_SOURCE_DIR}/python) -gaudi_add_test(QMTest QMTEST) +gaudi_add_tests(pytest ${CMAKE_CURRENT_SOURCE_DIR}/python) +gaudi_add_tests(QMTest) diff --git a/Hlt/Moore/CMakeLists.txt b/Hlt/Moore/CMakeLists.txt index 780fbba47f1..1a3d255dab2 100644 --- a/Hlt/Moore/CMakeLists.txt +++ b/Hlt/Moore/CMakeLists.txt @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2000-2021 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". # @@ -8,13 +8,12 @@ # granted to it by virtue of its status as an Intergovernmental Organization # # or submit itself to any jurisdiction. # ############################################################################### -gaudi_subdir(Moore) +#[=======================================================================[.rst: +Hlt/Moore +--------- +#]=======================================================================] -find_package(pytools) +gaudi_install(PYTHON) -gaudi_install_python_modules() - -gaudi_add_test(pytests - COMMAND python -m pytest -v --doctest-modules - ${CMAKE_CURRENT_SOURCE_DIR}/python) -gaudi_add_test(QMTest QMTEST) +gaudi_add_tests(pytest ${CMAKE_CURRENT_SOURCE_DIR}/python) +gaudi_add_tests(QMTest) diff --git a/Hlt/RecoConf/CMakeLists.txt b/Hlt/RecoConf/CMakeLists.txt index d092947e399..416915a6dc2 100644 --- a/Hlt/RecoConf/CMakeLists.txt +++ b/Hlt/RecoConf/CMakeLists.txt @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2000-2021 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". # @@ -8,8 +8,7 @@ # granted to it by virtue of its status as an Intergovernmental Organization # # or submit itself to any jurisdiction. # ############################################################################### -find_package(pytools) -gaudi_install_python_modules() +gaudi_install(PYTHON) -gaudi_add_test(QMTest QMTEST) +gaudi_add_tests(QMTest) diff --git a/MooreCache/CMakeLists.txt b/MooreCache/CMakeLists.txt index 16f6cc9510f..218c0fe9c64 100644 --- a/MooreCache/CMakeLists.txt +++ b/MooreCache/CMakeLists.txt @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2000-2021 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". # @@ -8,65 +8,73 @@ # granted to it by virtue of its status as an Intergovernmental Organization # # or submit itself to any jurisdiction. # ############################################################################### -gaudi_subdir(MooreCache) - -gaudi_depends_on_subdirs(Hlt/Hlt1Conf - Phys/FunctorCore) - -# Suppress compilation warnings from external packages -find_package(Boost) -find_package(ROOT) -include_directories(SYSTEM ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS}) +#[=======================================================================[.rst: +MooreCache +---------- +#]=======================================================================] # Import the cache creation module include(LoKiFunctorsCache) -# Allow build in satellite (lb-dev) projects -if(TARGET MooreConfUserDB) - set(conf_deps DEPENDS MooreConfUserDB) +set(cache_deps) + +if(TARGET MergeConfDB2) + list(APPEND cache_deps MergeConfDB2) endif() # Disable LoKi-specific hacks in LoKiFunctorsCachePostActionOpts.py -# Save the old value so we don't change the behaviour elsewhere. -set(LOKI_FUNCTORS_CACHE_POST_ACTION_OPTS_TMP ${LOKI_FUNCTORS_CACHE_POST_ACTION_OPTS}) -set(LOKI_FUNCTORS_CACHE_POST_ACTION_OPTS "") +set(LOKI_FUNCTORS_CACHE_POST_ACTION_OPTS) list(APPEND hlt1_settings hlt1_pp_default hlt1_pp_comparison) list(APPEND hlt2_settings options/hlt2_pp_default tests/options/thor/loki_comparison) if(NOT DEFINED REC_ROOT_DIR) - # Rec uses new CMake configuration so we need a different way to locate - # private files - set(REC_ROOT_DIR ${Rec_DIR}/../../../../..) + # Rec uses new CMake configuration so we need a different way to locate + # private files + set(REC_ROOT_DIR ${Rec_DIR}/../../../../..) endif() foreach(name IN LISTS hlt1_settings) - loki_functors_cache(Moore_FunctorCache_Hlt1_${name} - ${REC_ROOT_DIR}/Phys/FunctorCache/options/DisableLoKiCacheFunctors.py - ${Moore_SOURCE_DIR}/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py - ${CMAKE_CURRENT_SOURCE_DIR}/options/process_zero_events.py - ${CMAKE_CURRENT_SOURCE_DIR}/options/silence_application_manager.py - ${Moore_SOURCE_DIR}/Hlt/Hlt1Conf/options/${name}.py - FACTORIES FunctorFactory - LINK_LIBRARIES FunctorCoreLib - ${conf_deps} - SPLIT 15) + loki_functors_cache(Moore_FunctorCache_Hlt1_${name} + ${REC_ROOT_DIR}/Phys/FunctorCache/options/DisableLoKiCacheFunctors.py + ${PROJECT_SOURCE_DIR}/Hlt/Moore/tests/options/default_input_and_conds_hlt1.py + ${CMAKE_CURRENT_SOURCE_DIR}/options/process_zero_events.py + ${CMAKE_CURRENT_SOURCE_DIR}/options/silence_application_manager.py + ${PROJECT_SOURCE_DIR}/Hlt/Hlt1Conf/options/${name}.py + FACTORIES FunctorFactory + LINK_LIBRARIES + Gaudi::GaudiKernel + Rec::FunctorCoreLib + DEPENDS ${cache_deps} + SPLIT 15 + ) endforeach() foreach(options_path IN LISTS hlt2_settings) - # Replace forward slashes with underscores to form a valid CMake identifier - string(REPLACE "/" "_" name ${options_path}) - loki_functors_cache(Moore_FunctorCache_Hlt2_${name} - ${REC_ROOT_DIR}/Phys/FunctorCache/options/DisableLoKiCacheFunctors.py - ${Moore_SOURCE_DIR}/Hlt/Moore/tests/options/default_input_and_conds_hlt2.py - ${CMAKE_CURRENT_SOURCE_DIR}/options/process_zero_events.py - ${CMAKE_CURRENT_SOURCE_DIR}/options/silence_application_manager.py - ${Moore_SOURCE_DIR}/Hlt/Hlt2Conf/${options_path}.py - FACTORIES FunctorFactory TrackFunctorFactory HybridFactory PPFactoryHybridFactory HltFactory - LINK_LIBRARIES FunctorCoreLib DaVinciKernelLib LoKiArrayFunctorsLib LoKiPhysLib LoKiHltLib LoKiCoreLib LoKiTrackLib - ${conf_deps} - SPLIT 15) + # Replace forward slashes with underscores to form a valid CMake identifier + string(REPLACE "/" "_" name ${options_path}) + loki_functors_cache(Moore_FunctorCache_Hlt2_${name} + ${REC_ROOT_DIR}/Phys/FunctorCache/options/DisableLoKiCacheFunctors.py + ${PROJECT_SOURCE_DIR}/Hlt/Moore/tests/options/default_input_and_conds_hlt2.py + ${CMAKE_CURRENT_SOURCE_DIR}/options/process_zero_events.py + ${CMAKE_CURRENT_SOURCE_DIR}/options/silence_application_manager.py + ${PROJECT_SOURCE_DIR}/Hlt/Hlt2Conf/${options_path}.py + FACTORIES + FunctorFactory + TrackFunctorFactory + HybridFactory + PPFactoryHybridFactory + HltFactory + LINK_LIBRARIES + Gaudi::GaudiKernel + LHCb::LoKiCoreLib + LHCb::LoKiHltLib + Phys::DaVinciKernelLib + Phys::LoKiArrayFunctorsLib + Phys::LoKiPhysLib + Rec::FunctorCoreLib + Rec::LoKiTrackLib + DEPENDS ${cache_deps} + SPLIT 15 + ) endforeach() - -# Restore the old value -set(LOKI_FUNCTORS_CACHE_POST_ACTION_OPTS ${LOKI_FUNCTORS_CACHE_POST_ACTION_OPTS_TMP}) diff --git a/cmake/MooreDependencies.cmake b/cmake/MooreDependencies.cmake new file mode 100644 index 00000000000..e7e87634bd1 --- /dev/null +++ b/cmake/MooreDependencies.cmake @@ -0,0 +1,47 @@ +############################################################################### +# (c) Copyright 2021 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. # +############################################################################### +if(NOT COMMAND lhcb_find_package) + # Look for LHCb find_package wrapper + find_file(LHCbFindPackage_FILE LHCbFindPackage.cmake) + if(LHCbFindPackage_FILE) + include(${LHCbFindPackage_FILE}) + else() + # if not found, use the standard find_package + macro(lhcb_find_package) + find_package(${ARGV}) + endmacro() + endif() +endif() + +# -- Public dependencies +lhcb_find_package(Phys 33.0 REQUIRED) +lhcb_find_package(Allen REQUIRED) + +# Allen uses old-style CMake configuration +get_filename_component(ALLEN_PROJECT_ROOT "${Allen_DIR}" DIRECTORY) +get_filename_component(ALLEN_PROJECT_ROOT "${ALLEN_PROJECT_ROOT}" DIRECTORY) +lhcb_env(PRIVATE SET ALLEN_PROJECT_ROOT ${ALLEN_PROJECT_ROOT}) +lhcb_env(PREPEND PYTHONPATH ${Allen_DIR}/python) +lhcb_env(PREPEND LD_LIBRARY_PATH ${Allen_DIR}/lib) +lhcb_env(SET ALLEN_INSTALL_DIR ${Allen_DIR}) + +find_data_package(AppConfig 3.0 REQUIRED) +find_data_package(FieldMap 5.0 REQUIRED) +find_data_package(ParamFiles 8.0 REQUIRED) +find_data_package(PRConfig 1.0 REQUIRED) +find_data_package(RawEventFormat REQUIRED) +find_data_package(TCK/HltTCK 3.0 REQUIRED) +find_data_package(TMVAWeights 1.0 REQUIRED) + +# -- Private dependencies +if(WITH_Moore_PRIVATE_DEPENDENCIES) + # no private dependencies +endif() diff --git a/doc/Makefile b/doc/Makefile index 4deec0887ff..eaf4fc00acd 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -35,7 +35,7 @@ help: $(SPHINXBUILD) $(SPHINXBUILD): requirements.txt Makefile python -m pip install --disable-pip-version-check --no-warn-conflicts --ignore-installed \ --target=$(SPHINXPREFIX) -r $< \ - certifi==`python -E -c 'import certifi; print(certifi.__version__)'` + certifi==`python -c 'import certifi; print(certifi.__version__)'` @touch $@ # Catch-all target: route all unknown targets to Sphinx using the new diff --git a/lhcbproject.yml b/lhcbproject.yml new file mode 100644 index 00000000000..184c1d5eab3 --- /dev/null +++ b/lhcbproject.yml @@ -0,0 +1,6 @@ +--- +name: Moore +license: GPL-3.0-only +dependencies: + - Phys + - Allen -- GitLab