# ********************************* # ************ cmake ************** # ********************************* CMAKE_MINIMUM_REQUIRED(VERSION 3.1 FATAL_ERROR) CMAKE_POLICY(SET CMP0043 NEW) CMAKE_POLICY(SET CMP0048 NEW) # TARGET_SOURCES requires v3.1 # Enable debug symbols by default # must be done before project() statement SET(CMAKE_BUILD_TYPE_INIT Release) # (you can also set it on the command line: -D CMAKE_BUILD_TYPE=Release) # Enable CLANG as default compilers, to change this use # cmake -DCMAKE_C_COMPILER=cc -DCMAKE_CXX_COMPILER=c++ # Note that if compilers are switched on the fly, # the cache is deleted IF(NOT DEFINED CMAKE_C_COMPILER) FIND_PROGRAM(CMAKE_C_COMPILER NAMES $ENV{CC} clang gcc cc PATHS ENV PATH NO_DEFAULT_PATH DOC "C Compiler") ENDIF() IF(NOT DEFINED CMAKE_CXX_COMPILER) FIND_PROGRAM(CMAKE_CXX_COMPILER NAMES $ENV{CXX} clang++ g++ c++ PATHS ENV PATH NO_DEFAULT_PATH DOC "C++ Compiler") ENDIF() #SET(CMAKE_VERBOSE_MAKEFILE ON) # To check for an include file you do this: #CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H) # To check the size of a primitive type: #CHECK_TYPE_SIZE("int" SIZEOF_INT) # ********************************* # ************ Project ************ # ********************************* STRING(TIMESTAMP VERSION %y.%U.%w.%H UTC) MESSAGE(STATUS "Cmake V${CMAKE_VERSION}") MESSAGE(STATUS "Mars V${VERSION}") PROJECT(mars VERSION ${VERSION}) INCLUDE(GNUInstallDirs) IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") SET(GCC_MIN 4.4.7) IF (CMAKE_C_COMPILER_VERSION VERSION_LESS GCC_MIN OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS GCC_MIN) MESSAGE(FATAL_ERROR "\n gcc/g++ ${GCC_MIN} or higher is required.\n You are running version ${CMAKE_C_COMPILER_VERSION}/${CMAKE_CXX_COMPILER_VERSION}.") ENDIF() ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") SET(CLANG_MIN 3.5) IF (CMAKE_C_COMPILER_VERSION VERSION_LESS CLANG_MIN OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS CLANG_MIN) MESSAGE(FATAL_ERROR "\n clang/clang++ ${CLANG_MIN} or higher is required.\n You are running version ${CMAKE_C_COMPILER_VERSION}/${CMAKE_CXX_COMPILER_VERSION}.") ENDIF() ELSE() MESSAGE(WARNING "You are using an unsupported compiler! Compilation has only been tested only with clang/clang++ and gcc/g++.") ENDIF() # ======== For config.h.in ========= SET(PACKAGE_MAINTAINER "Thomas Bretz") SET(PACKAGE_BUGREPORT "tbretz@physik.rwth-aachen.de") SET(PACKAGE_URL "https://www.fact-project.org") FIND_PROGRAM(LSB_RELEASE_EXE NAMES lsb_release) IF (DEFINED LSB_RELEASE_EXE) EXECUTE_PROCESS(COMMAND ${LSB_RELEASE_EXE} -d OUTPUT_VARIABLE LSB_RELEASE OUTPUT_STRIP_TRAILING_WHITESPACE) MESSAGE(STATUS ${LSB_RELEASE}) ENDIF() # ********************************* # ********* Requirements ********** # ********************************* # Inlclude the main source AND build dir itself #SET(CMAKE_INCLUDE_CURRENT_DIR ON) SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) # =========== help2man ============ FIND_PROGRAM(HELP2MAN_EXECUTABLE help2man) # =========== pkg-config ============ FIND_PACKAGE(PkgConfig) FIND_PACKAGE(PackageHandleStandardArgs) # ============= libnova ============== PKG_CHECK_MODULES(Nova QUIET Nova) # Try to locate the package in the default path # and in the path provided by pkg-config FIND_PATH(NOVA_INCLUDE_DIR NAMES libnova/libnova.h PATHS ${NOVA_INCLUDE_DIRS}) FIND_LIBRARY(NOVA_LIBRARY NAMES nova PATHS ${NOVA_LIBRARY_DIRS}) # Check if NOVA_LIBARARY and NOVA_INCLUDE_DIR is set # Print a message otherwise FIND_PACKAGE_HANDLE_STANDARD_ARGS(Nova DEFAULT_MSG NOVA_LIBRARY NOVA_INCLUDE_DIR) # Mark those variables to be displayed as 'advanced' in the GUI MARK_AS_ADVANCED(NOVA_LIBRARY NOVA_INCLUDE_DIR) # handle success FIND_PACKAGE_MESSAGE(NovaInc "Found Nova headers in ${NOVA_INCLUDE_DIR}" "[${NOVA_LIBRARY}][${NOVA_INCLUDE_DIR}]") # ============== libz ================ FIND_PACKAGE(ZLIB REQUIRED) # ********************************* # ********** HEAL Pix ********** # ********************************* SET(HEALPIX_PREFIX "${CMAKE_SOURCE_DIR}/RootHealPix" CACHE FILEPATH "Base path to the RootHealPix code.") IF(EXISTS ${HEALPIX_PREFIX}) FIND_PACKAGE_MESSAGE(HealPixPrefix "RootHealPix prefix: ${HEALPIX_PREFIX}" "[${HEALPIX_PREFIX}]") SET(FOUND_HEALPIX ON) ENDIF() # ============== ROOT ================ FIND_PROGRAM(ROOTCONFIG_EXECUTABLE NAMES root-config) FIND_PACKAGE_HANDLE_STANDARD_ARGS(root-config DEFAULT_MSG ROOTCONFIG_EXECUTABLE) IF(NOT ROOTCONFIG_EXECUTABLE) MESSAGE(FATAL_ERROR "Please make sure `root-config` is accessible in your path. In case of an installation from source, you might need to source\n . [path-to-root]/bin/thisroot.sh") ENDIF() # You need to tell CMake where to find the ROOT installation. This can be done in a number of ways: # - ROOT built with classic configure/make use the provided $ROOTSYS/etc/cmake/FindROOT.cmake # - ROOT built with CMake. Add in CMAKE_PREFIX_PATH the installation prefix for ROOT IF(EXISTS $ENV{ROOTSYS}/ROOTConfig.cmake) IF(NOT DEFINED ENV{CMAKE_PREFIX_PATH}) LIST(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS}) ENDIF() ENDIF() SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "$ENV{ROOTSYS}/etc/cmake") SET(ROOT_PACKAGES Gui Minuit ASImage HistPainter) IF(FOUND_HEALPIX) SET(ROOT_PACKAGES ${ROOT_PACKAGES} FITSIO) ENDIF() #---Locate the ROOT package and defines a number of variables (e.g. ROOT_INCLUDE_DIRS) #SET(ROOT_CONFIG_DEBUG 1) FIND_PACKAGE(ROOT REQUIRED COMPONENTS ${ROOT_PACKAGES}) IF(NOT DEFINED ROOT_CONFIG_EXECUTABLE) FIND_PACKAGE_MESSAGE(RootFound "Found ROOT: ${ROOT_INCLUDE_DIRS}" "[${ROOT_INCLUDE_DIRS}][${ROOT_LIBRARY_DIR}][${ROOT_VERSION}]") ENDIF() #---Define useful ROOT functions and macros (e.g. ROOT_GENERATE_DICTIONARY) FIND_PACKAGE_MESSAGE(RootInclude "Setup ROOT: [${ROOT_VERSION}] ${ROOT_USE_FILE}" "[${ROOT_VERSION}][${ROOT_USE_FILE}]") IF(DEFINED ROOT_USE_FILE) INCLUDE(${ROOT_USE_FILE}) ELSE() # From RootUseFile.cmake (root 6) INCLUDE_DIRECTORIES(${ROOT_INCLUDE_DIRS}) LINK_DIRECTORIES(${ROOT_LIBRARY_DIR}) ADD_DEFINITIONS(${ROOT_DEFINITIONS}) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ROOT_CXX_FLAGS}") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ROOT_C_FLAGS}") SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${ROOT_fortran_FLAGS}") ENDIF() # Replace separators to make the version consistent # (older version might use the '/') STRING(REPLACE "/" "." ROOT_VERSION ${ROOT_VERSION}) # This happens when root is used from its build directory # Create the version components manually IF(ROOT_VERSION AND NOT ROOT_VERSION_MAJOR) # Create a list of components STRING(REPLACE "." ";" ROOT_VERSION_LIST ${ROOT_VERSION}) # Split version string LIST(GET ROOT_VERSION_LIST 0 ROOT_VERSION_MAJOR) LIST(GET ROOT_VERSION_LIST 1 ROOT_VERSION_MINOR) LIST(GET ROOT_VERSION_LIST 2 ROOT_VERSION_PATCH) # Remove trailing 0's STRING(REGEX REPLACE "0+([0-9]+)" "\\1" ROOT_VERSION_MINOR ${ROOT_VERSION_MINOR}) STRING(REGEX REPLACE "0+([0-9]+)" "\\1" ROOT_VERSION_PATCH ${ROOT_VERSION_PATCH}) ENDIF() # Is this is a local or a global installation? IF(DEFINED ENV{ROOTSYS}) IF(ROOTSYS AND NOT ROOTSYS STREQUAL "$ENV{ROOTSYS}") MESSAGE(WARNING " \n" " ROOT Location changed!\n" " Present ROOTSYS: $ENV{ROOTSYS}\n" " Previous ROOTSYS: ${ROOTSYS}") FILE(REMOVE thisroot.sh) FILE(REMOVE root) ENDIF() SET(ROOTSYS $ENV{ROOTSYS} CACHE INTERNAL "Internal variable to check for consistency in ROOTSYS") # For convenience and easy tracking ADD_CUSTOM_COMMAND(OUTPUT thisroot.sh COMMAND ln -sf ${ROOTSYS}/bin/thisroot.sh VERBATIM) ADD_CUSTOM_COMMAND(OUTPUT root COMMAND ln -sf ${ROOTSYS}/bin/root VERBATIM) ADD_CUSTOM_TARGET(thisroot ALL DEPENDS thisroot.sh) ADD_CUSTOM_TARGET(lnroot ALL DEPENDS root) ENDIF() IF(ROOTVER AND NOT ROOTVER VERSION_EQUAL ROOT_VERSION) MESSAGE(WARNING " \n" " ROOT Version changed!\n" " Present: ${ROOT_VERSION}\n" " Previous: ${ROOTVER}") ENDIF() SET(ROOTVER ${ROOT_VERSION} CACHE INTERNAL "Internal variable to check for consistency of root version") IF(ROOT_VERSION VERSION_LESS 6.20) SET(ROOT_DICTIONARY_OPTION -p) ENDIF() # -lGui -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree # -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread # -lASImage -lMinuit -lHistPainter -lThread #MESSAGE("INCL_DIRS: ${ROOT_INCLUDE_DIRS}") #MESSAGE("LIBS: ${ROOT_LIBRARIES}") #MESSAGE("DEFS: ${ROOT_DEFINITIONS}") #MESSAGE("CXXFLAGS: ${ROOT_CXX_FLAGS}") #MESSAGE("CXFLAGS: ${ROOT_CC_FLAGS}") #MESSAGE("FOUND: ${ROOT_FOUND}") #MESSAGE("FILE: ${ROOT_USE_FILE}") #MESSAGE("DIR: ${CMAKE_CURRENT_SOURCE_DIR}") #ROOT__LIBRARY PATH Full path for each of the ROOT libraries listed in COMPONENTS #ROOT__CMD PATH Full path for each ROOT executable (rootcling, root, hadd, etc.) #ROOT_