# The top-level CMake file is there to bring all modules into scope. # That means, adding the subdirectories for all CMake projects in this tree, # and finding external libraries and turning them into imported targets. # # # manager COMET Software Group # author andreas.jansen@tu-dresden.de ## -- TODO -- # Cleanup of compiler flags, create ICEDUST macro # Additionally support for other OS / compiler? # # zLib, Recpack and SQLite as part of ICEDUST? # # Right now I disabled use of version files as they are likely just a leftover from CMT? # For more infos see: oaEvent documentation > Tracking the compiled library version # To avoid setting a lot of preprocessor definitions I commented out # the #include lines in several source files: # oaGeomInfo/src/IGeomInfo.cxx # oaGeomInfo/src/IGeomInfo.hxx # oaGeomInfo/test/tutGeomVisitor.cxx # oaGeomInfo/test/tutCDCGeomInfo.cxx # oaGeomInfo/test/tutGeomInfo.cxx # oaEvent/app/plot-event.cxx # SimG4/src/COMETRootPersistencyManager.cc # SimG4/src/COMETRootGeometryManager.cc # SimG4/sElec/ISimplisticElec.cxx # oaRawEvent/src/IMCMBank.cxx # oaRawEvent/src/ITriggerBank.cxx # In oaApplyAlign/src/ICOMETAlignmentLookup.cxx I commented out include of "oaApplyAlign_version.h" # and set required definitions (MAJOR_VERSION etc) manually! # If this causes problems later on we have to revisit this! (and possibly implement preprocessor definitions) ###################################### ######### User Flag Options: ######### # Preface with -D and end in =, i.e. "-DBUILD_FLAG_NAME="something" ###################################### # BUILD_GEANT4_VERSION : Sets the version of Geant4 to build and related package version # (String) Can currently be "4.10.4" or "4.10.6". # "4.10.6" is forcibly set as a default if no argument or and incorrct argument is given. cmake_minimum_required (VERSION 3.0) # --- CMake policys --- # enables project(...) command to use VERSION argument (may override other, manually set variables) # to stay consitent VERSION SHOULD be provided for each call of project(...)!! cmake_policy(SET CMP0048 NEW) # Enables use of _ROOT variables. # NOTE: This functionality was manually implemented in the find_macro files beforehand either way. # This means it works even with policy set to OLD or older CMake (>3.11) version. if(${CMAKE_VERSION} VERSION_GREATER 3.12) cmake_policy(SET CMP0074 NEW) endif() # Support for IN_LIST if operator cmake_policy(SET CMP0057 NEW) # --- project name, version --- project(ICEDUST LANGUAGES CXX VERSION 1.0.0) # --- save git commit --- execute_process(COMMAND git log -1 --format=%H WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE GIT_COMMIT) string(REGEX REPLACE "\n$" "" GIT_COMMIT "${GIT_COMMIT}") file(WRITE ${CMAKE_BINARY_DIR}/version/ICOMETRepoVersion.hxx "#define GIT_COMMIET_SHA1 \"${GIT_COMMIT}\"") # --- Prepend our own CMake Modules to the search path --- # Note: if our custom modules include others that we don't supply, those in # the base path will be used, so watch for incompatibilities!! # Note2: This directory also contains Find.cmake files for support of external packages set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules ${CMAKE_MODULE_PATH} ) # --- Include our ICDEUST Custom-macros in ../cmake/Modules --- include(IcedustOutOfSourceBuild) include(IcedustCreateROOTDict) # needs ROOT include(IcedustConfigureOutput) include(IcedustCreateSetupScript) if(NOT ((ICEDUST_BUILD_VERSION_AND_REGISTER STREQUAL ON) OR (ICEDUST_BUILD_VERSION_AND_REGISTER STREQUAL TRUE))) # Skip building version.h and Ipackage_version files by default if # "ICEDUST_BUILD_VERSION_AND_REGISTER" is not set as "TRUE" or "ON" message(STATUS "Skip building version.h and Ipackage_version files") include(IcedustSkipRegisterAndVersion) else() message(STATUS "Build (and link against) version.h and Ipackage_version files") # FIXME: As #include are commented out in source files this option # will build the files but they won't be used! See TODO list at top of this file. include(IcedustPackageVersion) include(IcedustRegisterPackage) # needs IcedustCreateROOTDict macro! endif() # Forced Geant4.10.6 if a version is not selected if( NOT BUILD_GEANT4_VERSION ) message(STATUS "WARNING: NO GEANT4 VERSION SELECTED, Geant4.10.6 will be built as the latest default") set(BUILD_GEANT4_VERSION "4.10.6") elseif( NOT ( (BUILD_GEANT4_VERSION STREQUAL "4.10.4") OR (BUILD_GEANT4_VERSION STREQUAL "4.10.6")) ) message(STATUS "WARNING: UNSUPPORTED GEANT4 VERSION SELECTED, Geant4.10.6 will be built as the latest default") set(BUILD_GEANT4_VERSION "4.10.6") endif() # --- (example) Debug option --- #set(CMAKE_DEBUG_TARGET_PROPERTIES INCLUDE_DIRECTORIES) # # --- Enable Test with CPack (adds build target "test" e.g. run "make test") --- enable_testing() # --- Set/Check where our external packages are located --- if((NOT EXTERNAL_PACKAGES_PATH) OR (NOT EXISTS ${EXTERNAL_PACKAGES_PATH})) # If no path to external packages is provided we fallback to our default location # ("ICEDUST_externals_source" dir next to "ICEDUST_packages" dir) get_filename_component(EXTERNAL_PACKAGES_PATH ${CMAKE_SOURCE_DIR}/../ICEDUST_externals_install ABSOLUTE) message(WARNING "No path to external packages provided, falling back to default location ${EXTERNAL_PACKAGES_PATH}") endif() if(NOT EXISTS ${EXTERNAL_PACKAGES_PATH}) message(WARNING "Could not find external packages. Please provide option: \ -DEXTERNAL_PACKAGES_PATH=/path/to/ICEDUST_externals_source \ or make sure the directory is next to /ICEDUST_packages/. \ \nIf ALL package locations are provided with -D=/path/to/extPackage \ this warning can be ignored.") endif() # --- Default build type if none was specified --- if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.") set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE) # Set the possible values of build type for cmake-gui set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() # guard against bad build-type strings string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_tolower) if( NOT cmake_build_type_tolower STREQUAL "debug" AND NOT cmake_build_type_tolower STREQUAL "release" AND NOT cmake_build_type_tolower STREQUAL "minsizerel" AND NOT cmake_build_type_tolower STREQUAL "relwithdebinfo") message(FATAL_ERROR "Unknown build type \"${CMAKE_BUILD_TYPE}\". Allowed values are Debug, Release, MinSizeRel, RelWithDebInfo (case-insensitive).") endif() # --- Shared / Static library option --- if(NOT DEFINED BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS) # We build shared libraries (by default!) if # a) "BUILD_SHARED_LIBS" is not set at all # b) "BUILD_SHARED_LIBS" is not set as "FALSE" or "OFF" message(STATUS "Building shared libraries") set(BUILD_SHARED_LIBS ON) else() message(STATUS "Building static libraries") endif() # --- Default CMAKE_INSTALL_PREFIX --- if(CMAKE_INSTALL_PREFIX STREQUAL "/usr/local") # -- TODO -- default CMAKE_INSTALL_PREFIX under linux is "/usr/local" # so if no other PATH is provided we set our default prefix path here # this of course disables "/usr/local" as a valid option which is fine for now(?) -- FIXME get_filename_component(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/../ICEDUST_install ABSOLUTE) else() # use provided CMAKE_INSTALL_PREFIX # this may conflict with "ICEDUST_IN_SOURCE" option. In this case we throw a warning if((ICEDUST_IN_SOURCE EQUAL ON) OR (ICEDUST_IN_SOURCE EQUAL TRUE)) message(WARNING "### 'ICEDUST_IN_SOURCE' overrides provided 'CMAKE_INSTALL_PREFIX' path!") endif() endif() # --- In- / Out-of-source option --- if(NOT ((ICEDUST_IN_SOURCE STREQUAL ON) OR (ICEDUST_IN_SOURCE STREQUAL TRUE))) # We want to build out-of-source (by default!) if # "ICEDUST_IN_SOURCE" is not set as "TRUE" or "ON" ICEDUST_ensure_out_of_source_build() message(STATUS "Build is done out-of-source: ${CMAKE_INSTALL_PREFIX}/packageName/") else() # If "ICEDUST_IN_SOURCE" option is set we do a "trick" # >> simply change the install directory to the corrosponding in-source PATH set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}) message(STATUS "Build is done in-source: ../ICEDUST_packages/packageName/") endif() # --- RPATH handling for shared library linking --- ## for more infos on this topic see: https://cmake.org/Wiki/CMake_RPATH_handling # use, i.e. don't skip the full RPATH for the build tree SET(CMAKE_SKIP_BUILD_RPATH FALSE) # when building, don't use the install RPATH already (but later on when installing) SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) # add the automatically determined parts of the RPATH # which point to directories outside the build tree to the install RPATH SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # --- Option if created root-dictionaries are copied to the install path --- if(NOT DEFINED ICEDUST_COPY_DICT OR ICEDUST_COPY_DICT) # We want to copy created root-dictionaries (by default!) if # a) "ICEDUST_COPY_DICT" is not set at all # b) "ICEDUST_COPY_DICT" is not set as "FALSE" or "OFF" set(ICEDUST_COPY_DICT ON) message(STATUS "Copy created root-dictionaries while installing") else() set(ICEDUST_COPY_DICT OFF) message(STATUS "Skip created root-dictionaries while installing") endif() # --- Options for symlinks --- if(NOT DEFINED ICEDUST_CREATE_SYMLINKS OR ICEDUST_CREATE_SYMLINKS) # TODO: Maybe also options to customize those directories set(SYMLINK_INSTALL_OUTPUT_FOLDER "${CMAKE_INSTALL_PREFIX}/ICEDUST_SYMLINKS") set(SYMLINK_BUILD_OUTPUT_FOLDER "${CMAKE_BINARY_DIR}/ICEDUST_SYMLINKS") endif() # --- Include External libraries to be linked against --- # we use EXTERNAL_PACKAGES_PATH from above as default search path # use -DextPackage_ROOT=/path/to/ext/package to set up specifc directories # ------- ROOT: # find_packages uses "ROOTConfig.cmake" provided by ROOT # if ROOT is build sperately (without RPATH) one has to set up the environment beforehand! (source /bin/thisroot.sh) # It is IMPORTANT to separately specify the needed root-libraries for our executables via COMPONENTS option! if((NOT ROOT_ROOT) OR (NOT EXISTS ${ROOT_ROOT})) if(EXISTS ${EXTERNAL_PACKAGES_PATH}/root_v6.18.00) set(ROOT_ROOT ${EXTERNAL_PACKAGES_PATH}/root_v6.18.00) elseif(EXISTS ${EXTERNAL_PACKAGES_PATH}/root_v6.24.02) set(ROOT_ROOT ${EXTERNAL_PACKAGES_PATH}/root_v6.24.02) endif() endif() list(APPEND CMAKE_PREFIX_PATH ${ROOT_ROOT}) find_package(ROOT REQUIRED COMPONENTS Core Tree Geom Physics EG Eve Ged RGL Gui Matrix RIO Hist XMLParser Net MathCore MathMore Gpad Graf Graf3d Spectrum Minuit) include(${ROOT_USE_FILE}) # ------- MYSQL: if((NOT MYSQL_ROOT) OR (NOT EXISTS ${MYSQL_ROOT})) set(MYSQL_ROOT ${EXTERNAL_PACKAGES_PATH}/mysql-5.6.34) endif() find_package(MYSQL REQUIRED) # creates IMPORTED target MYSQL::MYSQL # ------- CLHEP: if((NOT CLHEP_ROOT) OR (NOT EXISTS ${CLHEP_ROOT})) if(EXISTS ${EXTERNAL_PACKAGES_PATH}/clhep-2.4.4.1) set(CLHEP_ROOT ${EXTERNAL_PACKAGES_PATH}/clhep-2.4.4.1) endif() endif() #find_package(CLHEP REQUIRED) # creates IMPORTED target CLHEP::CLHEP # ------- GSL: if((NOT GSL_ROOT) OR (NOT EXISTS ${CLHEP_ROOT})) if(EXISTS ${EXTERNAL_PACKAGES_PATH}/gsl-1.15) set(GSL_ROOT ${EXTERNAL_PACKAGES_PATH}/gsl-1.15) elseif(EXISTS ${EXTERNAL_PACKAGES_PATH}/gsl-2.7) set(GSL_ROOT ${EXTERNAL_PACKAGES_PATH}/gsl-2.7) endif() endif() find_package(GSL REQUIRED) # creates IMPORTED target GSL::gsl # ------- zLib (this package is currently NOT part of ICEDUST_externals_source) # this means it has to be compiled seperately beforehand! -- TODO (?) # One can give a PATH to find specific versions by setting "ZLIB_ROOT" find_package(ZLIB REQUIRED) # creates IMPORTED target ZLIB::ZLIB # ------- GEANT4: # find_packages uses "Geant4Config.cmake" provided by GEANT4 if((NOT GEANT4_ROOT) OR (NOT EXISTS ${GEANT4_ROOT})) if((BUILD_GEANT4_VERSION STREQUAL "4.10.6")) set(GEANT4_ROOT ${EXTERNAL_PACKAGES_PATH}/geant4.10.06.p03) elseif((BUILD_GEANT4_VERSION STREQUAL "4.10.4")) set(GEANT4_ROOT ${EXTERNAL_PACKAGES_PATH}/geant4.10.04.p03) endif() endif() list(APPEND CMAKE_PREFIX_PATH ${GEANT4_ROOT}) find_package(Geant4 REQUIRED) include(${Geant4_USE_FILE}) # ------- GENFIT: if((NOT GENFIT_ROOT) OR (NOT EXISTS ${GENFIT_ROOT})) set(GENFIT_ROOT ${EXTERNAL_PACKAGES_PATH}/genfit_2.2.0) endif() find_package(GENFIT REQUIRED) # creates IMPORTED target GENFIT::GENFIT # ------- EIGEN3: if((NOT EIGEN3_ROOT) OR (NOT EXISTS ${EIGEN3_ROOT})) set(EIGEN3_ROOT "${EXTERNAL_PACKAGES_PATH}/eigen3_3.3.4") endif() find_package(EIGEN3 REQUIRED) # Genfit 2.2 (req. for ROOT6) requires Eigen3 headers > Set transitive # link interface of genfit! set_target_properties(GENFIT::GENFIT PROPERTIES INTERFACE_LINK_LIBRARIES EIGEN3::EIGEN3) # ------- GARFIELD: if((NOT GARFIELD_ROOT) OR (NOT EXISTS ${GARFIELD_ROOT})) set(GARFIELD_ROOT ${EXTERNAL_PACKAGES_PATH}/garfield_patched_15b8e1fe) endif() find_package(GARFIELD REQUIRED) # creates IMPORTED target GARFIELD::GARFIELD # ------- PYTHON: if((NOT PYTHON_ROOT) OR (NOT EXISTS ${PYTHON_ROOT})) set(PYTHON_ROOT ${EXTERNAL_PACKAGES_PATH}/python-2.7.15) endif() # ------- GOUPIL: if((NOT GOUPIL_ROOT) OR (NOT EXISTS ${GOUPIL_ROOT})) set(GOUPIL_ROOT ${EXTERNAL_PACKAGES_PATH}/goupil_v1.0) endif() find_package(GOUPIL REQUIRED) # TODO: Recpack # TODO: SQLITE # --- Set default make rules for a CXX build (initialization of the compiler flags) --- # GNU C++ or Clang/AppleClang Compiler on all(?) platforms # IMPORTANT: If CMAKE identifies the compiler, it sets some distinct variables for each build type # CMake will create by default the following variables when using a single-configuration generator: #None (CMAKE_C_FLAGS or CMAKE_CXX_FLAGS used) || always used in addition to one of: #Debug (CMAKE_C_FLAGS_DEBUG or CMAKE_CXX_FLAGS_DEBUG) #Release (CMAKE_C_FLAGS_RELEASE or CMAKE_CXX_FLAGS_RELEASE) #RelWithDebInfo (CMAKE_C_FLAGS_RELWITHDEBINFO or CMAKE_CXX_FLAGS_RELWITHDEBINFO #MinSizeRel (CMAKE_C_FLAGS_MINSIZEREL or CMAKE_CXX_FLAGS_MINSIZEREL) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") set(CMAKE_CXX_FLAGS_INIT -pipe -fpic -Wall -Wctor-dtor-privacy -Woverloaded-virtual -Wnon-virtual-dtor -Wno-ignored-qualifiers -Wno-unused-parameter -Wno-unused-variable -Wno-pedantic) set(CMAKE_CXX_FLAGS_RELEASE_INIT -O3 -DNDEBUG) set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT -Os -DNDEBUG) set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT -O2 -g) endif() # --- add subdirectories where CMakeLists of single packages are found --- ######################### ## IcedustXYZ packages ## ######################### # Copy bunch of python scripts: add_subdirectory(${PROJECT_SOURCE_DIR}/IcedustControl) add_subdirectory(${PROJECT_SOURCE_DIR}/IcedustTest) add_subdirectory(${PROJECT_SOURCE_DIR}/IcedustValidate) # Old way to build externals, not required anymore: #add_subdirectory(${PROJECT_SOURCE_DIR}/IcedustExternal) # Old way to set up cppflags and manage version fragments, not required anymore: #add_subdirectory(${PROJECT_SOURCE_DIR}/IcedustPolicy) # No idea what this was used for... #add_subdirectory(${PROJECT_SOURCE_DIR}/IcedustVerify) ##################### ## OfflineProject ## ##################### # cometBase add_subdirectory(${PROJECT_SOURCE_DIR}/oaEvent) add_subdirectory(${PROJECT_SOURCE_DIR}/oaEMField) add_subdirectory(${PROJECT_SOURCE_DIR}/EventLoop) add_subdirectory(${PROJECT_SOURCE_DIR}/oaRawEvent) add_subdirectory(${PROJECT_SOURCE_DIR}/oaRooTracker) add_subdirectory(${PROJECT_SOURCE_DIR}/oaRuntimeParameters) add_subdirectory(${PROJECT_SOURCE_DIR}/oaSlowControlDatabase) add_subdirectory(${PROJECT_SOURCE_DIR}/oaOfflineDatabase) add_subdirectory(${PROJECT_SOURCE_DIR}/oaCalibTables) add_subdirectory(${PROJECT_SOURCE_DIR}/oaChanInfo) add_subdirectory(${PROJECT_SOURCE_DIR}/oaGeomInfo) add_subdirectory(${PROJECT_SOURCE_DIR}/oaApplyAlign) # cometSim add_subdirectory(${PROJECT_SOURCE_DIR}/SimG4) add_subdirectory(${PROJECT_SOURCE_DIR}/SimHitMerger) add_subdirectory(${PROJECT_SOURCE_DIR}/SimDetectorResponse) add_subdirectory(${PROJECT_SOURCE_DIR}/oaCherryPicker) add_subdirectory(${PROJECT_SOURCE_DIR}/SimBackwardMC) add_subdirectory(${PROJECT_SOURCE_DIR}/SimCDCGAN) # DisplayCore add_subdirectory(${PROJECT_SOURCE_DIR}/DisplayCore) # AnalysisBase add_subdirectory(${PROJECT_SOURCE_DIR}/AnalysisBase) # Additional documentation add_subdirectory(${PROJECT_SOURCE_DIR}/IcedustDoc) ####################### ## ProductionProject ## ####################### # single Packages (Calib) add_subdirectory(${PROJECT_SOURCE_DIR}/oaCalibReconBase) add_subdirectory(${PROJECT_SOURCE_DIR}/CalibGlobal) # Currently disabled duo to work in progess for IHit data structure. #[[ add_subdirectory(${PROJECT_SOURCE_DIR}/CalibECAL) # comet Recon add_subdirectory(${PROJECT_SOURCE_DIR}/ReconTrackFinding) add_subdirectory(${PROJECT_SOURCE_DIR}/ReconTrackFitting) add_subdirectory(${PROJECT_SOURCE_DIR}/ReconECAL) add_subdirectory(${PROJECT_SOURCE_DIR}/ReconCyDet) ]] ######################## ## Currently not used ## ######################## # --- CMakeLists available, but not build: # CalibMagnet # oaBeamData # oaDataQuality # oaUnpack #ITpcBank.hxx missing (for IFGDDigitFactory.hxx) # SimCosmicTrigger #ITFBChannelId.hxx missing (for ITripTTrigger.hxx) # ReconTools #IHitFilter.hxx missing (for createIReconTrack.cxx) # --- Unused / Todo: # SimCosmicTrigger # oaUtility # ReconGlobal # ReconStrawTrk # MONITORS # SimFLUKA # SimMARS # SimPHITS # oaControlSample # ReconFGD packages "used" but not available anymore # oaAlignTools # ReconFGD and ReconP0D packages "used" but not available anymore # oaAnalysis # oaRecPack packages "used" but not available anymore # CalibOffline # oaRecPack and ReconTPC packages "used" but not available anymore # --- Creating the setup.sh / BUILD_setup.sh scripts --- ICEDUST_CREATE_SETUP_SCRIPT(TYPE build) ICEDUST_CREATE_SETUP_SCRIPT(TYPE install)