diff --git a/CMakeLists.txt b/CMakeLists.txt index b7e3e2344e47d7e4a80a0f502199de84b4b02e40..483a311fa4cae8aa084ebec0bfe8009018fe8fa2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,7 @@ set(CBMROOT_PATCH_VERSION 99) # Set name of our project to "CBMROOT" # This also sets ${CBMROOT_VERSION} to the provided VERSION value, which would be empty if not set here explicitly -project(CBMROOT +project(CBMROOT VERSION ${CBMROOT_MAJOR_VERSION}.${CBMROOT_MINOR_VERSION}.${CBMROOT_PATCH_VERSION} LANGUAGES C CXX ) @@ -71,7 +71,7 @@ list(PREPEND CMAKE_PREFIX_PATH ${SIMPATH}) find_package(ROOT 6.22 CONFIG REQUIRED) if(ROOT_FOUND) Message("Root was found") - # The following CMake variables are needed until the modernization is done + # The following CMake variables are needed until the modernization is done set(ROOT_CINT_EXECUTABLE ${ROOT_BINDIR}/rootcling) set(ROOT_CONFIG_EXECUTABLE ${ROOT_BINDIR}/root-config) set(ROOT_INCLUDE_DIR ${ROOT_INCLUDE_DIRS}) @@ -171,7 +171,7 @@ if(FairMQ_FOUND) set(FAIRMQ_INCLUDE_DIR ${FairMQ_INCDIR}/fairmq) get_target_property(_inDirMQ FairMQ::FairMQ INTERFACE_INCLUDE_DIRECTORIES) - set_property(TARGET FairMQ::FairMQ APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${_inDirMQ}/fairmq/options") + set_property(TARGET FairMQ::FairMQ APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${_inDirMQ}/fairmq/options") endif() # Check if the compiler supports the needed C++ standard @@ -197,7 +197,12 @@ set(FAIRROOT_LIBRARY_PROPERTIES ${FAIRROOT_LIBRARY_PROPERTIES} SOVERSION "${CBMROOT_MAJOR_VERSION}" ) +# Searching for OpenMP + control variable prep. for config script (default behavior + override) find_package(OpenMP) +set(OMP_NUM_THREADS 1) +If(DEFINED ENV{OMP_NUM_THREADS} ) + set(OMP_NUM_THREADS $ENV{OMP_NUM_THREADS}) +endif() # set a variable which should be used in all CMakeLists.txt # Defines all basic include directories from fairbase @@ -288,13 +293,13 @@ if(BUILD_DOXYGEN) add_subdirectory(doxygen) endif() -# Definde additional targets +# Definde additional targets # cleanlib: rm al Cbm libraries and dictionaries # cleantest: remove all files from build directory created when running ROOT macros -# FormatCheck: execute clang-format for all changed files (needed for CI) +# FormatCheck: execute clang-format for all changed files (needed for CI) define_additional_targets() -# generate the needed config files to run macros from build and +# generate the needed config files to run macros from build and # installation directories. The later will be installed into the # install directory generate_config_files() diff --git a/cmake/scripts/config.csh.in b/cmake/scripts/config.csh.in index c7e23422d12e3a96e83bb12ecdb4279f56022886..86da852bd4577b2238a699d018ab7ba8414f9812 100644 --- a/cmake/scripts/config.csh.in +++ b/cmake/scripts/config.csh.in @@ -30,6 +30,14 @@ if ( "$same_system" == "1" ) then setenv VMCWORKDIR "@VMCWORKDIR@" setenv FAIRLIBDIR "@FAIRLIBDIR@" setenv PYTHONPATH "@MY_PYTHONPATH@" + setenv OMP_NUM_THREADS @OMP_NUM_THREADS@ + if (! $?OMP_NUM_THREADS) then + setenv OMP_NUM_THREADS @OMP_NUM_THREADS@ + else + if ("$OMP_NUM_THREADS" == "") then + setenv OMP_NUM_THREADS @OMP_NUM_THREADS@ + endif + endif switch( $1 ) case '-a' : setenv DYLD_LIBRARY_PATH $DYLD_LIBRARY_PATH:"@MY_DYLD_LIBRARY_PATH@" diff --git a/cmake/scripts/config.sh.in b/cmake/scripts/config.sh.in index 17a26963af71b91aba3f5ccf58c05ca2b1bb5f3b..0097d168f253a518ab8a876ea7ca1293a1d272dd 100644 --- a/cmake/scripts/config.sh.in +++ b/cmake/scripts/config.sh.in @@ -29,6 +29,10 @@ if [ $same_system -eq 1 ]; then export VMCWORKDIR="@VMCWORKDIR@" export FAIRLIBDIR="@FAIRLIBDIR@" export PYTHONPATH="@MY_PYTHONPATH@" + if [[ -z "${OMP_NUM_THREADS}" ]]; then + export OMP_NUM_THREADS=@OMP_NUM_THREADS@ + fi + case $1 in -a | --append ) export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:"@MY_DYLD_LIBRARY_PATH@" diff --git a/cmake/scripts/root_macro.sh.in b/cmake/scripts/root_macro.sh.in index 535797a33baea0155e84c7040226a16de76d0072..9082e424c6950045e21b47ca1e13164a2627fe55 100644 --- a/cmake/scripts/root_macro.sh.in +++ b/cmake/scripts/root_macro.sh.in @@ -2,7 +2,7 @@ # This macro is needed to start the Root macros used for automatic testing # from inside CMake using the add_test functionality. Since the tests -# starts with a fresh environment on has to set first the correct environment +# starts with a fresh environment one has to set first the correct environment # needed to run FairRoot. # Also parameters defined in add_test will be converted in the correct format # to be passed to root. @@ -19,6 +19,9 @@ export VMCWORKDIR=@VMCWORKDIR@ export Geant4VMC_MACRO_DIR=@Geant4VMC_MACRO_DIR@ export USE_VGM=1 export BOOST=@Boost_Avail@ +if [[ -z "${OMP_NUM_THREADS}" ]]; then + export OMP_NUM_THREADS=@OMP_NUM_THREADS@ +fi @Geant4Data_Variables_sh@