Skip to content
Snippets Groups Projects
Commit 571726b3 authored by Administrator's avatar Administrator Committed by Pierre-Alain Loizeau
Browse files

Clean build system

Restructure code in the main CMakeLists.txt
parent 59638da0
No related branches found
No related tags found
1 merge request!883Clean build system
...@@ -2,30 +2,55 @@ ...@@ -2,30 +2,55 @@
# refer to the root source directory of the project as ${CBMROOT_SOURCE_DIR} or # refer to the root source directory of the project as ${CBMROOT_SOURCE_DIR} or
# as ${CMAKE_SOURCE_DIR} and to the root binary directory of the project as # as ${CMAKE_SOURCE_DIR} and to the root binary directory of the project as
# ${CBMROOT_BINARY_DIR} or ${CMAKE_BINARY_DIR}. # ${CBMROOT_BINARY_DIR} or ${CMAKE_BINARY_DIR}.
# This difference is important for the base classes which are in CBMROOT
# and PANDAROOT.
# Check if cmake has the required version # Check if cmake has the required version
# For the CTest fixtures at least CMake 3.7.2 is needed.
# Since flesnet requires 3.14.0 we should be consistent while we # Since flesnet requires 3.14.0 we should be consistent while we
# build it in the CbmRoot context # build it in the CbmRoot context
cmake_minimum_required(VERSION 3.14) cmake_minimum_required(VERSION 3.14.0 FATAL_ERROR)
cmake_policy(VERSION 3.14...3.23)
# Set name of our project to "CBMROOT". Has to be done
# after check of cmake version # Define compiler on macosx to avoid problems when comparing to compilers
project(CBMROOT) # used for FairSoft/FairRoot compilation
if(APPLE)
if(NOT DEFINED CMAKE_C_COMPILER)
set(CMAKE_C_COMPILER clang)
endif()
if(NOT DEFINED CMAKE_CXX_COMPILER)
set(CMAKE_CXX_COMPILER clang++)
endif()
endif()
# Default CMake settings
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
# Set the library version in the main CMakeLists.txt
set(CBMROOT_MAJOR_VERSION 22)
set(CBMROOT_MINOR_VERSION 2)
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
VERSION ${CBMROOT_MAJOR_VERSION}.${CBMROOT_MINOR_VERSION}.${CBMROOT_PATCH_VERSION}
LANGUAGES C CXX
)
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/
# is checked
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
# Load some basic cmake functionality
include(ExternalProject)
include(CTest)
# Make the CbmRoot cmake functions available # Make the CbmRoot cmake functions available
list(PREPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules") list(PREPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
include(CbmChecks) include(CbmChecks)
include(CbmGenerateConfig) include(CbmGenerateConfig)
# Load some basic macros which are needed later on
include(CbmMacros) include(CbmMacros)
include(CbmTargets) include(CbmTargets)
include(CbmGenerateConfig)
include(CbmCompilerSettings) include(CbmCompilerSettings)
# Do some basic checks # Do some basic checks
...@@ -33,58 +58,72 @@ include(CbmCompilerSettings) ...@@ -33,58 +58,72 @@ include(CbmCompilerSettings)
# existence of FAIRROOTPATH and SIMPATH variables # existence of FAIRROOTPATH and SIMPATH variables
Check_Prerequisites() Check_Prerequisites()
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ # Load cmake functionality from the FairRoot installation
# is checked if(IS_DIRECTORY ${FAIRROOTPATH}/share/fairbase/cmake/modules)
list(APPEND CMAKE_MODULE_PATH "${FAIRROOTPATH}/share/fairbase/cmake/modules_old") list(APPEND CMAKE_MODULE_PATH "${FAIRROOTPATH}/share/fairbase/cmake/modules")
list(APPEND CMAKE_MODULE_PATH "${FAIRROOTPATH}/share/fairbase/cmake/modules") endif()
if(IS_DIRECTORY ${FAIRROOTPATH}/share/fairbase/cmake/modules_old)
list(APPEND CMAKE_MODULE_PATH "${FAIRROOTPATH}/share/fairbase/cmake/modules_old")
endif()
include(FairMacros)
include(WriteConfigFile)
include(CheckCompiler)
set(CMAKE_PREFIX_PATH ${SIMPATH} ${CMAKE_PREFIX_PATH})
set(CMAKE_INSTALL_LIBDIR lib)
# Has to be called after the CMAKE_MODULE_PATH contains the FairRoot
# directories since the file is part of FairRoot
set(FairRoot_DIR ${FAIRROOTPATH}) set(FairRoot_DIR ${FAIRROOTPATH})
find_package(FairRoot) find_package(FairRoot REQUIRED)
include(FairMacros)
include(WriteConfigFile)
include(CTest)
include(CheckCompiler)
Include(ExternalProject)
# Check if the compiler supports the needed C++ standard # Check if the compiler supports the needed C++ standard
# Check for the minimum required versions of FairSoft and FairRoot # Check for the minimum required versions of FairSoft and FairRoot
check_external_stack() check_external_stack()
# Set the compiler flags # Set the compiler flags
set_compiler_flags() set_compiler_flags()
# Allow to find <package>Config.cmake files in the FairSoft installation
set(CMAKE_PREFIX_PATH ${SIMPATH} ${CMAKE_PREFIX_PATH})
# Define where the produced targets are placed in the binary directory
Set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib") Set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib")
Set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin") Set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")
Set(INCLUDE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/include") Set(INCLUDE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/include")
set(CMAKE_INSTALL_LIBDIR lib)
# VMCWORKDIR is needed by the CbmRoot runtime to find macros, geometries and
# parameters
Set(VMCWORKDIR ${CBMROOT_SOURCE_DIR}) Set(VMCWORKDIR ${CBMROOT_SOURCE_DIR})
# Set library versioning
set(FAIRROOT_LIBRARY_PROPERTIES ${FAIRROOT_LIBRARY_PROPERTIES}
VERSION "${CBMROOT_VERSION}"
SOVERSION "${CBMROOT_MAJOR_VERSION}"
)
# searches for needed packages # searches for needed packages
# REQUIRED means that cmake will stop if this packages are not found # REQUIRED means that cmake will stop if this packages are not found
# For example the framework can run without GEANT4, but ROOT is # For example the framework can run without GEANT4, but ROOT is
# mandatory # mandatory
find_package(ROOT 6.00.00 REQUIRED) find_package(ROOT 6.22.08 REQUIRED)
if("${ROOT_VERSION_MAJOR}.${ROOT_VERSION_MINOR}" VERSION_GREATER 6.16) if("${ROOT_VERSION_MAJOR}.${ROOT_VERSION_MINOR}" VERSION_LESS 6.26)
if("${ROOT_VERSION_MAJOR}.${ROOT_VERSION_MINOR}" VERSION_LESS 6.26) Execute_Process(COMMAND ${ROOT_CONFIG_EXECUTABLE} --has-vmc
Execute_Process(COMMAND ${ROOT_CONFIG_EXECUTABLE} --has-vmc OUTPUT_VARIABLE ROOT_vmc_FOUND
OUTPUT_VARIABLE ROOT_vmc_FOUND )
)
String(STRIP ${ROOT_vmc_FOUND} ROOT_vmc_FOUND)
String(STRIP ${ROOT_vmc_FOUND} ROOT_vmc_FOUND) If(NOT ROOT_vmc_FOUND)
If(NOT ROOT_vmc_FOUND)
set(CMAKE_PREFIX_PATH ${SIMPATH} ${CMAKE_PREFIX_PATH})
find_package2(PUBLIC VMC REQUIRED)
set(VMCLIB VMCLibrary)
endif()
else()
set(CMAKE_PREFIX_PATH ${SIMPATH} ${CMAKE_PREFIX_PATH}) set(CMAKE_PREFIX_PATH ${SIMPATH} ${CMAKE_PREFIX_PATH})
find_package2(PUBLIC VMC REQUIRED) find_package2(PUBLIC VMC REQUIRED)
set(VMCLIB VMCLibrary) set(VMCLIB VMCLibrary)
endif() endif()
else()
set(CMAKE_PREFIX_PATH ${SIMPATH} ${CMAKE_PREFIX_PATH})
find_package2(PUBLIC VMC REQUIRED)
set(VMCLIB VMCLibrary)
endif() endif()
find_package2(PUBLIC Geant3 REQUIRED) find_package2(PUBLIC Geant3 REQUIRED)
...@@ -102,7 +141,6 @@ find_package(GEANT4DATA) ...@@ -102,7 +141,6 @@ find_package(GEANT4DATA)
find_package(GEANT4VMC) find_package(GEANT4VMC)
find_package(TBB) find_package(TBB)
find_package(SSE) find_package(SSE)
# find_package(IWYU)
find_package(ZeroMQ) find_package(ZeroMQ)
Set(Boost_NO_SYSTEM_PATHS TRUE) Set(Boost_NO_SYSTEM_PATHS TRUE)
...@@ -138,30 +176,12 @@ SetBasicVariables() ...@@ -138,30 +176,12 @@ SetBasicVariables()
SET(ROOT_INCLUDE_PATH ${ROOT_INCLUDE_PATH} "${Geant3_INCLUDE_DIRS}") SET(ROOT_INCLUDE_PATH ${ROOT_INCLUDE_PATH} "${Geant3_INCLUDE_DIRS}")
Set(BASE_INCLUDE_DIRECTORIES Set(BASE_INCLUDE_DIRECTORIES
${BASE_INCLUDE_DIRECTORIES} ${BASE_INCLUDE_DIRECTORIES}
${SYSTEM_INCLUDE_DIRECTORIES} ${SYSTEM_INCLUDE_DIRECTORIES}
${FAIRLOGGER_INCLUDE_DIR} ${FAIRLOGGER_INCLUDE_DIR}
${VMC_INCLUDE_DIRS} ${VMC_INCLUDE_DIRS}
) )
# Set the library version in the main CMakeLists.txt
SET(CBMROOT_MAJOR_VERSION 0)
SET(CBMROOT_MINOR_VERSION 0)
SET(CBMROOT_PATCH_VERSION 0)
SET(CBMROOT_VERSION "${CBMROOT_MAJOR_VERSION}.${CBMROOT_MINOR_VERSION}.${CBMROOT_PATCH_VERSION}")
If(NOT ROOT_FOUND_VERSION OR ROOT_FOUND_VERSION LESS 59999)
SET(FAIRROOT_LIBRARY_PROPERTIES ${FAIRROOT_LIBRARY_PROPERTIES}
VERSION "${CBMROOT_VERSION}"
SOVERSION "${CBMROOT_MAJOR_VERSION}"
SUFFIX ".so"
)
Else()
SET(FAIRROOT_LIBRARY_PROPERTIES ${FAIRROOT_LIBRARY_PROPERTIES}
VERSION "${CBMROOT_VERSION}"
SOVERSION "${CBMROOT_MAJOR_VERSION}"
)
EndIf()
SET(CBMLIBDIR ${CMAKE_BINARY_DIR}/lib) SET(CBMLIBDIR ${CMAKE_BINARY_DIR}/lib)
SET(LD_LIBRARY_PATH ${CBMLIBDIR} ${Boost_LIBRARY_DIRS} ${LD_LIBRARY_PATH}) SET(LD_LIBRARY_PATH ${CBMLIBDIR} ${Boost_LIBRARY_DIRS} ${LD_LIBRARY_PATH})
...@@ -186,7 +206,9 @@ endif() ...@@ -186,7 +206,9 @@ endif()
### Subdirectories to be compiled ##### ### Subdirectories to be compiled #####
### Externals included and build from sveral sources ### Externals included and build from several sources
# Must be the first subdirectory since the defined targets are needed by
# following targets
add_subdirectory (external) add_subdirectory (external)
### Base directories ### Base directories
...@@ -208,17 +230,18 @@ endif() ...@@ -208,17 +230,18 @@ endif()
add_subdirectory (macro) add_subdirectory (macro)
add_subdirectory(fles) add_subdirectory(fles)
If(FAIRMQ_FOUND) If(FAIRMQ_FOUND)
add_subdirectory(MQ) add_subdirectory(MQ)
EndIf() EndIf()
add_subdirectory(tutorials) add_subdirectory(tutorials)
Option(BUILD_DOXYGEN "Build Doxygen" OFF) option(BUILD_DOXYGEN "Build Doxygen" OFF)
if(BUILD_DOXYGEN) if(BUILD_DOXYGEN)
MESSAGE(STATUS "*** Building the Doxygen documentaion ***") message(STATUS "*** Building the Doxygen documentaion ***")
ADD_SUBDIRECTORY(doxygen) add_subdirectory(doxygen)
endif(BUILD_DOXYGEN) endif()
# Definde additional targets # Definde additional targets
# cleanlib: rm al Cbm libraries and dictionaries # cleanlib: rm al Cbm libraries and dictionaries
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment