Skip to content

Commit

Permalink
Find ROOT using config mode and cmake targets
Browse files Browse the repository at this point in the history
CMake targets imported from ROOT using config mode is suggested both
from ROOT and FairRoot. Libraries generated with different detectors are
also represented by proper CMake targets for easier dependency
management.
  • Loading branch information
YanzhaoW committed May 23, 2024
1 parent 3a118c5 commit bf53b8a
Show file tree
Hide file tree
Showing 88 changed files with 2,547 additions and 2,930 deletions.
9 changes: 9 additions & 0 deletions .cmake-format
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ line_width = 100
# How many spaces to tab for indent
tab_size = 4

# If a candidate layout is wrapped horizontally but it exceeds this many
# lines, then reject the layout.
max_lines_hwrap = 4

# If a positional argument group contains more than this many arguments, then
# force it to a vertical layout.
max_pargs_hwrap = 4

# If true, separate flow control names from their parentheses with a space
separate_ctrl_name_with_space = False

Expand Down Expand Up @@ -39,4 +47,5 @@ enable_markup = False

# If true, the argument lists which are known to be sortable will be sorted
# lexicographicall
autosort = True
enable_sort = True
3 changes: 2 additions & 1 deletion .github/actions/pre-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ runs:

- name: mount cvmfs
run: |
apt-get install -y ccache
apt-get update
apt-get install --fix-missing -y ccache sudo
wget https://cernbox.cern.ch/remote.php/dav/public-files/RmnTeeOZpYjCJQb/masterkey.gsi.de.pub
mv masterkey.gsi.de.pub /etc/cvmfs/keys
cp .githubfiles/fairsoft.gsi.de.conf /etc/cvmfs/config.d
Expand Down
137 changes: 97 additions & 40 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ if(SIMPATH)
set(CMAKE_PREFIX_PATH ${SIMPATH} ${CMAKE_PREFIX_PATH})
endif()

# fairsoft lib path needed to be added for root dictionary detection:
set(LD_LIBRARY_PATH ${SIMPATH}/lib ${LD_LIBRARY_PATH})
set(GRAPHVIZ_EXTERNAL_LIBS FALSE)

