diff --git a/CMakeLists.txt b/CMakeLists.txt index e5033d5e9f..d3b8491b0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,18 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 3.5.2 FATAL_ERROR) + +### CMP0025 Compiler id for Apple Clang is now AppleClang. +### CMP0042 MACOSX_RPATH is enabled by default. + +FOREACH (p + CMP0025 # CMake 3.0 + CMP0042 # CMake 3.0 + ) + IF (POLICY ${p}) + cmake_policy(SET ${p} NEW) + ENDIF () +endforeach () + + add_subdirectory(Framework) add_subdirectory(Modules) add_subdirectory(doc) diff --git a/Framework/CMakeLists.txt b/Framework/CMakeLists.txt index b68195cfa7..dc96bc53fd 100644 --- a/Framework/CMakeLists.txt +++ b/Framework/CMakeLists.txt @@ -2,20 +2,6 @@ # General project definition #################################### -CMAKE_MINIMUM_REQUIRED(VERSION 3.5.2 FATAL_ERROR) - -### CMP0025 Compiler id for Apple Clang is now AppleClang. -### CMP0042 MACOSX_RPATH is enabled by default. - -FOREACH (p - CMP0025 # CMake 3.0 - CMP0042 # CMake 3.0 - ) - IF (POLICY ${p}) - cmake_policy(SET ${p} NEW) - ENDIF () -endforeach () - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) # project specific cmake dir set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) @@ -24,7 +10,6 @@ project(QualityControl) # Load some basic macros which are needed later on include(O2Utils) include(QualityControlDependencies) -include(O2) # to be removed # TODO make it required, once in its own repo if(ROOT_FOUND) diff --git a/Modules/CMakeLists.txt b/Modules/CMakeLists.txt index 1cd6fbba05..bac5b103d8 100644 --- a/Modules/CMakeLists.txt +++ b/Modules/CMakeLists.txt @@ -21,7 +21,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) project(QualityControlModules) # Load some basic macros which are needed later on -include(O2) include(O2Utils) include(QualityControlDependencies) @@ -64,8 +63,6 @@ ENDIF () # Add compiler flags for warnings and (more importantly) fPIC and debug symbols set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wextra -fPIC") -link_o2_subproject(QualityControl) - add_subdirectory(Common) add_subdirectory(Example) add_subdirectory(Skeleton) diff --git a/cmake/CPackConfig.cmake b/cmake/CPackConfig.cmake deleted file mode 100644 index bda29ba1ee..0000000000 --- a/cmake/CPackConfig.cmake +++ /dev/null @@ -1,89 +0,0 @@ -# @author Barthélémy von Haller - -# General CPack configuration -# Info: http://www.itk.org/Wiki/CMake:Component_Install_With_CPack -# _____________________________________________________________________________ - -set(CPACK_PACKAGE_NAME "QualityControl${VERSION_MAJOR}") - -if(APPLE) - set(CPACK_PACKAGE_VENDOR "ALICE") # PackageMaker doesn't like http:// -else() - set(CPACK_PACKAGE_VENDOR "http://aliceinfo.cern.ch") # deb lintian insists on URL -endif() - -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Example project") -set(CPACK_PACKAGE_CONTACT "Barthelemy von Haller ") -set(CPACK_PACKAGE_VERSION ${VERSION}) -set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR}) -set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR}) -set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH}) -set(CPACK_RPM_PACKAGE_DEBUG 0) - -# Select package generator -if(MSVC) - set(CPACK_GENERATOR "NSIS") -endif(MSVC) - -if(APPLE) - set(CPACK_GENERATOR "PackageMaker") - set(CPACK_SET_DESTDIR ON) -endif(APPLE) - -if (${CMAKE_SYSTEM_NAME} MATCHES Linux) - find_program(RPM_EXE rpmbuild) - if(${RPM_EXE} MATCHES RPM_EXE-NOTFOUND) - set(CPACK_GENERATOR "TGZ;DEB") - else() - set(CPACK_GENERATOR "TGZ;DEB;RPM") - endif() -endif(${CMAKE_SYSTEM_NAME} MATCHES Linux) - -# Components -# _____________________________________________________________________________ -set(CPACK_COMPONENT_INSTALL ON) -set(CPACK_COMPONENTS_ALL libs dev apps docs) - -set(CPACK_COMPONENT_LIBS_DISPLAY_NAME "Libraries") -set(CPACK_COMPONENT_LIBS_DESCRIPTION "Runtime Libraries") -set(CPACK_COMPONENT_LIBS_GROUP "Runtime") -# express component dependencies this way, it will translate into package dependencies where applicable -set(CPACK_COMPONENT_LIBS_DEPENDS docs) # dependency on another group - -set(CPACK_COMPONENT_APPS_DISPLAY_NAME "Applications") -set(CPACK_COMPONENT_APPS_DESCRIPTION "Example Programs") -set(CPACK_COMPONENT_APPS_GROUP "Runtime") -set(CPACK_COMPONENT_APPS_DEPENDS libs docs) # dependency within the same group (lib) and another (docs), but second time from the same group - -set(CPACK_COMPONENT_DEV_DISPLAY_NAME "Development files") -set(CPACK_COMPONENT_DEV_DESCRIPTION "Development header files and libraries") -set(CPACK_COMPONENT_DEV_GROUP "Development") -set(CPACK_COMPONENT_DEV_DEPENDS libs) # dependency on another group - -set(CPACK_COMPONENT_DOCS_DISPLAY_NAME "Documents") -set(CPACK_COMPONENT_DOCS_DESCRIPTION "User Documentation") -#set(CPACK_COMPONENT_DOCS_GROUP "Documentation") - -# see www.cmake.org/Wiki/CMake:Component_Install_With_CPack#Controlling_Differents_Ways_of_packaging_components -#set(CPACK_COMPONENTS_GROUPING "ALL_COMPONENTS_IN_ONE") # IGNORE, ONE_PER_GROUP (default), ALL_COMPONENTS_IN_ONE - -# Debian specific configuration (minimum) -# _____________________________________________________________________________ - -set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_PACKAGE_CONTACT}") -SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.3.1-6), libboost-test-dev") - -# RPM specific configuration (minimum) -# _____________________________________________________________________________ -set(CPACK_RPM_PACKAGE_LICENSE "Proprietary") -set(CPACK_RPM_PACKAGE_GROUP "Development/Libraries") -set(CPACK_RPM_PACKAGE_VERSION ${VERSION}) -set(CPACK_RPM_COMPONENT_INSTALL ON) # necessary even if CPACK_COMPONENT_INSTALL set to ON. A bug in my opinion. - - -# OS X PackageMaker -# _____________________________________________________________________________ -set(CPACK_OSX_PACKAGE_VERSION "10.5") - -include (InstallRequiredSystemLibraries) -include (CPack) diff --git a/cmake/FindCommon.cmake b/cmake/FindCommon.cmake new file mode 100644 index 0000000000..6894dd8454 --- /dev/null +++ b/cmake/FindCommon.cmake @@ -0,0 +1,36 @@ +# - Try to find the O2 Common package include dirs and libraries +# Author: Barthelemy von Haller +# +# This script will set the following variables: +# Common_FOUND - System has Common +# Common_INCLUDE_DIRS - The Common include directories +# Common_LIBRARIES - The libraries needed to use Common +# Common_DEFINITIONS - Compiler switches required for using Common +# +# This script can use the following variables: +# Common_ROOT - Installation root to tell this module where to look. (it tries LD_LIBRARY_PATH otherwise) + +# Init +include(FindPackageHandleStandardArgs) + +# find includes +find_path(COMMON_INCLUDE_DIR Timer.h + HINTS ${Common_ROOT}/include ENV LD_LIBRARY_PATH PATH_SUFFIXES "../include/Common" "../../include/Common" ) +# Remove the final "Common" +get_filename_component(COMMON_INCLUDE_DIR ${COMMON_INCLUDE_DIR} DIRECTORY) +set(Common_INCLUDE_DIRS ${COMMON_INCLUDE_DIR}) + +# find library +find_library(COMMON_LIBRARY NAMES Common HINTS ${Common_ROOT}/lib ENV LD_LIBRARY_PATH) +set(Common_LIBRARIES ${COMMON_LIBRARY}) + +# handle the QUIETLY and REQUIRED arguments and set COMMON_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(Common "Common could not be found. Install package Common or set Common_ROOT to its root installation directory." + COMMON_LIBRARY COMMON_INCLUDE_DIR) + +if(${COMMON_FOUND}) + message(STATUS "Common found : ${Common_LIBRARIES}") +endif() + +mark_as_advanced(COMMON_INCLUDE_DIR COMMON_LIBRARY) diff --git a/cmake/FindConfiguration.cmake b/cmake/FindConfiguration.cmake new file mode 100644 index 0000000000..b6cc5887ea --- /dev/null +++ b/cmake/FindConfiguration.cmake @@ -0,0 +1,36 @@ +# - Try to find the O2 Configuration package include dirs and libraries +# Author: Barthelemy von Haller +# +# This script will set the following variables: +# Configuration_FOUND - System has Configuration +# Configuration_INCLUDE_DIRS - The Configuration include directories +# Configuration_LIBRARIES - The libraries needed to use Configuration +# Configuration_DEFINITIONS - Compiler switches required for using Configuration +# +# This script can use the following variables: +# Configuration_ROOT - Installation root to tell this module where to look. (it tries LD_LIBRARY_PATH otherwise) + +# Init +include(FindPackageHandleStandardArgs) + +# find includes +find_path(CONFIGURATION_INCLUDE_DIR Configuration.h + HINTS ${Configuration_ROOT}/include ENV LD_LIBRARY_PATH PATH_SUFFIXES "../include/Configuration" "../../include/Configuration" ) +# Remove the final "Configuration" +get_filename_component(CONFIGURATION_INCLUDE_DIR ${CONFIGURATION_INCLUDE_DIR} DIRECTORY) +set(Configuration_INCLUDE_DIRS ${CONFIGURATION_INCLUDE_DIR}) + +# find library +find_library(CONFIGURATION_LIBRARY NAMES Configuration HINTS ${Configuration_ROOT}/lib ENV LD_LIBRARY_PATH) +set(Configuration_LIBRARIES ${CONFIGURATION_LIBRARY}) + +# handle the QUIETLY and REQUIRED arguments and set CONFIGURATION_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(Configuration "Configuration could not be found. Install package Configuration or set Configuration_ROOT to its root installation directory." + CONFIGURATION_LIBRARY CONFIGURATION_INCLUDE_DIR) + +if(${CONFIGURATION_FOUND}) + message(STATUS "Configuration found : ${Configuration_LIBRARIES}") +endif() + +mark_as_advanced(CONFIGURATION_INCLUDE_DIR CONFIGURATION_LIBRARY) diff --git a/cmake/FindDataSampling.cmake b/cmake/FindDataSampling.cmake new file mode 100644 index 0000000000..49c1ccccd6 --- /dev/null +++ b/cmake/FindDataSampling.cmake @@ -0,0 +1,36 @@ +# - Try to find the O2 DataSampling package include dirs and libraries +# Author: Barthelemy von Haller +# +# This script will set the following variables: +# DataSampling_FOUND - System has DataSampling +# DataSampling_INCLUDE_DIRS - The DataSampling include directories +# DataSampling_LIBRARIES - The libraries needed to use DataSampling +# DataSampling_DEFINITIONS - Compiler switches required for using DataSampling +# +# This script can use the following variables: +# DataSampling_ROOT - Installation root to tell this module where to look. (it tries LD_LIBRARY_PATH otherwise) + +# Init +include(FindPackageHandleStandardArgs) + +# find includes +find_path(DATASAMPLING_INCLUDE_DIR SamplerInterface.h + HINTS ${DataSampling_ROOT}/include ENV LD_LIBRARY_PATH PATH_SUFFIXES "../include/DataSampling" "../../include/DataSampling" ) +# Remove the final "DataSampling" +get_filename_component(DATASAMPLING_INCLUDE_DIR ${DATASAMPLING_INCLUDE_DIR} DIRECTORY) +set(DataSampling_INCLUDE_DIRS ${DATASAMPLING_INCLUDE_DIR}) + +# find library +find_library(DATASAMPLING_LIBRARY NAMES DataSampling HINTS ${DataSampling_ROOT}/lib ENV LD_LIBRARY_PATH) +set(DataSampling_LIBRARIES ${DATASAMPLING_LIBRARY}) + +# handle the QUIETLY and REQUIRED arguments and set DATASAMPLING_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(DataSampling "DataSampling could not be found. Install package DataSampling or set DataSampling_ROOT to its root installation directory." + DATASAMPLING_LIBRARY DATASAMPLING_INCLUDE_DIR) + +if(${DataSampling_FOUND}) + message(STATUS "DataSampling found : ${DataSampling_LIBRARIES}") +endif() + +mark_as_advanced(DATASAMPLING_INCLUDE_DIR DATASAMPLING_LIBRARY) diff --git a/cmake/FindFairRoot.cmake b/cmake/FindFairRoot.cmake new file mode 100644 index 0000000000..0abcea09f8 --- /dev/null +++ b/cmake/FindFairRoot.cmake @@ -0,0 +1,58 @@ + ################################################################################ + # Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # + # # + # This software is distributed under the terms of the # + # GNU Lesser General Public Licence version 3 (LGPL) version 3, # + # copied verbatim in the file "LICENSE" # + ################################################################################ +# Find FairRoot installation +# Check the environment variable "FAIRROOTPATH" or "FAIRROOT_ROOT" + +if(FairRoot_DIR) + SET(FAIRROOTPATH ${FairRoot_DIR}) +elseif(DEFINED ENV{FAIRROOT_ROOT}) + SET(FAIRROOTPATH $ENV{FAIRROOT_ROOT}) +else() + if(NOT DEFINED ENV{FAIRROOTPATH}) + set(user_message "You did not define the environment variable FAIRROOTPATH or FAIRROOT_ROOT which are needed to find FairRoot.\nPlease set one of these variables and execute cmake again." ) + if(FairRoot_FIND_REQUIRED) + MESSAGE(FATAL_ERROR ${user_message}) + else(FairRoot_FIND_REQUIRED) + MESSAGE(WARNING ${user_message}) + return() + endif(FairRoot_FIND_REQUIRED) + endif(NOT DEFINED ENV{FAIRROOTPATH}) + + SET(FAIRROOTPATH $ENV{FAIRROOTPATH}) +endif() + +MESSAGE(STATUS "Setting FairRoot environment…") + +FIND_PATH(FAIRROOT_INCLUDE_DIR NAMES FairRun.h PATHS + ${FAIRROOTPATH}/include + NO_DEFAULT_PATH +) + +FIND_PATH(FAIRROOT_LIBRARY_DIR NAMES libBase.so libBase.dylib PATHS + ${FAIRROOTPATH}/lib + NO_DEFAULT_PATH +) + +FIND_PATH(FAIRROOT_CMAKEMOD_DIR NAMES CMakeLists.txt PATHS + ${FAIRROOTPATH}/share/fairbase/cmake + NO_DEFAULT_PATH +) + + +if(FAIRROOT_INCLUDE_DIR AND FAIRROOT_LIBRARY_DIR) + set(FAIRROOT_FOUND TRUE) + MESSAGE(STATUS "FairRoot ... - found ${FAIRROOTPATH}") + MESSAGE(STATUS "FairRoot Library directory : ${FAIRROOT_LIBRARY_DIR}") + MESSAGE(STATUS "FairRoot Include path… : ${FAIRROOT_INCLUDE_DIR}") + MESSAGE(STATUS "FairRoot Cmake Modules : ${FAIRROOT_CMAKEMOD_DIR}") + +else(FAIRROOT_INCLUDE_DIR AND FAIRROOT_LIBRARY_DIR) + set(FAIRROOT_FOUND FALSE) + #MESSAGE(FATAL_ERROR "FairRoot installation not found") +endif (FAIRROOT_INCLUDE_DIR AND FAIRROOT_LIBRARY_DIR) + diff --git a/cmake/FindInfoLogger.cmake b/cmake/FindInfoLogger.cmake new file mode 100644 index 0000000000..23c0b87244 --- /dev/null +++ b/cmake/FindInfoLogger.cmake @@ -0,0 +1,36 @@ +# - Try to find the O2 InfoLogger package include dirs and libraries +# Author: Barthelemy von Haller +# +# This script will set the following variables: +# InfoLogger_FOUND - System has InfoLogger +# InfoLogger_INCLUDE_DIRS - The InfoLogger include directories +# InfoLogger_LIBRARIES - The libraries needed to use InfoLogger +# InfoLogger_DEFINITIONS - Compiler switches required for using InfoLogger +# +# This script can use the following variables: +# InfoLogger_ROOT - Installation root to tell this module where to look. (it tries LD_LIBRARY_PATH otherwise) + +# Init +include(FindPackageHandleStandardArgs) + +# find includes +find_path(INFOLOGGER_INCLUDE_DIR InfoLogger.h + HINTS ${InfoLogger_ROOT}/include ENV LD_LIBRARY_PATH PATH_SUFFIXES "../include/InfoLogger" "../../include/InfoLogger" ) +# Remove the final "InfoLogger" +get_filename_component(INFOLOGGER_INCLUDE_DIR ${INFOLOGGER_INCLUDE_DIR} DIRECTORY) +set(InfoLogger_INCLUDE_DIRS ${INFOLOGGER_INCLUDE_DIR}) + +# find library +find_library(INFOLOGGER_LIBRARY NAMES InfoLogger HINTS ${InfoLogger_ROOT}/lib ENV LD_LIBRARY_PATH) +set(InfoLogger_LIBRARIES ${INFOLOGGER_LIBRARY}) + +# handle the QUIETLY and REQUIRED arguments and set INFOLOGGER_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(InfoLogger "InfoLogger could not be found. Install package InfoLogger or set InfoLogger_ROOT to its root installation directory." + INFOLOGGER_LIBRARY INFOLOGGER_INCLUDE_DIR) + +if(${InfoLogger_FOUND}) + message(STATUS "InfoLogger found : ${InfoLogger_LIBRARIES}") +endif() + +mark_as_advanced(INFOLOGGER_INCLUDE_DIR INFOLOGGER_LIBRARY) diff --git a/cmake/FindMonitoring.cmake b/cmake/FindMonitoring.cmake new file mode 100644 index 0000000000..453061c7eb --- /dev/null +++ b/cmake/FindMonitoring.cmake @@ -0,0 +1,43 @@ +# - Tries to find the O2 Monitoring package (include dir and library) +# Author: Barthelemy von Haller +# Author: Adam Wegrzynek +# +# +# This module will set the following non-cached variables: +# Monitoring_FOUND - states whether Monitoring package has been found +# Monitoring_INCLUDE_DIRS - Monitoring include directory +# Monitoring_LIBRARIES - Monitoring library filepath +# Monitoring_DEFINITIONS - Compiler definitions when comping code using Monitoring +# +# Also following cached variables, but not for general use, are defined: +# MONITORING_INCLUDE_DIR +# MONITORING_LIBRARY +# +# This module respects following variables: +# Monitoring_ROOT - Installation root directory (otherwise it goes through LD_LIBRARY_PATH and ENV) + +# Init +include(FindPackageHandleStandardArgs) + +# find includes +find_path(MONITORING_INCLUDE_DIR Collector.h + HINTS ${Monitoring_ROOT}/include ENV LD_LIBRARY_PATH PATH_SUFFIXES "../include/Monitoring" "../../include/Monitoring" ) + +# Remove the final "Monitoring" +get_filename_component(MONITORING_INCLUDE_DIR ${MONITORING_INCLUDE_DIR} DIRECTORY) +set(Monitoring_INCLUDE_DIRS ${MONITORING_INCLUDE_DIR}) + +# find library +find_library(MONITORING_LIBRARY NAMES Monitoring HINTS ${Monitoring_ROOT}/lib ENV LD_LIBRARY_PATH) +set(Monitoring_LIBRARIES ${MONITORING_LIBRARY}) + +# handle the QUIETLY and REQUIRED arguments and set Monitoring_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(Monitoring "Monitoring could not be found. Set Monitoring_ROOT as root installation directory." + MONITORING_LIBRARY MONITORING_INCLUDE_DIR) +if(${Monitoring_FOUND}) + set(Monitoring_DEFINITIONS "") + message(STATUS "Monitoring found : ${Monitoring_LIBRARIES}") +endif() + +mark_as_advanced(MONITORING_INCLUDE_DIR MONITORING_LIBRARY) diff --git a/cmake/FindMySQL.cmake b/cmake/FindMySQL.cmake new file mode 100644 index 0000000000..2445b33a01 --- /dev/null +++ b/cmake/FindMySQL.cmake @@ -0,0 +1,47 @@ +# - Find mysqlclient +# Find the native MySQL includes and library +# +# MYSQL_INCLUDE_DIRS - where to find mysql.h, etc. +# MYSQL_LIBRARIES - List of libraries when using MySQL. +# MYSQL_FOUND - True if MySQL found. + +# MYSQL_PATH_SUFFIXES - by default it includes "mysql". Set it if you want to force extra suffixes to be used. + +if(NOT MYSQL_PATH_SUFFIXES) + set(MYSQL_PATH_SUFFIXES "" "mysql") +endif() + +FIND_PATH(MYSQL_INCLUDE_DIRS mysql.h + /usr/local/include/mysql + /usr/include/mysql +) + +SET(MYSQL_NAMES mysqlclient mysqlclient_r) +FIND_LIBRARY(MYSQL_LIBRARY + NAMES ${MYSQL_NAMES} + PATHS /usr/lib /usr/lib64 /usr/local/lib + PATH_SUFFIXES ${MYSQL_PATH_SUFFIXES} +) + +IF (MYSQL_INCLUDE_DIRS AND MYSQL_LIBRARY) + SET(MYSQL_FOUND TRUE) + SET( MYSQL_LIBRARIES ${MYSQL_LIBRARY} ) +ELSE (MYSQL_INCLUDE_DIRS AND MYSQL_LIBRARY) + SET(MYSQL_FOUND FALSE) + UNSET(MYSQL_LIBRARIES CACHE) + UNSET(MYSQL_INCLUDE_DIRS CACHE) +ENDIF (MYSQL_INCLUDE_DIRS AND MYSQL_LIBRARY) + +IF (MYSQL_FOUND) + MESSAGE(STATUS "Found MySQL: ${MYSQL_LIBRARY}") +ELSE (MYSQL_FOUND) + IF (MYSQL_FIND_REQUIRED) + MESSAGE(STATUS "Looked for MySQL libraries named ${MYSQL_NAMES}.") + MESSAGE(FATAL_ERROR "Could NOT find MySQL library") + ENDIF (MYSQL_FIND_REQUIRED) +ENDIF (MYSQL_FOUND) + +MARK_AS_ADVANCED( + MYSQL_LIBRARY + MYSQL_INCLUDE_DIRS +) diff --git a/cmake/FindROOT.cmake b/cmake/FindROOT.cmake new file mode 100644 index 0000000000..68ff4a798d --- /dev/null +++ b/cmake/FindROOT.cmake @@ -0,0 +1,182 @@ + ################################################################################ + # Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # + # # + # This software is distributed under the terms of the # + # GNU Lesser General Public Licence version 3 (LGPL) version 3, # + # copied verbatim in the file "LICENSE" # + ################################################################################ +# - Find ROOT instalation +# This module tries to find the ROOT installation on your system. +# It tries to find the root-config script which gives you all the needed +# information. +# If the system variable ROOTSYS is set this is straight forward. +# If not the module uses the pathes given in ROOT_CONFIG_SEARCHPATH. +# If you need an other path you should add this path to this varaible. +# The root-config script is then used to detect basically everything else. +# This module defines a number of key variables and macros. +# +# Variables defined by this module: +# +# ROOT_FOUND System has ROOT, this means the root-config +# executable was found. +# +# ROOT_INCLUDE_DIR ROOT include directories: not cached +# +# ROOT_INCLUDES Same as above, +# +# ROOT_LIBRARIES Link to these to use the ROOT libraries, not cached +# +# ROOT_LIBRARY_DIR The path to where the ROOT library files are. +# +# ROOT_VERSION_STRING The version string of the ROOT libraries which +# is reported by root-config +# +# ROOT_VERSION_MAJOR Major version number of ROOT +# ROOT_VERSION_MINOR Minor version number of ROOT +# ROOT_VERSION_PATCH Patch version number of ROOT +# +# ROOT_VERSION_NUMBER A unique version number which is calculated from +# major, minor and patch version found +# +# ROOT_CINT_EXECUTABLE The rootcint executable. +# +# RLIBMAP_EXECUTABLE The rlibmap executable. + +Message(STATUS "Looking for Root...") + +Set(ROOT_CONFIG_SEARCHPATH + ${ROOT_DIR}/bin + ${SIMPATH}/bin + ${SIMPATH}/tools/root/bin + $ENV{ROOTSYS}/bin +) + +Set(ROOT_FOUND FALSE) +Set(ROOT_DEFINITIONS "") +Set(ROOT_INSTALLED_VERSION_TOO_OLD FALSE) +Set(ROOT_CONFIG_EXECUTABLE ROOT_CONFIG_EXECUTABLE-NOTFOUND) + +Find_Program(ROOT_CONFIG_EXECUTABLE NAMES root-config + PATHS ${ROOT_CONFIG_SEARCHPATH} + NO_DEFAULT_PATH + ) + +If(ROOT_CONFIG_EXECUTABLE) + + String(REGEX REPLACE "(^.*)/bin/root-config" "\\1" test ${ROOT_CONFIG_EXECUTABLE}) + Set(ENV{ROOTSYS} ${test}) + Set(ROOTSYS ${test}) + + Execute_Process(COMMAND ${ROOT_CONFIG_EXECUTABLE} --version + OUTPUT_VARIABLE ROOT_VERSION_STRING + ) + Execute_Process(COMMAND ${ROOT_CONFIG_EXECUTABLE} --prefix + OUTPUT_VARIABLE ROOT_INSTALL_DIR + ) + String(STRIP ${ROOT_VERSION_STRING} ROOT_VERSION_STRING) + String(STRIP ${ROOT_INSTALL_DIR} ROOT_INSTALL_DIR) + + + MESSAGE(STATUS "Looking for Root... - Found ${ROOT_INSTALL_DIR}/bin/root") + MESSAGE(STATUS "Looking for Root... - Found version is ${ROOT_VERSION_STRING} ") + + # extract major, minor, and patch versions from + # the version string given by root-config + String(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+.*" "\\1" ROOT_VERSION_MAJOR "${ROOT_VERSION_STRING}") + String(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+\\/[0-9][0-9]+.*" "\\1" ROOT_VERSION_MINOR "${ROOT_VERSION_STRING}") + String(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+\\/([0-9][0-9]+).*" "\\1" ROOT_VERSION_PATCH "${ROOT_VERSION_STRING}") + + # compute overall version numbers which can be compared at once + Math(EXPR req_vers "${ROOT_FIND_VERSION_MAJOR}*10000 + ${ROOT_FIND_VERSION_MINOR}*100 + ${ROOT_FIND_VERSION_PATCH}") + Math(EXPR found_vers "${ROOT_VERSION_MAJOR}*10000 + ${ROOT_VERSION_MINOR}*100 + ${ROOT_VERSION_PATCH}") + Math(EXPR ROOT_FOUND_VERSION "${ROOT_VERSION_MAJOR}*10000 + ${ROOT_VERSION_MINOR}*100 + ${ROOT_VERSION_PATCH}") + + Set(ROOT_Version ${found_vers}) + Set(ROOT_VERSION_NUMBER ${found_vers}) + + If(found_vers LESS req_vers) + Set(ROOT_FOUND FALSE) + Set(ROOT_INSTALLED_VERSION_TOO_OLD TRUE) + Else(found_vers LESS req_vers) + Set(ROOT_FOUND TRUE) + EndIf(found_vers LESS req_vers) + +Else(ROOT_CONFIG_EXECUTABLE) + Message(STATUS "Looking for Root... - Not found") + Message(WARNING "ROOT not installed in the searchpath and ROOTSYS is not set. Please set ROOTSYS or add the path to your ROOT installation in the Macro FindROOT.cmake in the subdirectory cmake/modules.") +Endif(ROOT_CONFIG_EXECUTABLE) + + +If(ROOT_FOUND) + + # ask root-config for the library dir + # Set ROOT_LIBRARY_DIR + Execute_Process(COMMAND ${ROOT_CONFIG_EXECUTABLE} --libdir + OUTPUT_VARIABLE ROOT_LIBRARY_DIR + ) + String(STRIP ${ROOT_LIBRARY_DIR} ROOT_LIBRARY_DIR) + + # ask root-config for the binary dir + Execute_Process(COMMAND ${ROOT_CONFIG_EXECUTABLE} --bindir + OUTPUT_VARIABLE ROOT_BINARY_DIR + ) + String(STRIP ${ROOT_BINARY_DIR} ROOT_BINARY_DIR) + + # ask root-config for the include dir + Execute_Process(COMMAND ${ROOT_CONFIG_EXECUTABLE} --incdir + OUTPUT_VARIABLE ROOT_INCLUDE_DIR + ) + String(STRIP ${ROOT_INCLUDE_DIR} ROOT_INCLUDE_DIR) + + # ask root-config for the library variables + Execute_Process(COMMAND ${ROOT_CONFIG_EXECUTABLE} --glibs + OUTPUT_VARIABLE ROOT_LIBRARIES + ) + String(STRIP ${ROOT_LIBRARIES} ROOT_LIBRARIES) + foreach(_cpt ${rootlibs} ${ROOT_FIND_COMPONENTS}) + find_library(ROOT_${_cpt}_LIBRARY ${_cpt} HINTS ${ROOT_LIBRARY_DIR}) + if(ROOT_${_cpt}_LIBRARY) + mark_as_advanced(ROOT_${_cpt}_LIBRARY) + list(APPEND ROOT_LIBRARIES ${ROOT_${_cpt}_LIBRARY}) + list(REMOVE_ITEM ROOT_FIND_COMPONENTS ${_cpt}) + endif() + endforeach() + + # Make variables changeble to the advanced user + Mark_As_Advanced(ROOT_LIBRARY_DIR ROOT_INCLUDE_DIR ROOT_DEFINITIONS) + + # Set ROOT_INCLUDES + Set(ROOT_INCLUDES ${ROOT_INCLUDE_DIR}) + + Set(LD_LIBRARY_PATH ${LD_LIBRARY_PATH} ${ROOT_LIBRARY_DIR}) + + ####################################### + # + # Check the executables of ROOT + # ( rootcint ) + # + ####################################### + + Find_Program(ROOT_CINT_EXECUTABLE + NAMES rootcint + PATHS ${ROOT_BINARY_DIR} + NO_DEFAULT_PATH + ) + + Find_Program(RLIBMAP_EXECUTABLE + NAMES rlibmap + PATHS ${ROOT_BINARY_DIR} + NO_DEFAULT_PATH + ) + + Include(ROOTMacros) + +Else(ROOT_FOUND) + + If(ROOT_FIND_REQUIRED) + Message(STATUS "Looking for ROOT... - Found version to old.") + Message(STATUS "Looking for ROOT... - Minimum required version is ${ROOT_FIND_VERSION}") + Message(FATAL_ERROR "Stop here because of a wrong Root version.") + EndIf(ROOT_FIND_REQUIRED) + +Endif(ROOT_FOUND) diff --git a/cmake/O2Utils.cmake b/cmake/O2Utils.cmake new file mode 100644 index 0000000000..fb2219ae33 --- /dev/null +++ b/cmake/O2Utils.cmake @@ -0,0 +1,486 @@ +include(CMakeParseArguments) + +#------------------------------------------------------------------------------ +# O2_SETUP +# The modules register themselves using this macro. +# Developer note : we use a macro because we want to access the variables of the caller. +# arg NAME - Module name +macro(O2_SETUP) + cmake_parse_arguments( + PARSED_ARGS + "" # bool args + "NAME" # mono-valued arguments + "" # multi-valued arguments + ${ARGN} # arguments + ) + CHECK_VARIABLE(PARSED_ARGS_NAME "You must provide a name") + set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib") + set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin") + set(INCLUDE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/include") +endmacro() + +#------------------------------------------------------------------------------ +# O2_DEFINE_BUCKET +# arg NAME +# arg DEPENDENCIES # either libraries or buckets +# arg INCLUDE_DIRECTORIES # project include directories +# arg SYSTEMINCLUDE_DIRECTORIES # system include directories (no compiler warnings) +function(O2_DEFINE_BUCKET) + cmake_parse_arguments( + PARSED_ARGS + "" # bool args + "NAME" # mono-valued arguments + "DEPENDENCIES;INCLUDE_DIRECTORIES;SYSTEMINCLUDE_DIRECTORIES" # multi-valued arguments + ${ARGN} # arguments + ) + CHECK_VARIABLE(PARSED_ARGS_NAME "You must provide a name") + +# message(STATUS "o2_define_bucket : ${PARSED_ARGS_NAME}") +# foreach (library ${PARSED_ARGS_DEPENDENCIES}) +# message(STATUS " - ${library} (lib or bucket)") +# endforeach () +# foreach (inc_dir ${PARSED_ARGS_INCLUDE_DIRECTORIES}) +# message(STATUS " - ${inc_dir} (inc_dir)") +# endforeach () + + # Save this information + set("bucket_map_${PARSED_ARGS_NAME}" "${PARSED_ARGS_NAME}" PARENT_SCOPE) # emulation of a map + set("bucket_map_libs_${PARSED_ARGS_NAME}" "${PARSED_ARGS_DEPENDENCIES}" PARENT_SCOPE) # emulation of a map + set("bucket_map_inc_dirs_${PARSED_ARGS_NAME}" "${PARSED_ARGS_INCLUDE_DIRECTORIES}" PARENT_SCOPE) # emulation of a map + set("bucket_map_systeminc_dirs_${PARSED_ARGS_NAME}" "${PARSED_ARGS_SYSTEMINCLUDE_DIRECTORIES}" PARENT_SCOPE) # emulation of a map +endfunction() + +macro(INDENT NUMBER_SPACES INDENTATION) + foreach (i RANGE ${NUMBER_SPACES}) + set(${INDENTATION} "${${INDENTATION}} ") + endforeach () +endmacro() + +#------------------------------------------------------------------------------ +# GET_BUCKET_CONTENT +# Returns the list of libraries defined in the bucket, including the ones +# part of other buckets referenced by this one. +# We allow a maximum of 10 levels of recursion. +# arg BUCKET_NAME - +# arg RESULT_LIBS_VAR_NAME - Name of the variable in the parent scope that should be populated with list of libraries. +# arg RESULT_INC_DIRS_VAR_NAME - Name of the variable in the parent scope that should be populated with list of include directories. +# arg RESULT_SYSTEMINC_DIRS_VAR_NAME - Name of the variable in the parent scope that should be populated with list of system include directories. +# arg DEPTH - Use 0 when calling the first time (can be omitted). +function(GET_BUCKET_CONTENT + BUCKET_NAME + RESULT_LIBS_VAR_NAME + RESULT_INC_DIRS_VAR_NAME + RESULT_SYSTEMINC_DIRS_VAR_NAME + ) + INDENT(0 INDENTATION) +# message("${INDENTATION}Get content of bucket ${BUCKET_NAME} (from parent(s): ${RECURSIVE_BUCKETS})") +# message("${INDENTATION} RESULT_LIBS_VAR_NAME = ${RESULT_LIBS_VAR_NAME} ") +# message("${INDENTATION} RESULT_INC_DIRS_VAR_NAME = ${RESULT_INC_DIRS_VAR_NAME} ") +# message("${INDENTATION} RESULT_SYSTEMINC_DIRS_VAR_NAME = ${RESULT_SYSTEMINC_DIRS_VAR_NAME}") + + if (NOT DEFINED bucket_map_${BUCKET_NAME}) + message(FATAL_ERROR "${INDENTATION}bucket ${BUCKET_NAME} not defined. Use o2_define_bucket to define it.") + endif () + list (FIND RECURSIVE_BUCKETS ${BUCKET_NAME} _index) + if (${_index} GREATER -1) + message(FATAL_ERROR "circular dependency detected for bucket ${BUCKET_NAME} from parent(s):${RECURSIVE_BUCKETS}") + endif () + + # Fetch the content (recursively) + set(libs ${bucket_map_libs_${BUCKET_NAME}}) + set(inc_dirs ${bucket_map_inc_dirs_${BUCKET_NAME}}) + set(systeminc_dirs ${bucket_map_systeminc_dirs_${BUCKET_NAME}}) + set(LOCAL_VARIABLE_EXTENSION "_${BUCKET_NAME}") + set(LOCAL_RESULT_libs${LOCAL_VARIABLE_EXTENSION} "") + set(LOCAL_RESULT_inc_dirs${LOCAL_VARIABLE_EXTENSION} "") + set(LOCAL_RESULT_systeminc_dirs${LOCAL_VARIABLE_EXTENSION} "") + foreach (dependency ${libs}) +# message("${INDENTATION}- ${dependency} (lib or bucket)") + # if it is a bucket we call recursively + if (DEFINED bucket_map_${dependency}) + list(APPEND RECURSIVE_BUCKETS ${BUCKET_NAME}) + GET_BUCKET_CONTENT(${dependency} + LOCAL_RESULT_libs${LOCAL_VARIABLE_EXTENSION} + LOCAL_RESULT_inc_dirs${LOCAL_VARIABLE_EXTENSION} + LOCAL_RESULT_systeminc_dirs${LOCAL_VARIABLE_EXTENSION} + ) + list(REMOVE_ITEM RECURSIVE_BUCKETS ${BUCKET_NAME}) +# message(" ${INDENTATION}dependencies ${LOCAL_RESULT_libs${LOCAL_VARIABLE_EXTENSION}}") +# message(" ${INDENTATION}include ${LOCAL_RESULT_inc_dirs${LOCAL_VARIABLE_EXTENSION}}") +# message(" ${INDENTATION}systeminclude ${LOCAL_RESULT_systeminc_dirs${LOCAL_VARIABLE_EXTENSION}}") + else () + # else we add the dependency to the results + set(LOCAL_RESULT_libs${LOCAL_VARIABLE_EXTENSION} "${LOCAL_RESULT_libs${LOCAL_VARIABLE_EXTENSION}};${dependency}") + endif () + endforeach () + + if (DEFINED LOCAL_RESULT_inc_dirs${LOCAL_VARIABLE_EXTENSION} AND DEFINED inc_dirs) + set(LOCAL_RESULT_inc_dirs${LOCAL_VARIABLE_EXTENSION} "${LOCAL_RESULT_inc_dirs${LOCAL_VARIABLE_EXTENSION}};") + endif () + set(LOCAL_RESULT_inc_dirs${LOCAL_VARIABLE_EXTENSION} "${LOCAL_RESULT_inc_dirs${LOCAL_VARIABLE_EXTENSION}}${inc_dirs}") + if (DEFINED LOCAL_RESULT_systeminc_dirs${LOCAL_VARIABLE_EXTENSION} AND DEFINED systeminc_dirs) + set(LOCAL_RESULT_systeminc_dirs${LOCAL_VARIABLE_EXTENSION} "${LOCAL_RESULT_systeminc_dirs${LOCAL_VARIABLE_EXTENSION}};") + endif () + set(LOCAL_RESULT_systeminc_dirs${LOCAL_VARIABLE_EXTENSION} "${LOCAL_RESULT_systeminc_dirs${LOCAL_VARIABLE_EXTENSION}}${systeminc_dirs}") +# foreach (inc_dir ${inc_dirs}) +# message("${INDENTATION}- ${inc_dir} (inc_dir)") +# endforeach () +# foreach (inc_dir ${systeminc_dirs}) +# message("${INDENTATION}- ${inc_dir} (systeminc_dir)") +# endforeach () + + if (DEFINED LOCAL_RESULT_libs${LOCAL_VARIABLE_EXTENSION}) + set(${RESULT_LIBS_VAR_NAME} "${${RESULT_LIBS_VAR_NAME}};${LOCAL_RESULT_libs${LOCAL_VARIABLE_EXTENSION}}" PARENT_SCOPE) + endif () + if (DEFINED LOCAL_RESULT_inc_dirs${LOCAL_VARIABLE_EXTENSION}) + set(${RESULT_INC_DIRS_VAR_NAME} "${${RESULT_INC_DIRS_VAR_NAME}};${LOCAL_RESULT_inc_dirs${LOCAL_VARIABLE_EXTENSION}}" PARENT_SCOPE) + endif () + if (DEFINED LOCAL_RESULT_systeminc_dirs${LOCAL_VARIABLE_EXTENSION}) + set(${RESULT_SYSTEMINC_DIRS_VAR_NAME} "${${RESULT_SYSTEMINC_DIRS_VAR_NAME}};${LOCAL_RESULT_systeminc_dirs${LOCAL_VARIABLE_EXTENSION}}" PARENT_SCOPE) + endif () +endfunction() + +#------------------------------------------------------------------------------ +# O2_TARGET_LINK_BUCKET +# arg TARGET +# arg BUCKET +# arg EXE - true indicates that it is an executable. (not used for the time being/anymore) +# arg MODULE_LIBRARY_NAME - Only used for executables. It should indicate the library of the module. +function(O2_TARGET_LINK_BUCKET) + cmake_parse_arguments( + PARSED_ARGS + "EXE" # bool args + "TARGET;BUCKET;MODULE_LIBRARY_NAME" # mono-valued arguments + "" # multi-valued arguments + ${ARGN} # arguments + ) + # errors if missing arguments + CHECK_VARIABLE(PARSED_ARGS_TARGET "You must provide a target name") + CHECK_VARIABLE(PARSED_ARGS_BUCKET "You must provide a bucket name") + + # message(STATUS "Add dependency bucket for target ${PARSED_ARGS_TARGET} : ${PARSED_ARGS_BUCKET}") + + # find the bucket + if (NOT DEFINED bucket_map_libs_${PARSED_ARGS_BUCKET}) + message(FATAL_ERROR "bucket ${PARSED_ARGS_BUCKET} not defined. + Use o2_define_bucket to define it.") + endif () + + set(RESULT_libs "") + set(RESULT_inc_dirs "") + set(RESULT_systeminc_dirs "") + GET_BUCKET_CONTENT(${PARSED_ARGS_BUCKET} RESULT_libs RESULT_inc_dirs RESULT_systeminc_dirs) # RESULT_lib_dirs) +# message(STATUS "All dependencies of the bucket : ${RESULT_libs}") +# message(STATUS "All inc_dirs of the bucket ${PARSED_ARGS_BUCKET} : ${RESULT_inc_dirs}") + + # for each dependency in the bucket invoke target_link_library + # set(DEPENDENCIES ${bucket_map_libs_${PARSED_ARGS_BUCKET}}) + # message(STATUS " invoke target_link_libraries for target ${PARSED_ARGS_TARGET} : ${RESULT_libs} ${PARSED_ARGS_MODULE_LIBRARY_NAME}") + + target_link_libraries(${PARSED_ARGS_TARGET} ${RESULT_libs} ${PARSED_ARGS_MODULE_LIBRARY_NAME}) + + # Same thing for lib_dirs and inc_dirs + target_include_directories(${PARSED_ARGS_TARGET} PUBLIC ${RESULT_inc_dirs}) + target_include_directories(${PARSED_ARGS_TARGET} SYSTEM PUBLIC ${RESULT_systeminc_dirs}) +endfunction() + +#------------------------------------------------------------------------------ +# O2_GENERATE_LIBRARY +# TODO use arguments, do NOT modify the parent's scope variables. +# This macro +# - Generate a ROOT dictionary if LINKDEF is defined and install it, +# - Create the library named LIBRARY_NAME with sources SRCS using headers HEADERS and install it, +# - Install +macro(O2_GENERATE_LIBRARY) + + # cmake_parse_arguments( + # ARGS + # "" # bool args + # "LIBRARY_NAME;BUCKET_NAME;DICTIONARY;LINKDEF" # mono-valued arguments + # "SOURCES;NO_DICT_SOURCES;HEADERS;INCLUDE_DIRECTORIES" # multi-valued arguments + # ${ARGN} # arguments + # ) + + ############### Preparation - Arguments ##################### + + # CHECK_VARIABLE(ARGS_LIBRARY_NAME "You must provide the name of the library" ) + # CHECK_VARIABLE(ARGS_BUCKET_NAME "You must provide a bucket name" ) + + set(Int_LIB ${LIBRARY_NAME}) + Set(HeaderRuleName "${Int_LIB}_HEADER_RULES") + Set(DictName "G__${Int_LIB}Dict.cxx") + + if (NOT DICTIONARY) + Set(DICTIONARY ${CMAKE_CURRENT_BINARY_DIR}/${DictName}) + endif (NOT DICTIONARY) + if (IS_ABSOLUTE ${DICTIONARY}) + Set(Int_DICTIONARY ${DICTIONARY}) + else (IS_ABSOLUTE ${DICTIONARY}) + Set(Int_DICTIONARY ${CMAKE_CURRENT_SOURCE_DIR}/${DICTIONARY}) + endif (IS_ABSOLUTE ${DICTIONARY}) + + + Set(Int_SRCS ${SRCS}) + + # If headers are defined we use them otherwise we search for the headers + if (HEADERS) + set(HDRS ${HEADERS}) + else (HEADERS) + file(GLOB_RECURSE HDRS *.h) + endif (HEADERS) + + # ??? + if (IWYU_FOUND) + Set(_INCLUDE_DIRS ${INCLUDE_DIRECTORIES} ${SYSTEM_INCLUDE_DIRECTORIES}) + CHECK_HEADERS("${Int_SRCS}" "${_INCLUDE_DIRS}" ${HeaderRuleName}) + endif (IWYU_FOUND) + + ############### build the dictionary ##################### + if (LINKDEF) + if (IS_ABSOLUTE ${LINKDEF}) + Set(LINKDEF ${LINKDEF}) + else (IS_ABSOLUTE ${LINKDEF}) + Set(LINKDEF ${CMAKE_CURRENT_SOURCE_DIR}/${LINKDEF}) + endif (IS_ABSOLUTE ${LINKDEF}) + O2_ROOT_GENERATE_DICTIONARY() + SET(Int_SRCS ${Int_SRCS} ${Int_DICTIONARY}) + endif (LINKDEF) + + # ???? + set(Int_DEPENDENCIES) + foreach (d ${DEPENDENCIES}) + get_filename_component(_ext ${d} EXT) + if (NOT _ext MATCHES a$) + set(Int_DEPENDENCIES ${Int_DEPENDENCIES} ${d}) + else () + Message("Found Static library with extension ${_ext}") + get_filename_component(_lib ${d} NAME_WE) + set(Int_DEPENDENCIES ${Int_DEPENDENCIES} ${_lib}) + endif () + endforeach () + + ############### build the library ##################### + if (${CMAKE_GENERATOR} MATCHES Xcode) + Add_Library(${Int_LIB} SHARED ${Int_SRCS} ${NO_DICT_SRCS} ${HDRS} ${LINKDEF}) + else () + Add_Library(${Int_LIB} SHARED ${Int_SRCS} ${NO_DICT_SRCS} ${LINKDEF}) + endif () + + ############### Add dependencies ###################### + o2_target_link_bucket(TARGET ${Int_LIB} BUCKET ${BUCKET_NAME}) + target_include_directories( + ${Int_LIB} + PUBLIC + # TODO retrofit to O2 + $ + $ # /include/mylib + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/src # internal headers + ${CMAKE_CURRENT_SOURCE_DIR} # For the modules that generate a dictionary + ) + + ############### install the library ################### + # TODO remove ? keep ? + install(TARGETS ${Int_LIB} + EXPORT ${PROJECT_NAME}Targets # for downstream dependencies + DESTINATION lib) + + # Install all the public headers + # TODO retrofit to O2 + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/include/${MODULE_NAME}) + install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/${MODULE_NAME} + DESTINATION include) + endif() + +endmacro(O2_GENERATE_LIBRARY) + +#------------------------------------------------------------------------------ +# O2_GENERATE_EXECUTABLE +# arg EXE_NAME +# arg BUCKET_NAME +# arg SOURCES +# arg MODULE_LIBRARY_NAME - Name of the library of the module this executable belongs to. Optional. +# arg INSTALL - True to install (default), false otherwise. Optional. +function(O2_GENERATE_EXECUTABLE) + + cmake_parse_arguments( + PARSED_ARGS + "NO_INSTALL" # bool args + "EXE_NAME;BUCKET_NAME;MODULE_LIBRARY_NAME" # mono-valued arguments + "SOURCES" # multi-valued arguments + ${ARGN} # arguments + ) + + CHECK_VARIABLE(PARSED_ARGS_EXE_NAME "You must provide an executable name") + CHECK_VARIABLE(PARSED_ARGS_BUCKET_NAME "You must provide a bucket name") + CHECK_VARIABLE(PARSED_ARGS_SOURCES "You must provide the list of sources") +# CHECK_VARIABLE(PARSED_ARGS_MODULE_LIBRARY_NAME "You must provide the module library name this executable belongs to") + + ############### build the library ##################### + ADD_EXECUTABLE(${PARSED_ARGS_EXE_NAME} ${PARSED_ARGS_SOURCES}) + O2_TARGET_LINK_BUCKET( + TARGET ${PARSED_ARGS_EXE_NAME} + BUCKET ${PARSED_ARGS_BUCKET_NAME} + EXE TRUE + MODULE_LIBRARY_NAME ${PARSED_ARGS_MODULE_LIBRARY_NAME} + ) + + if (NOT ${PARSED_ARGS_NO_INSTALL}) + ############### install the executable ################# + install(TARGETS ${PARSED_ARGS_EXE_NAME} DESTINATION bin) + + ############### install the library ################### + install(TARGETS ${PARSED_ARGS_MODULE_LIBRARY_NAME} DESTINATION lib) + endif () + +endfunction(O2_GENERATE_EXECUTABLE) + + +#------------------------------------------------------------------------------ +# O2_GENERATE_TESTS +# Generate tests for all source files listed in TEST_SRCS +# arg BUCKET_NAME +# arg TEST_SRCS +# arg MODULE_LIBRARY_NAME - Name of the library of the module this executable belongs to. +# arg TIMEOUT in seconds after which the test is considered failed. +function(O2_GENERATE_TESTS) + cmake_parse_arguments( + PARSED_ARGS + "" # bool args + "BUCKET_NAME;MODULE_LIBRARY_NAME;TIMEOUT" # mono-valued arguments + "TEST_SRCS" # multi-valued arguments + ${ARGN} # arguments + ) + + CHECK_VARIABLE(PARSED_ARGS_BUCKET_NAME "You must provide a bucket name") + CHECK_VARIABLE(PARSED_ARGS_TEST_SRCS "You must provide the list of sources") + CHECK_VARIABLE(PARSED_ARGS_MODULE_LIBRARY_NAME "You must provide the module library name this executable belongs to") + + foreach (test ${PARSED_ARGS_TEST_SRCS}) + string(REGEX REPLACE ".*/" "" test_name ${test}) + string(REGEX REPLACE "\\..*" "" test_name ${test_name}) + + message(STATUS "Generate test ${test_name}") + + O2_GENERATE_EXECUTABLE( + EXE_NAME ${test_name} + SOURCES ${test} + MODULE_LIBRARY_NAME ${PARSED_ARGS_MODULE_LIBRARY_NAME} + BUCKET_NAME ${PARSED_ARGS_BUCKET_NAME} + NO_INSTALL FALSE + ) + target_link_libraries(${test_name} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + add_test(NAME ${test_name} COMMAND ${test_name}) + if(PARSED_ARGS_TIMEOUT) + set_tests_properties(${test_name} PROPERTIES TIMEOUT ${PARSED_ARGS_TIMEOUT}) + endif() + endforeach () +endfunction() + + +#------------------------------------------------------------------------------ +# CHECK_VARIABLE +macro(CHECK_VARIABLE VARIABLE_NAME ERROR_MESSAGE) + if (NOT ${VARIABLE_NAME}) + message(FATAL_ERROR "${ERROR_MESSAGE}") + endif (NOT ${VARIABLE_NAME}) +endmacro(CHECK_VARIABLE) + +#------------------------------------------------------------------------------ +# O2_FORMAT +function(O2_FORMAT _output input prefix suffix) + + # DevNotes - input should be put in quotes or the complete list does not get passed to the function + set(format) + foreach (arg ${input}) + set(item ${arg}) + if (prefix) + string(REGEX MATCH "^${prefix}" pre ${arg}) + endif (prefix) + if (suffix) + string(REGEX MATCH "${suffix}$" suf ${arg}) + endif (suffix) + if (NOT pre) + set(item "${prefix}${item}") + endif (NOT pre) + if (NOT suf) + set(item "${item}${suffix}") + endif (NOT suf) + list(APPEND format ${item}) + endforeach (arg) + set(${_output} ${format} PARENT_SCOPE) + +endfunction(O2_FORMAT) + +#------------------------------------------------------------------------------ +# O2_ROOT_GENERATE_DICTIONARY +# TODO use arguments, do NOT modify the parent's scope variables. +macro(O2_ROOT_GENERATE_DICTIONARY) + + # All Arguments needed for this new version of the macro are defined + # in the parent scope, namely in the CMakeLists.txt of the submodule + set(Int_LINKDEF ${LINKDEF}) + set(Int_DICTIONARY ${DICTIONARY}) + set(Int_LIB ${LIBRARY_NAME}) + + set(Int_HDRS ${HDRS}) + set(Int_DEF ${DEFINITIONS}) + + # Convert the values of the variable to a semi-colon separated list + separate_arguments(Int_HDRS) + separate_arguments(Int_DEF) + + # Get the include directories (from the bucket and from the internal dependencies) + set(RESULT_libs "") + set(Int_INC "") + set(Int_SYSTEMINC "") + GET_BUCKET_CONTENT(${BUCKET_NAME} RESULT_libs Int_INC Int_SYSTEMINC) + set(Int_INC ${Int_INC} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include) + set(Int_INC ${Int_INC} ${CMAKE_CURRENT_SOURCE_DIR}/src) # internal headers + set(Int_INC ${Int_INC} ${GLOBAL_ALL_MODULES_INCLUDE_DIRECTORIES}) + set(Int_INC ${Int_INC} ${Int_SYSTEMINC}) + + # Format neccesary arguments + # Add -I and -D to include directories and definitions + O2_FORMAT(Int_INC "${Int_INC}" "-I" "") + O2_FORMAT(Int_DEF "${Int_DEF}" "-D" "") + + #---call rootcint / cling -------------------------------- + set(OUTPUT_FILES ${Int_DICTIONARY}) + set(EXTRA_DICT_PARAMETERS "") + set(Int_ROOTMAPFILE ${LIBRARY_OUTPUT_PATH}/lib${Int_LIB}.rootmap) + set(Int_PCMFILE G__${Int_LIB}Dict_rdict.pcm) + set(OUTPUT_FILES ${OUTPUT_FILES} ${Int_PCMFILE} ${Int_ROOTMAPFILE}) + set(EXTRA_DICT_PARAMETERS ${EXTRA_DICT_PARAMETERS} + -inlineInputHeader -rmf ${Int_ROOTMAPFILE} + -rml ${Int_LIB}${CMAKE_SHARED_LIBRARY_SUFFIX}) + set_source_files_properties(${OUTPUT_FILES} PROPERTIES GENERATED TRUE) + if (CMAKE_SYSTEM_NAME MATCHES Linux) + # Note : ROOT_CINT_EXECUTABLE is ok with ROOT6 (rootcint == rootcling) + add_custom_command(OUTPUT ${OUTPUT_FILES} + COMMAND LD_LIBRARY_PATH=${ROOT_LIBRARY_DIR}:${_intel_lib_dirs}:$ENV{LD_LIBRARY_PATH} ROOTSYS=${ROOTSYS} + ${ROOT_CINT_EXECUTABLE} -f ${Int_DICTIONARY} ${EXTRA_DICT_PARAMETERS} -c ${Int_DEF} ${Int_INC} ${Int_HDRS} ${Int_LINKDEF} + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/${Int_PCMFILE} ${LIBRARY_OUTPUT_PATH}/${Int_PCMFILE} + DEPENDS ${Int_HDRS} ${Int_LINKDEF} + ) + else (CMAKE_SYSTEM_NAME MATCHES Linux) + if (CMAKE_SYSTEM_NAME MATCHES Darwin) + add_custom_command(OUTPUT ${OUTPUT_FILES} + COMMAND DYLD_LIBRARY_PATH=${ROOT_LIBRARY_DIR}:$ENV{DYLD_LIBRARY_PATH} ROOTSYS=${ROOTSYS} ${ROOT_CINT_EXECUTABLE} + -f ${Int_DICTIONARY} ${EXTRA_DICT_PARAMETERS} -c ${Int_DEF} ${Int_INC} ${Int_HDRS} ${Int_LINKDEF} + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/${Int_PCMFILE} ${LIBRARY_OUTPUT_PATH}/${Int_PCMFILE} + DEPENDS ${Int_HDRS} ${Int_LINKDEF} + ) + endif (CMAKE_SYSTEM_NAME MATCHES Darwin) + endif (CMAKE_SYSTEM_NAME MATCHES Linux) + install(FILES ${LIBRARY_OUTPUT_PATH}/${Int_PCMFILE} ${Int_ROOTMAPFILE} DESTINATION lib) + + if (CMAKE_COMPILER_IS_GNUCXX) + exec_program(${CMAKE_C_COMPILER} ARGS "-dumpversion" OUTPUT_VARIABLE _gcc_version_info) + string(REGEX REPLACE "^([0-9]+).*$" "\\1" GCC_MAJOR ${_gcc_version_info}) + if (${GCC_MAJOR} GREATER 4) + set_source_files_properties(${Int_DICTIONARY} PROPERTIES COMPILE_DEFINITIONS R__ACCESS_IN_SYMBOL) + endif () + endif () + +endmacro(O2_ROOT_GENERATE_DICTIONARY) diff --git a/cmake/QualityControlDependencies.cmake b/cmake/QualityControlDependencies.cmake index 84eb322b98..5d6fbb7282 100644 --- a/cmake/QualityControlDependencies.cmake +++ b/cmake/QualityControlDependencies.cmake @@ -7,6 +7,7 @@ find_package(MySQL) find_package(Common REQUIRED) find_package(InfoLogger REQUIRED) find_package(DataSampling REQUIRED) +find_package(ROOT 6.06.02 COMPONENTS RHTTP RMySQL Gui REQUIRED) # todo not sure why this is needed if (BOOST_FOUND AND NOT Boost_FOUND) @@ -15,20 +16,15 @@ if (BOOST_FOUND AND NOT Boost_FOUND) endif () link_directories(${FAIRROOT_LIBRARY_DIR}) -find_package(ROOT 6.06.02 COMPONENTS RHTTP RMySQL Gui) set(FAIRROOT_LIBRARIES Base FairMQ BaseMQ) -if (NOT ROOT_FOUND) - return() -endif () - if (NOT MYSQL_FOUND) message(WARNING "MySQL not found, the corresponding classes won't be built.") #elseif(NOT ROOT_RMySQL_LIBRARY) # message(WARNING "MySQL ROOT class not found, the corresponding classes won't be built.") else () add_definitions(-D_WITH_MYSQL) - set(ROOT_LIBRARIES "${ROOT_LIBRARIES} -lRMySQL") +# set(ROOT_LIBRARIES "${ROOT_LIBRARIES} -lRMySQL") endif () o2_define_bucket( @@ -74,10 +70,6 @@ o2_define_bucket( ) -# todo just a quick fix to get the dictionary working . to be revisited when extracting -#list(APPEND GLOBAL_ALL_MODULES_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/../QualityControl/include) -#list(APPEND GLOBAL_ALL_MODULES_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/../DataFormat/include) - o2_define_bucket( NAME o2_qcmodules_base @@ -94,7 +86,7 @@ o2_define_bucket( ${Monitoring_INCLUDE_DIRS} ${InfoLogger_INCLUDE_DIRS} ${Common_INCLUDE_DIRS} - ${CMAKE_SOURCE_DIR}/QualityControl/Framework/include # another module's include dir + ${CMAKE_SOURCE_DIR}/Framework/include # another module's include dir ) o2_define_bucket( diff --git a/cmake/ROOTMacros.cmake b/cmake/ROOTMacros.cmake new file mode 100644 index 0000000000..ac0c1029d6 --- /dev/null +++ b/cmake/ROOTMacros.cmake @@ -0,0 +1,367 @@ + ################################################################################ + # Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # + # # + # This software is distributed under the terms of the # + # GNU Lesser General Public Licence version 3 (LGPL) version 3, # + # copied verbatim in the file "LICENSE" # + ################################################################################ +Function(Format _output input prefix suffix) + +# DevNotes - input should be put in quotes or the complete list does not get passed to the function + set(format) + foreach(arg ${input}) + set(item ${arg}) + if(prefix) + string(REGEX MATCH "^${prefix}" pre ${arg}) + endif(prefix) + if(suffix) + string(REGEX MATCH "${suffix}$" suf ${arg}) + endif(suffix) + if(NOT pre) + set(item "${prefix}${item}") + endif(NOT pre) + if(NOT suf) + set(item "${item}${suffix}") + endif(NOT suf) + list(APPEND format ${item}) + endforeach(arg) + set(${_output} ${format} PARENT_SCOPE) + +endfunction(Format) + + + ########################################### + # + # Macros for building ROOT dictionary + # + ########################################### +Macro(ROOT_GENERATE_DICTIONARY) + + # Macro to switch between the old implementation with parameters + # and the new implementation without parameters. + # For the new implementation some CMake variables has to be defined + # before calling the macro. + + If(${ARGC} EQUAL 0) +# Message("New Version") + ROOT_GENERATE_DICTIONARY_NEW() + Else(${ARGC} EQUAL 0) + If(${ARGC} EQUAL 4) +# Message("Old Version") + ROOT_GENERATE_DICTIONARY_OLD("${ARGV0}" "${ARGV1}" "${ARGV2}" "${ARGV3}") + Else(${ARGC} EQUAL 4) + Message(FATAL_ERROR "Has to be implemented") + EndIf(${ARGC} EQUAL 4) + EndIf(${ARGC} EQUAL 0) + +EndMacro(ROOT_GENERATE_DICTIONARY) + +Macro(ROOT_GENERATE_DICTIONARY_NEW) + + # All Arguments needed for this new version of the macro are defined + # in the parent scope, namely in the CMakeLists.txt of the submodule + set(Int_LINKDEF ${LINKDEF}) + set(Int_DICTIONARY ${DICTIONARY}) + set(Int_LIB ${LIBRARY_NAME}) + + set(Int_INC ${INCLUDE_DIRECTORIES} ${SYSTEM_INCLUDE_DIRECTORIES}) + set(Int_HDRS ${HDRS}) + set(Int_DEF ${DEFINITIONS}) + + # Convert the values of the variable to a semi-colon separated list + separate_arguments(Int_INC) + separate_arguments(Int_HDRS) + separate_arguments(Int_DEF) + + # Format neccesary arguments + # Add -I and -D to include directories and definitions + Format(Int_INC "${Int_INC}" "-I" "") + Format(Int_DEF "${Int_DEF}" "-D" "") + + #---call rootcint / cling -------------------------------- + set(OUTPUT_FILES ${Int_DICTIONARY}) + + If (CMAKE_SYSTEM_NAME MATCHES Linux) + Set(MY_LD_LIBRARY_PATH ${ROOT_LIBRARY_DIR}:${_intel_lib_dirs}:$ENV{LD_LIBRARY_PATH}) + ElseIf(CMAKE_SYSTEM_NAME MATCHES Darwin) + Set(MY_LD_LIBRARY_PATH ${ROOT_LIBRARY_DIR}:$ENV{DYLD_LIBRARY_PATH}) + EndIf() + + get_filename_component(script_name ${Int_DICTIONARY} NAME_WE) + String(REPLACE ";" " " Int_DEF_STR "${Int_DEF}") + String(REPLACE ";" " " Int_INC_STR "${Int_INC}") + String(REPLACE ";" " " Int_HDRS_STR "${Int_HDRS}") + + Set(EXTRA_DICT_PARAMETERS "") + If (ROOT_FOUND_VERSION GREATER 59999) + + Set(Int_ROOTMAPFILE ${LIBRARY_OUTPUT_PATH}/lib${Int_LIB}.rootmap) + Set(Int_PCMFILE G__${Int_LIB}Dict_rdict.pcm) + Set(OUTPUT_FILES ${OUTPUT_FILES} ${Int_PCMFILE} ${Int_ROOTMAPFILE}) + Set(EXTRA_DICT_PARAMETERS ${EXTRA_DICT_PARAMETERS} + -inlineInputHeader -rmf ${Int_ROOTMAPFILE} + -rml ${Int_LIB}${CMAKE_SHARED_LIBRARY_SUFFIX}) + Set_Source_Files_Properties(${OUTPUT_FILES} PROPERTIES GENERATED TRUE) + String(REPLACE ";" " " EXTRA_DICT_PARAMETERS_STR "${EXTRA_DICT_PARAMETERS}") + + EndIf() + + # We need some environment variables which are present when running cmake at the + # time we run make. To pass the variables a script is created containing the + # correct values for the needed variables + + IF(FAIRROOTPATH) + Configure_File(${FAIRROOTPATH}/share/fairbase/cmake/scripts/generate_dictionary_root.sh.in + ${CMAKE_CURRENT_BINARY_DIR}/generate_dictionary_${script_name}.sh + ) + EXEC_PROGRAM(/bin/chmod ARGS "u+x ${CMAKE_CURRENT_BINARY_DIR}/generate_dictionary_${script_name}.sh") + ELSE(FAIRROOTPATH) + Configure_File(${PROJECT_SOURCE_DIR}/cmake/scripts/generate_dictionary_root.sh.in + ${CMAKE_CURRENT_BINARY_DIR}/generate_dictionary_${script_name}.sh + ) + ENDIF(FAIRROOTPATH) + + + If (ROOT_FOUND_VERSION GREATER 59999) + Add_Custom_Command(OUTPUT ${OUTPUT_FILES} + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/generate_dictionary_${script_name}.sh + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/${Int_PCMFILE} ${LIBRARY_OUTPUT_PATH}/${Int_PCMFILE} + DEPENDS ${Int_HDRS} ${Int_LINKDEF} + ) + Install(FILES ${LIBRARY_OUTPUT_PATH}/${Int_PCMFILE} ${Int_ROOTMAPFILE} DESTINATION lib) + Else() + Add_Custom_Command(OUTPUT ${OUTPUT_FILES} + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/generate_dictionary_${script_name}.sh + DEPENDS ${Int_HDRS} ${Int_LINKDEF} + ) + EndIf() + +endmacro(ROOT_GENERATE_DICTIONARY_NEW) + + +MACRO (ROOT_GENERATE_DICTIONARY_OLD INFILES LINKDEF_FILE OUTFILE INCLUDE_DIRS_IN) + + set(INCLUDE_DIRS) + + foreach (_current_FILE ${INCLUDE_DIRS_IN}) + set(INCLUDE_DIRS ${INCLUDE_DIRS} -I${_current_FILE}) + endforeach (_current_FILE ${INCLUDE_DIRS_IN}) + +# Message("Definitions: ${DEFINITIONS}") +# MESSAGE("INFILES: ${INFILES}") +# MESSAGE("OutFILE: ${OUTFILE}") +# MESSAGE("LINKDEF_FILE: ${LINKDEF_FILE}") +# MESSAGE("INCLUDE_DIRS: ${INCLUDE_DIRS}") + + STRING(REGEX REPLACE "^(.*)\\.(.*)$" "\\1.h" bla "${OUTFILE}") +# MESSAGE("BLA: ${bla}") + SET (OUTFILES ${OUTFILE} ${bla}) + + + if (CMAKE_SYSTEM_NAME MATCHES Linux) + ADD_CUSTOM_COMMAND(OUTPUT ${OUTFILES} + COMMAND LD_LIBRARY_PATH=${ROOT_LIBRARY_DIR}:${_intel_lib_dirs} ROOTSYS=${ROOTSYS} ${ROOT_CINT_EXECUTABLE} + ARGS -f ${OUTFILE} -c -DHAVE_CONFIG_H ${INCLUDE_DIRS} ${INFILES} ${LINKDEF_FILE} DEPENDS ${INFILES} ${LINKDEF_FILE}) + else (CMAKE_SYSTEM_NAME MATCHES Linux) + if (CMAKE_SYSTEM_NAME MATCHES Darwin) + ADD_CUSTOM_COMMAND(OUTPUT ${OUTFILES} + COMMAND DYLD_LIBRARY_PATH=${ROOT_LIBRARY_DIR} ROOTSYS=${ROOTSYS} ${ROOT_CINT_EXECUTABLE} + ARGS -f ${OUTFILE} -c -DHAVE_CONFIG_H ${INCLUDE_DIRS} ${INFILES} ${LINKDEF_FILE} DEPENDS ${INFILES} ${LINKDEF_FILE}) + endif (CMAKE_SYSTEM_NAME MATCHES Darwin) + endif (CMAKE_SYSTEM_NAME MATCHES Linux) + +ENDMACRO (ROOT_GENERATE_DICTIONARY_OLD) + +MACRO (GENERATE_ROOT_TEST_SCRIPT SCRIPT_FULL_NAME) + + get_filename_component(path_name ${SCRIPT_FULL_NAME} PATH) + get_filename_component(file_extension ${SCRIPT_FULL_NAME} EXT) + get_filename_component(file_name ${SCRIPT_FULL_NAME} NAME_WE) + set(shell_script_name "${file_name}.sh") + + #MESSAGE("PATH: ${path_name}") + #MESSAGE("Ext: ${file_extension}") + #MESSAGE("Name: ${file_name}") + #MESSAGE("Shell Name: ${shell_script_name}") + + string(REPLACE ${PROJECT_SOURCE_DIR} + ${PROJECT_BINARY_DIR} new_path ${path_name} + ) + + #MESSAGE("New PATH: ${new_path}") + + file(MAKE_DIRECTORY ${new_path}/data) + + CONVERT_LIST_TO_STRING(${LD_LIBRARY_PATH}) + set(MY_LD_LIBRARY_PATH ${output}) + + CONVERT_LIST_TO_STRING(${ROOT_INCLUDE_PATH}) + set(MY_ROOT_INCLUDE_PATH ${output}) + + set(my_script_name ${SCRIPT_FULL_NAME}) + + IF(FAIRROOTPATH) + configure_file(${FAIRROOTPATH}/share/fairbase/cmake/scripts/root_macro.sh.in + ${new_path}/${shell_script_name} + ) + ELSE(FAIRROOTPATH) + configure_file(${PROJECT_SOURCE_DIR}/cmake/scripts/root_macro.sh.in + ${new_path}/${shell_script_name} + ) + ENDIF(FAIRROOTPATH) + + EXEC_PROGRAM(/bin/chmod ARGS "u+x ${new_path}/${shell_script_name}") + +ENDMACRO (GENERATE_ROOT_TEST_SCRIPT) + + +Macro(ROOT_GENERATE_ROOTMAP) + + # All Arguments needed for this new version of the macro are defined + # in the parent scope, namely in the CMakeLists.txt of the submodule + if (DEFINED LINKDEF) + foreach(l ${LINKDEF}) + If( IS_ABSOLUTE ${l}) + Set(Int_LINKDEF ${Int_LINKDEF} ${l}) + Else( IS_ABSOLUTE ${l}) + Set(Int_LINKDEF ${Int_LINKDEF} ${CMAKE_CURRENT_SOURCE_DIR}/${l}) + EndIf( IS_ABSOLUTE ${l}) + endforeach() + + foreach(d ${DEPENDENCIES}) + get_filename_component(_ext ${d} EXT) + If(NOT _ext MATCHES a$) + if(_ext) + set(Int_DEPENDENCIES ${Int_DEPENDENCIES} ${d}) + else() + set(Int_DEPENDENCIES ${Int_DEPENDENCIES} lib${d}.so) + endif() + Else() + Message("Found Static library with extension ${_ext}") + EndIf() + endforeach() + + set(Int_LIB ${LIBRARY_NAME}) + set(Int_OUTFILE ${LIBRARY_OUTPUT_PATH}/lib${Int_LIB}.rootmap) + + add_custom_command(OUTPUT ${Int_OUTFILE} + COMMAND ${RLIBMAP_EXECUTABLE} -o ${Int_OUTFILE} -l ${Int_LIB} + -d ${Int_DEPENDENCIES} -c ${Int_LINKDEF} + DEPENDS ${Int_LINKDEF} ${RLIBMAP_EXECUTABLE} ) + add_custom_target( lib${Int_LIB}.rootmap ALL DEPENDS ${Int_OUTFILE}) + set_target_properties(lib${Int_LIB}.rootmap PROPERTIES FOLDER RootMaps ) + #---Install the rootmap file------------------------------------ + #install(FILES ${Int_OUTFILE} DESTINATION lib COMPONENT libraries) + install(FILES ${Int_OUTFILE} DESTINATION lib) + endif(DEFINED LINKDEF) +EndMacro(ROOT_GENERATE_ROOTMAP) + +Macro(GENERATE_LIBRARY) + + set(Int_LIB ${LIBRARY_NAME}) + + Set(HeaderRuleName "${Int_LIB}_HEADER_RULES") + Set(DictName "G__${Int_LIB}Dict.cxx") + + If(NOT DICTIONARY) + Set(DICTIONARY ${CMAKE_CURRENT_BINARY_DIR}/${DictName}) + EndIf(NOT DICTIONARY) + + If( IS_ABSOLUTE ${DICTIONARY}) + Set(DICTIONARY ${DICTIONARY}) + Else( IS_ABSOLUTE ${DICTIONARY}) + Set(Int_DICTIONARY ${CMAKE_CURRENT_SOURCE_DIR}/${DICTIONARY}) + EndIf( IS_ABSOLUTE ${DICTIONARY}) + + Set(Int_SRCS ${SRCS}) + + If(HEADERS) + Set(HDRS ${HEADERS}) + Else(HEADERS) + CHANGE_FILE_EXTENSION(*.cxx *.h HDRS "${SRCS}") + EndIf(HEADERS) + + If(IWYU_FOUND) + Set(_INCLUDE_DIRS ${INCLUDE_DIRECTORIES} ${SYSTEM_INCLUDE_DIRECTORIES}) + CHECK_HEADERS("${Int_SRCS}" "${_INCLUDE_DIRS}" ${HeaderRuleName}) + EndIf(IWYU_FOUND) + + install(FILES ${HDRS} DESTINATION include) + + If(LINKDEF) + If( IS_ABSOLUTE ${LINKDEF}) + Set(Int_LINKDEF ${LINKDEF}) + Else( IS_ABSOLUTE ${LINKDEF}) + Set(Int_LINKDEF ${CMAKE_CURRENT_SOURCE_DIR}/${LINKDEF}) + EndIf( IS_ABSOLUTE ${LINKDEF}) + ROOT_GENERATE_DICTIONARY() + SET(Int_SRCS ${Int_SRCS} ${DICTIONARY}) + SET_SOURCE_FILES_PROPERTIES(${DICTIONARY} + PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast" + ) + EndIf(LINKDEF) + + + If (ROOT_FOUND_VERSION LESS 59999) + ROOT_GENERATE_ROOTMAP() + EndIf() + + set(Int_DEPENDENCIES) + foreach(d ${DEPENDENCIES}) + get_filename_component(_ext ${d} EXT) + If(NOT _ext MATCHES a$) + set(Int_DEPENDENCIES ${Int_DEPENDENCIES} ${d}) + Else() + Message("Found Static library with extension ${_ext}") + get_filename_component(_lib ${d} NAME_WE) + set(Int_DEPENDENCIES ${Int_DEPENDENCIES} ${_lib}) + EndIf() + endforeach() + + ############### build the library ##################### + If(${CMAKE_GENERATOR} MATCHES Xcode) + Add_Library(${Int_LIB} SHARED ${Int_SRCS} ${NO_DICT_SRCS} ${HDRS} ${LINKDEF}) + Else() + Add_Library(${Int_LIB} SHARED ${Int_SRCS} ${NO_DICT_SRCS} ${LINKDEF}) + EndIf() + target_link_libraries(${Int_LIB} ${Int_DEPENDENCIES}) + set_target_properties(${Int_LIB} PROPERTIES ${FAIRROOT_LIBRARY_PROPERTIES}) + + ############### install the library ################### + install(TARGETS ${Int_LIB} DESTINATION lib) + + Set(LIBRARY_NAME) + Set(DICTIONARY) + Set(LINKDEF) + Set(SRCS) + Set(HEADERS) + Set(NO_DICT_SRCS) + Set(DEPENDENCIES) + +EndMacro(GENERATE_LIBRARY) + + +Macro(GENERATE_EXECUTABLE) + +# If(IWYU_FOUND) +# Set(HeaderRuleName "${EXE_NAME}_HEADER_RULES") +# CHECK_HEADERS("${SRCS}" "${INCLUDE_DIRECTORIES}" ${HeaderRuleName}) +# EndIf(IWYU_FOUND) + + ############### build the library ##################### + Add_Executable(${EXE_NAME} ${SRCS}) + target_link_libraries(${EXE_NAME} ${DEPENDENCIES}) + + ############### install the library ################### + if(DEFINED BIN_DESTINATION) + install(TARGETS ${EXE_NAME} DESTINATION ${BIN_DESTINATION}) + else(DEFINED BIN_DESTINATION) + install(TARGETS ${EXE_NAME} DESTINATION bin) + endif(DEFINED BIN_DESTINATION) + + Set(EXE_NAME) + Set(SRCS) + Set(DEPENDENCIES) + +EndMacro(GENERATE_EXECUTABLE) + diff --git a/cmake/RootNewMacros.cmake b/cmake/RootNewMacros.cmake new file mode 100644 index 0000000000..7c18921d26 --- /dev/null +++ b/cmake/RootNewMacros.cmake @@ -0,0 +1,862 @@ +#--------------------------------------------------------------------------------------------------- +# RootNewMacros.cmake +#--------------------------------------------------------------------------------------------------- +cmake_policy(SET CMP0003 NEW) # See "cmake --help-policy CMP0003" for more details +cmake_policy(SET CMP0011 NEW) # See "cmake --help-policy CMP0011" for more details +cmake_policy(SET CMP0009 NEW) # See "cmake --help-policy CMP0009" for more details +if(CMAKE_VERSION VERSION_GREATER 2.8.12) + cmake_policy(SET CMP0022 OLD) # See "cmake --help-policy CMP0022" for more details +endif() + +set(lib lib) +set(bin bin) +if(WIN32) + set(ssuffix .bat) + set(scomment rem) + set(libprefix lib) + set(ld_library_path PATH) + set(libsuffix .dll) + set(runtimedir ${CMAKE_INSTALL_BINDIR}) +elseif(APPLE) + set(ld_library_path DYLD_LIBRARY_PATH) + set(ssuffix .csh) + set(scomment \#) + set(libprefix lib) + set(libsuffix .so) + set(runtimedir ${CMAKE_INSTALL_LIBDIR}) +else() + set(ld_library_path LD_LIBRARY_PATH) + set(ssuffix .csh) + set(scomment \#) + set(libprefix lib) + set(libsuffix .so) + set(runtimedir ${CMAKE_INSTALL_LIBDIR}) +endif() + +if(soversion) + set(ROOT_LIBRARY_PROPERTIES ${ROOT_LIBRARY_PROPERTIES} + VERSION ${ROOT_VERSION} + SOVERSION ${ROOT_MAJOR_VERSION} + SUFFIX ${libsuffix} + PREFIX ${libprefix} ) +else() + set(ROOT_LIBRARY_PROPERTIES ${ROOT_LIBRARY_PROPERTIES} + SUFFIX ${libsuffix} + PREFIX ${libprefix} + IMPORT_PREFIX ${libprefix} ) +endif() + +if(APPLE) + if(gnuinstall) + set(ROOT_LIBRARY_PROPERTIES ${ROOT_LIBRARY_PROPERTIES} + INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}" + BUILD_WITH_INSTALL_RPATH ON) + else() + set(ROOT_LIBRARY_PROPERTIES ${ROOT_LIBRARY_PROPERTIES} + INSTALL_NAME_DIR "@rpath" + BUILD_WITH_INSTALL_RPATH ON) + endif() +endif() + +#---Modify the behaviour for local and non-local builds-------------------------------------------- + +if(CMAKE_PROJECT_NAME STREQUAL ROOT) + set(rootcint_cmd rootcling_tmp) + set(rlibmap_cmd rlibmap) + set(genreflex_cmd genreflex) + set(ROOTCINTDEP rootcling_tmp) +else() + set(rootcint_cmd rootcling) + set(rlibmap_cmd rlibmap) + set(genreflex_cmd genreflex) + set(ROOTCINTDEP) +endif() + +set(CMAKE_VERBOSE_MAKEFILES OFF) +set(CMAKE_INCLUDE_CURRENT_DIR OFF) + +include(CMakeParseArguments) + +#--------------------------------------------------------------------------------------------------- +#---ROOT_GLOB_FILES( [REALTIVE path] [FILTER regexp] ...) +#--------------------------------------------------------------------------------------------------- +function(ROOT_GLOB_FILES variable) + CMAKE_PARSE_ARGUMENTS(ARG "" "RELATIVE;FILTER" "" ${ARGN}) + if(ARG_RELATIVE) + file(GLOB _sources RELATIVE ${ARG_RELATIVE} ${ARG_UNPARSED_ARGUMENTS}) + else() + file(GLOB _sources ${ARG_UNPARSED_ARGUMENTS}) + endif() + if(ARG_FILTER) + foreach(s ${_sources}) + if(s MATCHES ${ARG_FILTER}) + list(REMOVE_ITEM _sources ${s}) + endif() + endforeach() + endif() + set(${variable} ${_sources} PARENT_SCOPE) +endfunction() + +function(ROOT_GLOB_SOURCES variable) + ROOT_GLOB_FILES(_sources FILTER "(^|/)G__" ${ARGN}) + set(${variable} ${_sources} PARENT_SCOPE) +endfunction() + +function(ROOT_GLOB_HEADERS variable) + ROOT_GLOB_FILES(_sources FILTER "LinkDef" ${ARGN}) + set(${variable} ${_sources} PARENT_SCOPE) +endfunction() + +#--------------------------------------------------------------------------------------------------- +#---ROOT_GET_SOURCES( cwd ...) +#--------------------------------------------------------------------------------------------------- +function(ROOT_GET_SOURCES variable cwd ) + set(sources) + foreach( fp ${ARGN}) + if( IS_ABSOLUTE ${fp}) + file(GLOB files ${fp}) + else() + file(GLOB files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${cwd}/${fp}) + endif() + if(files) + foreach(s ${files}) + if(fp MATCHES "[*]" AND s MATCHES "(^|/)G__") # Eliminate G__* files + elseif(s MATCHES "${cwd}/G__") + set(sources ${fp} ${sources}) + else() + set(sources ${sources} ${s}) + endif() + endforeach() + else() + if(fp MATCHES "(^|/)G__") + set(sources ${fp} ${sources}) + else() + set(sources ${sources} ${fp}) + endif() + endif() + endforeach() + set(${variable} ${sources} PARENT_SCOPE) +endfunction() + + +#--------------------------------------------------------------------------------------------------- +#---ROOT_GENERATE_DICTIONARY( dictionary headerfiles MODULE module DEPENDENCIES dep1 dep2 +# STAGE1 LINKDEF linkdef OPTIONS opt1 opt2 ...) +#--------------------------------------------------------------------------------------------------- +function(ROOT_GENERATE_DICTIONARY dictionary) + CMAKE_PARSE_ARGUMENTS(ARG "STAGE1;MULTIDICT" "MODULE" "LINKDEF;OPTIONS;DEPENDENCIES;EXTRA_INC_DIRS" ${ARGN}) + + #---roottest compability--------------------------------- + if(CMAKE_ROOTTEST_DICT) + set(CMAKE_INSTALL_LIBDIR ${CMAKE_CURRENT_BINARY_DIR}) + set(libprefix "") + endif() + + #---Get the list of header files------------------------- + set(headerfiles) + foreach(fp ${ARG_UNPARSED_ARGUMENTS}) + file(GLOB files inc/${fp}) + if(files) + foreach(f ${files}) + if(NOT f MATCHES LinkDef) + set(headerfiles ${headerfiles} ${f}) + endif() + endforeach() + else() + set(headerfiles ${headerfiles} ${fp}) + endif() + endforeach() + string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/inc/" "" rheaderfiles "${headerfiles}") + string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/../include/" "" rheaderfiles "${headerfiles}") + #---Get the list of include directories------------------ + get_directory_property(incdirs INCLUDE_DIRECTORIES) + if(CMAKE_PROJECT_NAME STREQUAL ROOT) + set(includedirs -I${CMAKE_SOURCE_DIR} + -I${CMAKE_BINARY_DIR}/include) + elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/inc) + set(includedirs -I${CMAKE_CURRENT_SOURCE_DIR}/inc) + endif() + foreach( f ${ARG_EXTRA_INC_DIRS}) + if( IS_ABSOLUTE ${f}) + set(incdirs ${incdirs} ${f}) + else() + set(incdirs ${incdirs} ${CMAKE_CURRENT_SOURCE_DIR}/${f}) + endif() + endforeach() + foreach( d ${incdirs}) + set(includedirs ${includedirs} -I${d}) + endforeach() + list(REMOVE_DUPLICATES includedirs) + #---Get the list of definitions--------------------------- + get_directory_property(defs COMPILE_DEFINITIONS) + foreach( d ${defs}) + if((NOT d MATCHES "=") AND (NOT d MATCHES "^[$]<.*>$")) # avoid generator expressions + set(definitions ${definitions} -D${d}) + endif() + endforeach() + #---Get LinkDef.h file------------------------------------ + foreach( f ${ARG_LINKDEF}) + if( IS_ABSOLUTE ${f}) + set(_linkdef ${_linkdef} ${f}) + else() + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/inc/${f}) + set(_linkdef ${_linkdef} ${CMAKE_CURRENT_SOURCE_DIR}/inc/${f}) + else() + set(_linkdef ${_linkdef} ${CMAKE_CURRENT_SOURCE_DIR}/${f}) + endif() + endif() + endforeach() + + #---Build the names for library, pcm and rootmap file ---- + get_filename_component(dict_base_name ${dictionary} NAME_WE) + if(dict_base_name MATCHES "^G__") + string(SUBSTRING ${dictionary} 3 -1 deduced_arg_module) + else() + set(deduced_arg_module ${dict_base_name}) + endif() + + #---Set the library output directory----------------------- + if(DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY) + set(library_output_dir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) + else() + set(library_output_dir ${CMAKE_CURRENT_BINARY_DIR}) + endif() + + if(ARG_MODULE) + set(library_name ${libprefix}${ARG_MODULE}${libsuffix}) + if(ARG_MULTIDICT) + set(newargs -s ${library_output_dir}/${library_name} -multiDict) + set(pcm_name ${library_output_dir}/${libprefix}${ARG_MODULE}_${dictionary}_rdict.pcm) + set(rootmap_name ${library_output_dir}/${libprefix}${deduced_arg_module}.rootmap) + else() + set(newargs -s ${library_output_dir}/${library_name}) + set(pcm_name ${library_output_dir}/${libprefix}${ARG_MODULE}_rdict.pcm) + set(rootmap_name ${library_output_dir}/${libprefix}${ARG_MODULE}.rootmap) + endif() + else() + set(library_name ${libprefix}${deduced_arg_module}${libsuffix}) + set(pcm_name ${dictionary}_rdict.pcm) + set(rootmap_name ${library_output_dir}/${libprefix}${deduced_arg_module}.rootmap) + endif() + + if(CMAKE_ROOTTEST_NOROOTMAP) + set(rootmapname ) + set(rootmapargs ) + else() + set(rootmapargs -rml ${library_name} -rmf ${rootmap_name}) + endif() + + #---Get the library and module dependencies----------------- + if(ARG_DEPENDENCIES) + foreach(dep ${ARG_DEPENDENCIES}) + set(newargs ${newargs} -m ${libprefix}${dep}_rdict.pcm) + endforeach() + endif() + + #---what rootcling command to use-------------------------- + if(ARG_STAGE1) + set(command rootcling_tmp) + set(pcm_name) + else() + if(CMAKE_PROJECT_NAME STREQUAL ROOT) + set(command rootcling -rootbuild) + set(ROOTCINTDEP rootcling) + else() + set(command rootcling) + endif() + endif() + + #---call rootcint------------------------------------------ + add_custom_command(OUTPUT ${dictionary}.cxx ${pcm_name} ${rootmap_name} + COMMAND ${command} -f ${dictionary}.cxx ${newargs} ${rootmapargs} + ${ARG_OPTIONS} ${definitions} ${includedirs} ${rheaderfiles} ${_linkdef} + DEPENDS ${headerfiles} ${_linkdef} ${ROOTCINTDEP}) + get_filename_component(dictname ${dictionary} NAME) + + #---roottest compability +# message("CMAKE_LIBRARY_OUTPUT_DIRECTORY : ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") +# message("CMAKE_ROOTTEST_DICT : ${CMAKE_ROOTTEST_DICT}") +# message((CMAKE_ROOTTEST_DICT OR (NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY))) +# if(CMAKE_ROOTTEST_DICT OR (NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY)) +# message("arg ${dictionary}.cxx") +# add_custom_target(${dictname} DEPENDS ${dictionary}.cxx) +# else() +# message("defined") +# add_custom_target(${dictname} DEPENDS ${dictionary}.cxx) +# +# set_property(GLOBAL APPEND PROPERTY ROOT_DICTIONARY_TARGETS ${dictname}) +# set_property(GLOBAL APPEND PROPERTY ROOT_DICTIONARY_FILES ${CMAKE_CURRENT_BINARY_DIR}/${dictionary}.cxx) +# +# if(ARG_STAGE1) +# message("CMAKE_INSTALL_LIBDIR : ${CMAKE_INSTALL_LIBDIR}") +#install(FILES ${rootmap_name} +# DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries) +# else() +# message("CMAKE_INSTALL_LIBDIR : ${CMAKE_INSTALL_LIBDIR}") +# message("pcm_name : ${pcm_name}") +# message("rootmap_name : ${rootmap_name}") +# message("pcm_name : ${CMAKE_CURRENT_BINARY_DIR}/${pcm_name}") +# message("pcm_name : ${CMAKE_CURRENT_BINARY_DIR}/${rootmap_name}") +# install(FILES "${pcm_name}" "${rootmap_name}" +# DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries) +# endif() +# endif() +endfunction() + + +#--------------------------------------------------------------------------------------------------- +#---ROOT_LINKER_LIBRARY( source1 source2 ...[TYPE STATIC|SHARED] [DLLEXPORT] LIBRARIES library1 library2 ...) +#--------------------------------------------------------------------------------------------------- +function(ROOT_LINKER_LIBRARY library) + CMAKE_PARSE_ARGUMENTS(ARG "DLLEXPORT;CMAKENOEXPORT;TEST" "TYPE" "LIBRARIES;DEPENDENCIES" ${ARGN}) + ROOT_GET_SOURCES(lib_srcs src ${ARG_UNPARSED_ARGUMENTS}) + if(NOT ARG_TYPE) + set(ARG_TYPE SHARED) + endif() + if(ARG_TEST) # we are building a test, so add EXCLUDE_FROM_ALL + set(_all EXCLUDE_FROM_ALL) + endif() + include_directories(${CMAKE_BINARY_DIR}/include) # This is a copy and certainly should last one + set(library_name ${library}) + if(TARGET ${library}) + message("Target ${library} already exists. Renaming target name to ${library}_new") + set(library ${library}_new) + endif() + if(WIN32 AND ARG_TYPE STREQUAL SHARED AND NOT ARG_DLLEXPORT) + #---create a list of all the object files----------------------------- + if(CMAKE_GENERATOR MATCHES "Visual Studio") + #foreach(src1 ${lib_srcs}) + # if(NOT src1 MATCHES "[.]h$|[.]icc$|[.]hxx$|[.]hpp$") + # string (REPLACE ${CMAKE_CURRENT_SOURCE_DIR} "" src2 ${src1}) + # string (REPLACE ${CMAKE_CURRENT_BINARY_DIR} "" src3 ${src2}) + # string (REPLACE ".." "__" src ${src3}) + # get_filename_component(name ${src} NAME_WE) + # set(lib_objs ${lib_objs} ${library}.dir/${CMAKE_CFG_INTDIR}/${name}.obj) + # endif() + #endforeach() + set(lib_objs ${lib_objs} ${library}.dir/${CMAKE_CFG_INTDIR}/*.obj) + else() + foreach(src1 ${lib_srcs}) + if(NOT src1 MATCHES "[.]h$|[.]icc$|[.]hxx$|[.]hpp$") + string (REPLACE ${CMAKE_CURRENT_SOURCE_DIR} "" src2 ${src1}) + string (REPLACE ${CMAKE_CURRENT_BINARY_DIR} "" src3 ${src2}) + string (REPLACE ".." "__" src ${src3}) + get_filename_component(name ${src} NAME) + get_filename_component(path ${src} PATH) + set(lib_objs ${lib_objs} ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${library}.dir/${path}/${name}.obj) + endif() + endforeach() + endif() + #---create a shared library with the .def file------------------------ + add_library(${library} ${_all} SHARED ${lib_srcs}) + target_link_libraries(${library} ${ARG_LIBRARIES} ${ARG_DEPENDENCIES}) + set_target_properties(${library} PROPERTIES ${ROOT_LIBRARY_PROPERTIES} LINK_FLAGS -DEF:${library}.def) + #---set the .def file as generated------------------------------------ + set_source_files_properties(${library}.def PROPERTIES GENERATED 1) + #---create a custom pre-link command that runs bindexplib + add_custom_command(TARGET ${library} PRE_LINK + COMMAND bindexplib + ARGS -o ${library}.def ${libprefix}${library} ${lib_objs} + DEPENDS bindexplib ) + else() + #---Need to add a dummy source file if all sources are OBJECT libraries (Xcode, ...) + if(NOT lib_srcs MATCHES "(^|[;])[^$][^<]") + add_custom_command(OUTPUT dummy.cxx COMMAND ${CMAKE_COMMAND} -E touch dummy.cxx) + set(lib_srcs ${lib_srcs} dummy.cxx) + endif() + add_library( ${library} ${_all} ${ARG_TYPE} ${lib_srcs}) + if(ARG_TYPE STREQUAL SHARED) + set_target_properties(${library} PROPERTIES ${ROOT_LIBRARY_PROPERTIES} ) + endif() + if(explicitlink OR ROOT_explicitlink_FOUND) + target_link_libraries(${library} ${ARG_LIBRARIES} ${ARG_DEPENDENCIES}) + else() + target_link_libraries(${library} ${ARG_LIBRARIES}) + endif() + endif() + if(TARGET G__${library}) + add_dependencies(${library} G__${library}) + endif() + if(TARGET move_headers) + add_dependencies(${library} move_headers) + endif() + set_property(GLOBAL APPEND PROPERTY ROOT_EXPORTED_TARGETS ${library}) + set_target_properties(${library} PROPERTIES OUTPUT_NAME ${library_name}) + set_target_properties(${library} PROPERTIES LINK_INTERFACE_LIBRARIES "${ARG_DEPENDENCIES}") + #----Installation details------------------------------------------------------- + if(NOT ARG_TEST AND CMAKE_LIBRARY_OUTPUT_DIRECTORY) + if(ARG_CMAKENOEXPORT) + install(TARGETS ${library} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries) + else() + install(TARGETS ${library} EXPORT ${CMAKE_PROJECT_NAME}Exports + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries) + endif() + if(WIN32 AND ARG_TYPE STREQUAL SHARED) + install(FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/lib${library}.pdb + CONFIGURATIONS Debug RelWithDebInfo + DESTINATION ${CMAKE_INSTALL_BINDIR} + COMPONENT libraries) + endif() + endif() +endfunction() + +#--------------------------------------------------------------------------------------------------- +#---ROOT_OBJECT_LIBRARY( source1 source2 ...) +#--------------------------------------------------------------------------------------------------- +function(ROOT_OBJECT_LIBRARY library) + ROOT_GET_SOURCES(lib_srcs src ${ARGN}) + include_directories(AFTER ${CMAKE_BINARY_DIR}/include) + add_library( ${library} OBJECT ${lib_srcs}) + if(lib_srcs MATCHES "(^|/)(G__[^.]*)[.]cxx.*") + add_dependencies(${library} ${CMAKE_MATCH_2}) + endif() + if(TARGET move_headers) + add_dependencies(${library} move_headers) + endif() + + #--- Fill the property OBJECTS with all the object files + # This is needed becuase the generator expression $ + # does not get expanded when used in custom command dependencies + get_target_property(sources ${library} SOURCES) + foreach(s ${sources}) + if(CMAKE_GENERATOR MATCHES Xcode) + get_filename_component(name ${s} NAME_WE) + set(obj ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.build/${CMAKE_CFG_INTDIR}/${library}.build/Objects-normal/x86_64/${name}${CMAKE_CXX_OUTPUT_EXTENSION}) + else() + if(IS_ABSOLUTE ${s}) + if(${s} MATCHES ${CMAKE_CURRENT_SOURCE_DIR}) + string(REPLACE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${library}.dir src ${s}) + elseif(${s} MATCHES ${CMAKE_CURRENT_BINARY_DIR}) + string(REPLACE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${library}.dir src ${s}) + else() + #message(WARNING "Unknown location of source ${s} for object library ${library}") + endif() + else() + set(src ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${library}.dir/${s}) + endif() + set(obj ${src}${CMAKE_CXX_OUTPUT_EXTENSION}) + endif() + set_property(TARGET ${library} APPEND PROPERTY OBJECTS ${obj}) + endforeach() +endfunction() + +#--------------------------------------------------------------------------------------------------- +#---ROOT_MODULE_LIBRARY( source1 source2 ... [DLLEXPORT] LIBRARIES library1 library2 ...) +#--------------------------------------------------------------------------------------------------- +function(ROOT_MODULE_LIBRARY library) + CMAKE_PARSE_ARGUMENTS(ARG "" "" "LIBRARIES" ${ARGN}) + ROOT_GET_SOURCES(lib_srcs src ${ARG_UNPARSED_ARGUMENTS}) + include_directories(${CMAKE_BINARY_DIR}/include) + add_library( ${library} SHARED ${lib_srcs}) + if(TARGET move_headers) + add_dependencies(${library} move_headers) + endif() + set_target_properties(${library} PROPERTIES ${ROOT_LIBRARY_PROPERTIES}) + target_link_libraries(${library} ${ARG_LIBRARIES}) + #----Installation details------------------------------------------------------- + install(TARGETS ${library} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries) +endfunction() + +#--------------------------------------------------------------------------------------------------- +#---ROOT_USE_PACKAGE( package ) +#--------------------------------------------------------------------------------------------------- +macro( ROOT_USE_PACKAGE package ) +endmacro() + +#--------------------------------------------------------------------------------------------------- +#---ROOT_GENERATE_ROOTMAP( library LINKDEF linkdef LIBRRARY lib DEPENDENCIES lib1 lib2 ) +#--------------------------------------------------------------------------------------------------- +function(ROOT_GENERATE_ROOTMAP library) + return() #--- No needed anymore + CMAKE_PARSE_ARGUMENTS(ARG "" "LIBRARY" "LINKDEF;DEPENDENCIES" ${ARGN}) + get_filename_component(libname ${library} NAME_WE) + get_filename_component(path ${library} PATH) + + #---Set the library output directory----------------------- + if(DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY) + set(library_output_dir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) + else() + set(library_output_dir ${CMAKE_CURRENT_BINARY_DIR}) + endif() + + set(outfile ${library_output_dir}/${libprefix}${libname}.rootmap) + foreach( f ${ARG_LINKDEF}) + if( IS_ABSOLUTE ${f}) + set(_linkdef ${_linkdef} ${f}) + else() + set(_linkdef ${_linkdef} ${CMAKE_CURRENT_SOURCE_DIR}/inc/${f}) + endif() + endforeach() + foreach(d ${ARG_DEPENDENCIES}) + get_filename_component(_ext ${d} EXT) + if(_ext) + set(_dependencies ${_dependencies} ${d}) + else() + set(_dependencies ${_dependencies} ${libprefix}${d}${CMAKE_SHARED_LIBRARY_SUFFIX}) + endif() + endforeach() + if(ARG_LIBRARY) + set(_library ${ARG_LIBRARY}) + else() + set(_library ${libprefix}${library}${CMAKE_SHARED_LIBRARY_SUFFIX}) + endif() + #---Build the rootmap file-------------------------------------- + add_custom_command(OUTPUT ${outfile} + COMMAND ${rlibmap_cmd} -o ${outfile} -l ${_library} -d ${_dependencies} -c ${_linkdef} + DEPENDS ${_linkdef} ${rlibmap_cmd} ) + add_custom_target( ${libprefix}${library}.rootmap ALL DEPENDS ${outfile}) + set_target_properties(${libprefix}${library}.rootmap PROPERTIES FOLDER RootMaps ) + #---Install the rootmap file------------------------------------ + install(FILES ${outfile} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries) +endfunction() + +#--------------------------------------------------------------------------------------------------- +#---ROOT_INSTALL_HEADERS([dir1 dir2 ...] OPTIONS [options]) +#--------------------------------------------------------------------------------------------------- +function(ROOT_INSTALL_HEADERS) + CMAKE_PARSE_ARGUMENTS(ARG "" "" "OPTIONS" ${ARGN}) + if( ARG_UNPARSED_ARGUMENTS ) + set(dirs ${ARG_UNPARSED_ARGUMENTS}) + else() + set(dirs inc/) + endif() + foreach(d ${dirs}) + install(DIRECTORY ${d} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + COMPONENT headers + PATTERN ".svn" EXCLUDE + REGEX "LinkDef" EXCLUDE + ${ARG_OPTIONS}) + set_property(GLOBAL APPEND PROPERTY ROOT_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/${d}) + endforeach() +endfunction() + +#--------------------------------------------------------------------------------------------------- +#---ROOT_STANDARD_LIBRARY_PACKAGE(libname DEPENDENCIES lib1 lib2) +#--------------------------------------------------------------------------------------------------- +function(ROOT_STANDARD_LIBRARY_PACKAGE libname) + CMAKE_PARSE_ARGUMENTS(ARG "" "" "DEPENDENCIES;DICTIONARY_OPTIONS" ${ARGN}) + ROOT_GENERATE_DICTIONARY(G__${libname} *.h MODULE ${libname} LINKDEF LinkDef.h OPTIONS ${ARG_DICTIONARY_OPTIONS}) + ROOT_LINKER_LIBRARY(${libname} *.cxx G__${libname}.cxx DEPENDENCIES ${ARG_DEPENDENCIES}) + ROOT_INSTALL_HEADERS() +endfunction() + +#--------------------------------------------------------------------------------------------------- +#---ROOT_EXECUTABLE( source1 source2 ... LIBRARIES library1 library2 ...) +#--------------------------------------------------------------------------------------------------- +function(ROOT_EXECUTABLE executable) + CMAKE_PARSE_ARGUMENTS(ARG "CMAKENOEXPORT;NOINSTALL;TEST" "" "LIBRARIES;ADDITIONAL_COMPILE_FLAGS" ${ARGN}) + ROOT_GET_SOURCES(exe_srcs src ${ARG_UNPARSED_ARGUMENTS}) + set(executable_name ${executable}) + if(TARGET ${executable}) + message("Target ${executable} already exists. Renaming target name to ${executable}_new") + set(executable ${executable}_new) + endif() + if(ARG_TEST) # we are building a test, so add EXCLUDE_FROM_ALL + set(_all EXCLUDE_FROM_ALL) + endif() + include_directories(${CMAKE_BINARY_DIR}/include) + add_executable( ${executable} ${_all} ${exe_srcs}) + target_link_libraries(${executable} ${ARG_LIBRARIES} ) + if(WIN32 AND ${executable} MATCHES .exe) + set_target_properties(${executable} PROPERTIES SUFFIX "") + endif() + set_property(GLOBAL APPEND PROPERTY ROOT_EXPORTED_TARGETS ${executable}) + set_target_properties(${executable} PROPERTIES OUTPUT_NAME ${executable_name}) + if (ARG_ADDITIONAL_COMPILE_FLAGS) + set_target_properties(${executable} PROPERTIES COMPILE_FLAGS ${ARG_ADDITIONAL_COMPILE_FLAGS}) + endif() + if(TARGET move_headers) + add_dependencies(${executable} move_headers) + endif() + + #----Installation details------------------------------------------------------ + if(NOT ARG_NOINSTALL AND CMAKE_RUNTIME_OUTPUT_DIRECTORY) + if(ARG_CMAKENOEXPORT) + install(TARGETS ${executable} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT applications) + else() + install(TARGETS ${executable} EXPORT ${CMAKE_PROJECT_NAME}Exports RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT applications) + endif() + if(WIN32) + install(FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${executable}.pdb + CONFIGURATIONS Debug RelWithDebInfo + DESTINATION ${CMAKE_INSTALL_BINDIR} + COMPONENT applications) + endif() + endif() +endfunction() + +#--------------------------------------------------------------------------------------------------- +#---REFLEX_BUILD_DICTIONARY( dictionary headerfiles selectionfile OPTIONS opt1 opt2 ... LIBRARIES lib1 lib2 ... ) +#--------------------------------------------------------------------------------------------------- +function(REFLEX_BUILD_DICTIONARY dictionary headerfiles selectionfile ) + CMAKE_PARSE_ARGUMENTS(ARG "" "" "LIBRARIES;OPTIONS" ${ARGN}) + REFLEX_GENERATE_DICTIONARY(${dictionary} ${headerfiles} SELECTION ${selectionfile} OPTIONS ${ARG_OPTIONS}) + add_library(${dictionary}Dict MODULE ${gensrcdict}) + target_link_libraries(${dictionary}Dict ${ARG_LIBRARIES} ${ROOT_Reflex_LIBRARY}) + #----Installation details------------------------------------------------------- + install(TARGETS ${dictionary}Dict LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + set(mergedRootMap ${CMAKE_INSTALL_PREFIX}/${lib}/${CMAKE_PROJECT_NAME}Dict.rootmap) + set(srcRootMap ${CMAKE_CURRENT_BINARY_DIR}/${rootmapname}) + install(CODE "EXECUTE_PROCESS(COMMAND ${merge_rootmap_cmd} --do-merge --input-file ${srcRootMap} --merged-file ${mergedRootMap})") +endfunction() + +#--------------------------------------------------------------------------------------------------- +#---ROOT_CHECK_OUT_OF_SOURCE_BUILD( ) +#--------------------------------------------------------------------------------------------------- +macro(ROOT_CHECK_OUT_OF_SOURCE_BUILD) + get_filename_component(bindir_parent ${CMAKE_BINARY_DIR} PATH) + if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) + file(REMOVE_RECURSE ${CMAKE_SOURCE_DIR}/Testing) + file(REMOVE ${CMAKE_SOURCE_DIR}/DartConfiguration.tcl) + message(FATAL_ERROR "ROOT should be built as an out of source build, to keep the source directory clean. Please create a extra build directory and run the command 'cmake ' in this newly created directory. You have also to delete the directory CMakeFiles and the file CMakeCache.txt in the source directory. Otherwise cmake will complain even if you run it from an out-of-source directory.") + elseif(IS_SYMLINK ${CMAKE_BINARY_DIR} AND CMAKE_SOURCE_DIR STREQUAL bindir_parent) + message(FATAL_ERROR "ROOT cannot be built from a sub-directory of the source tree that is a symlink. This is a current limitation of CMake. Please create a real build directory and run the command 'cmake ' in this newly created directory.") + endif() +endmacro() + +#---------------------------------------------------------------------------- +# function ROOT_ADD_TEST( COMMAND cmd [arg1... ] +# [PRECMD cmd [arg1...]] [POSTCMD cmd [arg1...]] +# [OUTPUT outfile] [ERROR errfile] [INPUT infile] +# [ENVIRONMENT var1=val1 var2=val2 ... +# [DEPENDS test1 ...] +# [TIMEOUT seconds] +# [DEBUG] +# [SOURCE_DIR dir] [BINARY_DIR dir] +# [WORKING_DIR dir] +# [BUILD target] [PROJECT project] +# [PASSREGEX exp] [FAILREGEX epx] +# [PASSRC code]) +# +function(ROOT_ADD_TEST test) + CMAKE_PARSE_ARGUMENTS(ARG "DEBUG;WILLFAIL;CHECKOUT;CHECKERR" + "TIMEOUT;BUILD;INPUT;OUTPUT;ERROR;SOURCE_DIR;BINARY_DIR;WORKING_DIR;PROJECT;PASSRC" + "COMMAND;COPY_TO_BUILDDIR;DIFFCMD;OUTCNV;OUTCNVCMD;PRECMD;POSTCMD;ENVIRONMENT;COMPILEMACROS;DEPENDS;PASSREGEX;OUTREF;ERRREF;FAILREGEX;LABELS" + ${ARGN}) + + #- Handle COMMAND argument + list(LENGTH ARG_COMMAND _len) + if(_len LESS 1) + if(NOT ARG_BUILD) + message(FATAL_ERROR "ROOT_ADD_TEST: command is mandatory (without build)") + endif() + else() + list(GET ARG_COMMAND 0 _prg) + list(REMOVE_AT ARG_COMMAND 0) + + if(TARGET ${_prg}) # if command is a target, get the actual executable + set(_prg "$") + set(_cmd ${_prg} ${ARG_COMMAND}) + else() + find_program(_exe ${_prg}) + if(_exe) # if the command is found in the system, use it + set(_cmd ${_exe} ${ARG_COMMAND}) + elseif(NOT IS_ABSOLUTE ${_prg}) # if not absolute, assume is found in current binary dir + set(_prg ${CMAKE_CURRENT_BINARY_DIR}/${_prg}) + set(_cmd ${_prg} ${ARG_COMMAND}) + else() # take as it is + set(_cmd ${_prg} ${ARG_COMMAND}) + endif() + unset(_exe CACHE) + endif() + + string(REPLACE ";" "^" _cmd "${_cmd}") + endif() + + set(_command ${CMAKE_COMMAND} -DCMD=${_cmd}) + + #- Handle PRE and POST commands + if(ARG_PRECMD) + string(REPLACE ";" "^" _pre "${ARG_PRECMD}") + set(_command ${_command} -DPRE=${_pre}) + endif() + + if(ARG_POSTCMD) + string(REPLACE ";" "^" _post "${ARG_POSTCMD}") + set(_command ${_command} -DPOST=${_post}) + endif() + + #- Handle INPUT, OUTPUT, ERROR, DEBUG arguments + if(ARG_INPUT) + set(_command ${_command} -DIN=${ARG_INPUT}) + endif() + + if(ARG_OUTPUT) + set(_command ${_command} -DOUT=${ARG_OUTPUT}) + endif() + + if(ARG_OUTREF) + set(_command ${_command} -DOUTREF=${ARG_OUTREF}) + endif() + + if(ARG_ERRREF) + set(_command ${_command} -DERRREF=${ARG_ERRREF}) + endif() + + if(ARG_ERROR) + set(_command ${_command} -DERR=${ARG_ERROR}) + endif() + + if(ARG_WORKING_DIR) + set(_command ${_command} -DCWD=${ARG_WORKING_DIR}) + endif() + + if(ARG_DEBUG) + set(_command ${_command} -DDBG=ON) + endif() + + if(ARG_PASSRC) + set(_command ${_command} -DRC=${ARG_PASSRC}) + endif() + + if(ARG_OUTCNVCMD) + string(REPLACE ";" "^" _outcnvcmd "${ARG_OUTCNVCMD}") + set(_command ${_command} -DCNVCMD=${_outcnvcmd}) + endif() + + if(ARG_OUTCNV) + string(REPLACE ";" "^" _outcnv "${ARG_OUTCNV}") + set(_command ${_command} -DCNV=${_outcnv}) + endif() + + if(ARG_DIFFCMD) + string(REPLACE ";" "^" _diff_cmd "${ARG_DIFFCMD}") + set(_command ${_command} -DDIFFCMD=${_diff_cmd}) + endif() + + if(ARG_CHECKOUT) + set(_command ${_command} -DCHECKOUT=true) + endif() + + if(ARG_CHECKERR) + set(_command ${_command} -DCHECKERR=true) + endif() + + set(_command ${_command} -DSYS=${ROOTSYS}) + + #- Handle ENVIRONMENT argument + if(ARG_ENVIRONMENT) + string(REPLACE ";" "#" _env "${ARG_ENVIRONMENT}") + string(REPLACE "=" "@" _env "${_env}") + set(_command ${_command} -DENV=${_env}) + endif() + + #- Copy files to the build directory. + if(ARG_COPY_TO_BUILDDIR) + string(REPLACE ";" "^" _copy_files "${ARG_COPY_TO_BUILDDIR}") + set(_command ${_command} -DCOPY=${_copy_files}) + endif() + + #- Locate the test driver + find_file(ROOT_TEST_DRIVER RootTestDriver.cmake PATHS ${CMAKE_MODULE_PATH}) + if(NOT ROOT_TEST_DRIVER) + message(FATAL_ERROR "ROOT_ADD_TEST: RootTestDriver.cmake not found!") + endif() + set(_command ${_command} -P ${ROOT_TEST_DRIVER}) + + if(ARG_WILLFAIL) + set(test ${test}_WILL_FAIL) + endif() + + #- Now we can actually add the test + if(ARG_BUILD) + if(NOT ARG_SOURCE_DIR) + set(ARG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + endif() + if(NOT ARG_BINARY_DIR) + set(ARG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) + endif() + if(NOT ARG_PROJECT) + if(NOT PROJECT_NAME STREQUAL "ROOT") + set(ARG_PROJECT ${PROJECT_NAME}) + else() + set(ARG_PROJECT ${ARG_BUILD}) + endif() + endif() + add_test(NAME ${test} COMMAND ${CMAKE_CTEST_COMMAND} + --build-and-test ${ARG_SOURCE_DIR} ${ARG_BINARY_DIR} + --build-generator ${CMAKE_GENERATOR} + --build-makeprogram ${CMAKE_MAKE_PROGRAM} + --build-target ${ARG_BUILD} + --build-project ${ARG_PROJECT} + --build-config $ + --build-noclean + --test-command ${_command} ) + set_property(TEST ${test} PROPERTY ENVIRONMENT ROOT_DIR=${CMAKE_BINARY_DIR}) + else() + add_test(NAME ${test} COMMAND ${_command}) + endif() + + #- Handle TIMOUT and DEPENDS arguments + if(ARG_TIMEOUT) + set_property(TEST ${test} PROPERTY TIMEOUT ${ARG_TIMEOUT}) + endif() + + if(ARG_DEPENDS) + set_property(TEST ${test} PROPERTY DEPENDS ${ARG_DEPENDS}) + endif() + + if(ARG_PASSREGEX) + set_property(TEST ${test} PROPERTY PASS_REGULAR_EXPRESSION ${ARG_PASSREGEX}) + endif() + + if(ARG_FAILREGEX) + set_property(TEST ${test} PROPERTY FAIL_REGULAR_EXPRESSION ${ARG_FAILREGEX}) + endif() + + if(ARG_WILLFAIL) + set_property(TEST ${test} PROPERTY WILL_FAIL true) + endif() + + if(ARG_LABELS) + set_tests_properties(${test} PROPERTIES LABELS "${ARG_LABELS}") + endif() + +endfunction() + +#---------------------------------------------------------------------------- +# ROOT_ADD_TEST_SUBDIRECTORY( ) +#---------------------------------------------------------------------------- +function(ROOT_ADD_TEST_SUBDIRECTORY subdir) + file(RELATIVE_PATH subdir ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}) + set_property(GLOBAL APPEND PROPERTY ROOT_TEST_SUBDIRS ${subdir}) +endfunction() + +#---------------------------------------------------------------------------- +# ROOT_ADD_BUILTIN_DEPENDENCIES(target EXTERNAL) +#---------------------------------------------------------------------------- +macro(ROOT_ADD_BUILTIN_DEPENDENCIES target EXTERNAL) + add_custom_command(OUTPUT ${${EXTERNAL}_LIBRARIES} DEPENDS ${EXTERNAL}) + if(NOT TARGET ${EXTERNAL}LIBS) + add_custom_target(${EXTERNAL}LIBS DEPENDS ${${EXTERNAL}_LIBRARIES}) + endif() + add_dependencies(${target} ${EXTERNAL}LIBS) +endmacro() + +#---------------------------------------------------------------------------- +# ROOT_ADD_CXX_FLAG(var flag) +#---------------------------------------------------------------------------- +function(ROOT_ADD_CXX_FLAG var flag) + string(REGEX REPLACE "[-.+/:= ]" "_" flag_esc "${flag}") + CHECK_CXX_COMPILER_FLAG("${flag}" CXX_HAS${flag_esc}) + if(CXX_HAS${flag_esc}) + set(${var} "${${var}} ${flag}" PARENT_SCOPE) + endif() +endfunction() +#---------------------------------------------------------------------------- +# ROOT_ADD_C_FLAG(var flag) +#---------------------------------------------------------------------------- +function(ROOT_ADD_C_FLAG var flag) + string(REGEX REPLACE "[-.+/:= ]" "_" flag_esc "${flag}") + CHECK_C_COMPILER_FLAG("${flag}" C_HAS${flag_esc}) + if(C_HAS${flag_esc}) + set(${var} "${${var}} ${flag}" PARENT_SCOPE) + endif() +endfunction() + diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 614deaa576..0bb3133134 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -1,17 +1,27 @@ # @author Barthélémy von Haller include(FindDoxygen) -include(DoxygenTarget) - -# Add an option for the user to enable or not the documentation generation every time we compile. -# Either set it on the command line or use ccmake. It is an advanced option. -option(BUILD_DOCS "Build doxygen documentation when building all" OFF) -mark_as_advanced(BUILD_DOCS) if(NOT DOXYGEN_DOT_FOUND) - message(WARNING "Graphviz doesn't seem to be installed. Doxygen will not be able to generate graphs. Consider installing this package.") + message(WARNING "Graphviz doesn't seem to be installed. Doxygen will not be able to generate graphs. Consider installing this package.") endif(NOT DOXYGEN_DOT_FOUND) -if(DOXYGEN_FOUND) - PrepareDocTarget() -endif(DOXYGEN_FOUND) +if (DOXYGEN_FOUND) + # Configure the doxygen config file with current settings + set("DOC_OUTPUT_DIR" "${CMAKE_CURRENT_BINARY_DIR}") + configure_file(doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/documentation-config.doxygen @ONLY) + + # target doc + add_custom_target(doc + ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/documentation-config.doxygen + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Generating API documentation using doxygen for ${PROJECT_NAME} + \n Output will be available in ${DOC_OUTPUT_DIR}/html" VERBATIM) + + # installation + option(DOC_INSTALL "Install the documentation when calling \"make install\"" OFF) + if(DOC_INSTALL) + message(STATUS "Documentation will be installed but you *must* run `make doc`") + install(DIRECTORY ${DOC_OUTPUT_DIR}/html DESTINATION share/doc/${PROJECT_NAME} COMPONENT doc) + endif(DOC_INSTALL) +endif (DOXYGEN_FOUND) diff --git a/doc/documentation-config.doxygen.in b/doc/doxyfile.in similarity index 99% rename from doc/documentation-config.doxygen.in rename to doc/doxyfile.in index 831ef30de4..2619582476 100644 --- a/doc/documentation-config.doxygen.in +++ b/doc/doxyfile.in @@ -10,7 +10,7 @@ # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" ") -#--------------------------------------------------------------------------- +#-----------------------------------------------------input---------------------- # Project related configuration options #--------------------------------------------------------------------------- @@ -577,11 +577,7 @@ WARN_LOGFILE = INPUT = "@PROJECT_SOURCE_DIR@/include" \ "@PROJECT_BINARY_DIR@/include" \ "@PROJECT_SOURCE_DIR@/src" \ - "@PROJECT_SOURCE_DIR@/doc" \ - "@PROJECT_SOURCE_DIR@/../QualityControlModules/Example/include" \ - "@PROJECT_SOURCE_DIR@/../QualityControlModules/Example/src" \ - "@PROJECT_SOURCE_DIR@/../QualityControlModules/Common/include" \ - "@PROJECT_SOURCE_DIR@/../QualityControlModules/Common/src" + "@PROJECT_SOURCE_DIR@/doc" # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is diff --git a/doc/release-notes.dox b/doc/release-notes.dox deleted file mode 100644 index 225757adc2..0000000000 --- a/doc/release-notes.dox +++ /dev/null @@ -1,64 +0,0 @@ -/** -@page Release_Notes Release Notes - @section TABLE_OF_CONTENTS TABLE OF CONTENTS - -# @ref INTRODUCTION - -# @ref Features - -# @ref New_in_this_release - -# @ref New_Features - -# @ref Enhancements - -# @ref Optimizations - -# @ref Examples - -# @ref Tools - -# @ref API_Changes - -# @ref Documentation - -# @ref Bug_Fixes - -# @ref Known_Bugs - -# @ref Errata - - @htmlonly -
- @endhtmlonly - @section INTRODUCTION INTRODUCTION - @subsection Features Features - - The latest release of [PRODUCT_NAME] provides the following major features and improvements: - - Feature 1 - - Feature 2 - - @htmlonly -
- @endhtmlonly - @section New_in_this_release New in this release - - @subsection New_Features New Features - - Feature 1 Explained - - Feature 2 Explained - - @subsection Enhancements Enhancements - - Enhancements - - @subsection Optimizations Optimizations - - Optimizations - - @subsection Examples Examples - - Examples - - @subsection Tools Tools - - Tools - - @subsection API_Changes API Changes - - API Changes - - @subsection Documentation Documentation - - Documentation - - @subsection Bug_Fixes Bug Fixes - - Bug Fixes - - @subsection Known_Bugs Known Bugs - - Known Bugs - - @htmlonly -
- @endhtmlonly - @section Errata -*/ diff --git a/doc/technical-overview.dox b/doc/technical-overview.dox deleted file mode 100644 index 7054b66187..0000000000 --- a/doc/technical-overview.dox +++ /dev/null @@ -1,88 +0,0 @@ - -/** -@page Technical_Overview Technical Overview - @section TABLE_OF_CONTENTS TABLE OF CONTENTS - -# @ref INTRODUCTION - -# @ref Overview - -# @ref Version - -# @ref Status - -# @ref Requirements - -# @ref Dependencies - -# @ref Acronyms_and_Abbreviations - -# @ref DESIGN - -# @ref Design_Overview - -# @ref System_Architecture - -# @ref Alternative_Designs - -# @ref Interface_Description - -# @ref COMPONENTS - -# @ref Component1 - -# @ref Component2 - -# @ref ADDITIONAL_MATERIAL - -# @ref ISSUES - -# @ref Issue1 - -# @ref Issue2 - - @htmlonly -
- @endhtmlonly - @section INTRODUCTION INTRODUCTION - @subsection Overview Overview - - Brief overview of the [PRODUCT_NAME] - @subsection Version Version - - Version - @subsection Status Status - - Describe the current status, e.g.: Prototype, Under Development, etc… - - @subsection Requirements Requirements - - List any requirements here - - @subsection Dependencies Dependencies - - List any dependencies here - - @subsection Acronyms_and_Abbreviations Acronyms and Abbreviations - - Provide a list of the acronyms and abbreviations used in this document and the meaning of each. - - @htmlonly -
- @endhtmlonly - @section DESIGN SYSTEM ARCHITECTURAL DESIGN - @subsection Design_Overview Design Overview - - High-level design overview (process view) - @dot - digraph Process { - node [shape=box]; - Step1 -> Step2 -> Step3; - } - @enddot - @subsection System_Architecture System Architecture - - Detailed system architecture description - @subsection Alternative_Designs Discussion of Alternative Designs - - Alternative system architecture discussion - @subsection Interface_Description System Interface Description - - Interface description - - @htmlonly -
- @endhtmlonly - @section COMPONENTS DETAILED DESCRIPTION OF COMPONENTS - @subsection Component1 Component-n - @subsection Component2 Component-n+1 - - @htmlonly -
- @endhtmlonly - @section ADDITIONAL_MATERIAL ADDITIONAL MATERIAL - - @htmlonly -
- @endhtmlonly - @section ISSUES ISSUES - @subsection Issue1 Issue #1 - - Discussion - - Resolution - - @subsection Issue2 Issue #2 - - Discussion - - Resolution - -*/ diff --git a/doc/user-guide.dox b/doc/user-guide.dox deleted file mode 100644 index fe1ace14b9..0000000000 --- a/doc/user-guide.dox +++ /dev/null @@ -1,118 +0,0 @@ - -/** -@page User_Guide User Guide - - @section TABLE_OF_CONTENTS TABLE OF CONTENTS - -# @ref GENERAL_INFORMATION - -# @ref Overview - -# @ref Acronyms_and_Abbreviations - -# @ref SETUP_AND_DATA_FLOWS - -# @ref Setup - -# @ref Data_Flows - -# @ref INSTALLATION_AND_UPGRADE - -# @ref Requirements - -# @ref Supported_Platforms - -# @ref Installation - -# @ref Upgrading - -# @ref Important_Files - -# @ref Tips_And_Tricks - -# @ref GETTING_STARTED - -# @ref Starting - -# @ref Running - -# @ref Exiting - -# @ref Exceptions - - @htmlonly -
- @endhtmlonly - @section GENERAL_INFORMATION GENERAL INFORMATION - - @subsection Overview Overview - - - Explain in general terms the tool and the purpose for which it is intended. The description shall include: - - Architecture of the tool in non-technical terms, (e.g., library, client/server, web-based, etc.) - - Major functions performed by the tool - - Status (Operational, Under Development, Undergoing a major modification, etc...) - - @subsection Acronyms_and_Abbreviations Acronyms and Abbreviations - - - Provide a list of the acronyms and abbreviations used in this document and the meaning of each. - - @htmlonly -
- @endhtmlonly - @section SETUP_AND_DATA_FLOWS SETUP AND DATA FLOWS - - @subsection Setup Setup - - - Briefly describe and depict graphically the setup (computers, servers, databases, etc...) used by the tool. - - @subsection Data_Flows Data Flows - - - Briefly describe the overall flow of data in the system (data inputs and outputs). - - @dot - digraph Data { - node [shape=box]; - Input1 -> Process; - Input2 -> Process; - Process -> Output1; - Process -> Output2; - } - @enddot - - @htmlonly -
- @endhtmlonly - @section INSTALLATION_AND_UPGRADE INSTALLATION AND UPGRADE - - @subsection Requirements Requirements - - - List prerequisites (if any) here - - @subsection Supported_Platforms Supported Platforms - - - List supported platforms here - - @subsection Installation Installation - - - Linux - - Mac OS X - - Windows - - @subsection Upgrading Upgrading - - - Upgrading Manually - - Rolling Back an Upgrade - - @subsection Important_Files Important Directories and Files - - - List all important files and directories here - - @subsection Tips_And_Tricks Tips, Tricks, and Best Practices - - - Add tips and tricks here (if any)) - - @htmlonly -
- @endhtmlonly - @section GETTING_STARTED GETTING STARTED - - - This section should provide a general walkthrough from tool initiation through exit. The logical arrangement of the information should enable others to understand the sequence and flow of the system. - - @subsection Starting Starting - - - Describe the procedures necessary to access the tool. - - @subsection Running Running - - - Describe the procedures necessary to run the tool. - - @subsection Exiting Exiting - - - Describe the actions necessary to properly exit the tool. - - @subsection Exceptions Caveats and Exceptions - - - If there are special actions the user must take to insure that data is properly saved or that some other function executes properly, describe those actions here. -*/ diff --git a/doc/versioning.txt b/doc/versioning.txt deleted file mode 100644 index dbfeef8c3d..0000000000 --- a/doc/versioning.txt +++ /dev/null @@ -1,34 +0,0 @@ - -Versionining allows the identification and coexistence of different -iterations of a product on a single install location. It is particularly -important for packages containing header files or libraries to be used -by other packages. This template uses the following approach: - -* Major versions are not compatible with each other -* Minor versions are source compatible, but not binary compatible -* Patch versions are source and binary compatible - - -In consequence, this means for C++ libraries: - -* Any modification of the existing API requires a new major version -* Any addition to the existing API or any change on the member variables - of an installed header require at least a new minor version -* Patch releases have to implemented without touching header files, - with a few exceptions if you know what you are doing - -Libraries with a C API are source and binary compatible as long as the C -functions and structs are unchanged. - - -To ensure coexistence of different version on the same installation -root, the following layout is used: - -/bin/- -/include//*.h -/lib/lib.so. -/share/-/ - -Symlinks to the non-versioned name are created, that is, the last -installed version of a package will be the one found if unversioned -includes are used.