if(NOT DEFINED ENV{FAIRROOTPATH})
message(
FATAL_ERROR
Expand All @@ -63,6 +67,13 @@ string(REGEX MATCHALL "[^:]+" PATH $ENV{PATH})

set(CMAKE_MODULE_PATH "${FAIRROOTPATH}/share/fairbase/cmake/modules" ${CMAKE_MODULE_PATH})
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules" ${CMAKE_MODULE_PATH})
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/scripts" ${CMAKE_MODULE_PATH})
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/utils" ${CMAKE_MODULE_PATH})

# For CMakeLists that still use the old way
set(ROOT_FOUND_VERSION 600000)
set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib")
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")

set(CheckSrcDir "${FAIRROOTPATH}/share/fairbase/cmake/checks")

Expand All @@ -84,6 +95,7 @@ if(NOT FairCMakeModules_FOUND)
message(FATAL_ERROR "Could not find FairCMakeModules! ")
endif()

include(create_library_with_dictionary)
include(FairFindPackage2)
include(FairFormattedOutput)

Expand Down Expand Up @@ -118,9 +130,9 @@ list(APPEND optional_root_components gdml vmc)
find_package2(
PUBLIC
ROOT
VERSION
6.16.00
MODULE
# VERSION
# 6.16.00
CONFIG
REQUIRED
COMPONENTS
${required_root_components}
Expand All @@ -137,28 +149,41 @@ endif()
include(R3BMacros)
include(WriteConfigFile_r3b)
include(WriteEnvCache)
include(Dart)
include(CheckCompiler)
include(ROOTMacros)

find_package2(PUBLIC FairLogger VERSION 1.6.0 REQUIRED)
find_package2(
PUBLIC
FairLogger
VERSION
1.6.0
REQUIRED)

foreach(dep IN LISTS FairLogger_PACKAGE_DEPENDENCIES)
if(NOT dep STREQUAL "Boost")
find_package2(PUBLIC ${dep} REQUIRED VERSION ${FairLogger_${dep}_VERSION})
find_package2(
PUBLIC
${dep}
REQUIRED
VERSION
${FairLogger_${dep}_VERSION})
endif()
endforeach()

if("${FairRoot_VERSION}" VERSION_GREATER 18.6.4)

find_package2(PUBLIC FairMQ VERSION 1.4.0 REQUIRED)
find_package2(
PUBLIC
FairMQ
VERSION
1.4.0
REQUIRED)
find_package2(PUBLIC DDS)

if(FAIRSOFT_EXTERN)
set(BOOST_ROOT ${SIMPATH})
set(Boost_ROOT ${SIMPATH})
set(GSL_DIR ${SIMPATH})
else(FAIRSOFT_EXTERN)
set(BOOST_ROOT ${SIMPATH}/basics/boost)
set(Boost_ROOT ${SIMPATH}/basics/boost)
set(GSL_DIR ${SIMPATH}/basics/gsl)
endif(FAIRSOFT_EXTERN)

Expand Down Expand Up @@ -215,10 +240,10 @@ else()
set(Boost_NO_BOOST_CMAKE TRUE)

if(${ROOT_LIBRARY_DIR} MATCHES /lib/root)
set(BOOST_ROOT ${SIMPATH})
set(Boost_ROOT ${SIMPATH})
set(GSL_DIR ${SIMPATH})
else(${ROOT_LIBRARY_DIR} MATCHES /lib/root)
set(BOOST_ROOT ${SIMPATH}/basics/boost)
set(Boost_ROOT ${SIMPATH}/basics/boost)
set(GSL_DIR ${SIMPATH}/basics/gsl)
endif(${ROOT_LIBRARY_DIR} MATCHES /lib/root)

Expand Down Expand Up @@ -294,8 +319,8 @@ set(CMAKE_CXX_FLAGS "-D_GLIBCXX_ASSERTIONS ${CMAKE_CXX_FLAGS}")

set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # used by clang-tidy

set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib")
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(INCLUDE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/include")
set(VMCWORKDIR ${CMAKE_SOURCE_DIR})

Expand Down Expand Up @@ -334,7 +359,12 @@ find_package2(PUBLIC yaml-cpp)
# Workaround missing exported include directories
# Upstream has fixed this in https://github.com/jbeder/yaml-cpp/commit/ab5f9259a4e67d3fe0e4832bd407a9e596e2d884 (since 0.6.3)
if(yaml-cpp_FOUND)
get_filename_component(YAML_CPP_INCLUDE_DIR "${YAML_CPP_INCLUDE_DIR}" REALPATH BASE_DIR "/")
get_filename_component(
YAML_CPP_INCLUDE_DIR
"${YAML_CPP_INCLUDE_DIR}"
REALPATH
BASE_DIR
"/")
endif()
if(yaml-cpp_FOUND
AND TARGET yaml-cpp
Expand All @@ -359,8 +389,12 @@ if(NOT DEFINED ROOT_FOUND_VERSION)
endif()
message("ROOT_FOUND_VERSION = ${ROOT_FOUND_VERSION}")

set(FAIRROOT_LIBRARY_PROPERTIES ${FAIRROOT_LIBRARY_PROPERTIES} VERSION "${R3BROOT_VERSION}"
SOVERSION "${R3BROOT_VERSION}")
set(FAIRROOT_LIBRARY_PROPERTIES
${FAIRROOT_LIBRARY_PROPERTIES}
VERSION
"${R3BROOT_VERSION}"
SOVERSION
"${R3BROOT_VERSION}")

string(COMPARE EQUAL "${CMAKE_GENERATOR}" "Xcode" IS_XCODE)
set(R3BLIBDIR ${CMAKE_BINARY_DIR}/lib)
Expand Down Expand Up @@ -473,6 +507,15 @@ r3b_generate_version_info()
find_package(VMC QUIET)
set(BASE_INCLUDE_DIRECTORIES ${BASE_INCLUDE_DIRECTORIES} ${VMC_INCLUDE_DIRS})

find_program(
ROOT_CINT_EXECUTABLE
NAMES rootcint
PATHS ${ROOT_BINDIR}
NO_DEFAULT_PATH)

include(CTest)
include(RootCTest)

if(MODULE)
add_subdirectory(${MODULE})
endif(MODULE)
Expand All @@ -488,24 +531,22 @@ if(NOT MODULE)
endif()
message(STATUS " ${BWhite}ROOT geometries${CR} ${unitgeo_summary}")
add_subdirectory(r3bbase)
add_subdirectory(r3bdata)
add_subdirectory(field)
add_subdirectory(tracking)
add_subdirectory(passive)
add_subdirectory(tcal)
if(WITH_UCESB)
add_subdirectory(r3bsource)
endif(WITH_UCESB)
if(WITH_EPICS)
add_subdirectory(epics)
endif(WITH_EPICS)
if(Atima_FOUND)
add_subdirectory(atima)
endif(Atima_FOUND)
add_subdirectory(passive)
endif()
add_subdirectory(neuland)
add_subdirectory(glad)
add_subdirectory(xball)
add_subdirectory(dch)
add_subdirectory(fiber)
add_subdirectory(gfi)
add_subdirectory(mfi)
add_subdirectory(land)
add_subdirectory(neuland)
add_subdirectory(los)
add_subdirectory(rolu)
add_subdirectory(frssci)
Expand All @@ -520,33 +561,36 @@ if(NOT MODULE)
add_subdirectory(tttx)
add_subdirectory(strawtubes)
add_subdirectory(music)
add_subdirectory(r3bdata)
add_subdirectory(field)
add_subdirectory(r3bgen)
add_subdirectory(lumon)
add_subdirectory(califa)
add_subdirectory(evtvis)
add_subdirectory(psp)
add_subdirectory(compilehelper)
add_subdirectory(tcal)
add_subdirectory(tracking)
add_subdirectory(analysis)
add_subdirectory(tracker_rene)
add_subdirectory(pdc)
add_subdirectory(califa)
add_subdirectory(rpc)
add_subdirectory(alpide)
add_subdirectory(mwpc)
add_subdirectory(twim)
add_subdirectory(musli)
if(WITH_ACTAR)
add_subdirectory(actar)
endif(WITH_ACTAR)
add_subdirectory(analysis)

#================================================================================
# TODO: Since other dependencies still use the old cmake configurations, include(ROOTMacros) has to be used. Please change them using CMake targets ASAP.
include(ROOTMacros)
if(WITH_SOFIA)
add_subdirectory(sofia)
endif(WITH_SOFIA)
if(WITH_NeuLAND_DNN)
add_subdirectory(NeuLAND_DNN)
endif(WITH_NeuLAND_DNN)
if(WITH_EPICS)
add_subdirectory(epics)
endif(WITH_EPICS)
if(Atima_FOUND)
add_subdirectory(atima)
endif(Atima_FOUND)
if(WITH_ACTAR)
add_subdirectory(actar)
endif(WITH_ACTAR)
if(WITH_GTPC)
add_subdirectory(glad-tpc)
endif(WITH_GTPC)
Expand All @@ -562,6 +606,8 @@ if(NOT MODULE)
if(EXISTS "${PROJECT_SOURCE_DIR}/macros")
add_subdirectory(macros)
endif(EXISTS "${PROJECT_SOURCE_DIR}/macros")
#================================================================================

endif(NOT MODULE)

# add_subdirectory(gconfig)
Expand Down Expand Up @@ -648,7 +694,13 @@ if(PROJECT_PACKAGE_DEPENDENCIES)
if(DISABLE_COLOR)
fair_pad("${version_str}${version_req_str}" 26 " " version_padded)
else()
fair_pad("${version_str}${version_req_str}" 26 " " version_padded COLOR 1)
fair_pad(
"${version_str}${version_req_str}"
26
" "
version_padded
COLOR
1)
endif()
set(prefix ${${dep}_PREFIX})
if(${dep} STREQUAL Boost)
Expand Down Expand Up @@ -711,7 +763,12 @@ if(PROJECT_PACKAGE_DEPENDENCIES)
# endif()
if(${dep} STREQUAL Geant4)
foreach(dataset IN LISTS Geant4_DATASETS)
fair_pad(${Geant4_DATASET_${dataset}_ENVVAR} 21 " " envvar_padded LEFT)
fair_pad(
${Geant4_DATASET_${dataset}_ENVVAR}
21
" "
envvar_padded
LEFT)
message(
STATUS
" ${envvar_padded}: ${Geant4_DATASET_${dataset}_PATH}"
Expand Down
26 changes: 17 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
[![CI-CD](https://github.com/R3BRootGroup/R3BRoot/actions/workflows/main.yml/badge.svg)](https://github.com/R3BRootGroup/R3BRoot/actions/workflows/main.yml) [![Static Analysis](https://github.com/R3BRootGroup/R3BRoot/actions/workflows/static_analysis.yml/badge.svg)](https://github.com/R3BRootGroup/R3BRoot/actions/workflows/static_analysis.yml) [![Validate Codemeta](https://github.com/R3BRootGroup/R3BRoot/actions/workflows/codemeta_validate.yaml/badge.svg)](https://github.com/R3BRootGroup/R3BRoot/actions/workflows/codemeta_validate.yaml) [![Cleanup Caches on PR Close](https://github.com/R3BRootGroup/R3BRoot/actions/workflows/cleanup_cache.yml/badge.svg)](https://github.com/R3BRootGroup/R3BRoot/actions/workflows/cleanup_cache.yml)

## The R3BRoot Framework

The R3BRoot software is based on the FairRoot framework and can be used to perform Monte Carlo simulations and experimental data analysis of the R3B (Reactions with Relativistic Radioactive Beams) nuclear physics experiments at the GSI-FAIR research center (Facility for Antiproton and Ion Research). The user can create simulated data and/or perform analysis with the same framework. Geant3 and Geant4 transport engines are supported, however, the implemented tasks that create simulated data do not depend on a particular Monte Carlo engine. The framework delivers base classes which enable the users to construct their detectors and/or analysis tasks in a simple way, it also delivers some general functionality like track visualization. Moreover, an interface for reading experimental and/or simulated magnetic field maps is also implemented.

## Discussion Forum

For the software-related user support you can post a new topic on our [forum](https://forum.gsi.de/index.php?t=index&cat=40&).

## License

R3BRoot is distributed under the terms of the GNU General Public Licence version 3 ([GPLv3](https://github.com/R3BRootGroup/R3BRoot/blob/dev/LICENSE)).

## Release Information

Please visit [releases](https://github.com/R3BRootGroup/R3BRoot/releases)

## Download
Expand All @@ -25,6 +29,7 @@ git clone https://github.com/R3BRootGroup/macros.git
## Step by Step Installation

### Required Software

First, you will need to install FairSoft and FairRoot. For more details:

1. Install [FairSoft](https://github.com/FairRootGroup/FairSoft)
Expand All @@ -34,15 +39,13 @@ First, you will need to install FairSoft and FairRoot. For more details:
### Configure and Compile

~~~bash
from %R3BRoot_DIRECTORY%
cd ..
mkdir build
cd build
export SIMPATH=%PATH_TO_FAIRSOFT%
export FAIRROOTPATH=%PATH_TO_FAIRROOT%
cmake ../R3BRoot
. config.sh
make -j6
from %R3BRoot_DIRECTORY%
mkdir build
cmake -S . -B ./build
cmake --build ./build
source build/config.sh
~~~

To run the detector tests do:
Expand All @@ -54,16 +57,21 @@ make -j8 test
~~~

## Simulations and Data Analysis

This is performed from the GitHub parameter and data analysis repository, which contains all the macros and parameter files needed by the user to carry out the simulations and data analysis of each experiment. There is one repository per experiment, please, visit the [R3B-Wiki](https://wiki.r3b-nustar.de) for more details.

## Contributing

Please ask your questions, request features, and report issues by [creating a github issue](https://github.com/R3BRootGroup/R3BRoot/issues/new/choose).

## Code Formatting

The R3BRoot project uses clang-format-15 to ensure a common code formatting. The script "clang-format-all.sh" can be used for this purpose:
~~~bash
source util/clang-format-all.sh
~~~

## Static analyzer using Clang-tidy
Please go to this [instruction](config/clang_tidy/README.md).
## More Information

* [Static analyzer using Clang-tidy](config/clang_tidy/README.md)
* [CMake build system for R3BRoot](doc/cmake_usage.md)
Loading

0 comments on commit bf53b8a

Please sign in to comment.