# ********************************* # ************ cmake ************** # ********************************* CMAKE_MINIMUM_REQUIRED(VERSION 2.6) CMAKE_POLICY(SET CMP0043 NEW) CMAKE_POLICY(SET CMP0048 NEW) # 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 "Mars V${VERSION}") PROJECT(mars VERSION ${VERSION}) INCLUDE(GNUInstallDirs) # ======== 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) # ============== 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") #---Locate the ROOT package and defines a number of variables (e.g. ROOT_INCLUDE_DIRS) FIND_PACKAGE(ROOT REQUIRED COMPONENTS Gui Minuit ASImage HistPainter) IF(NOT DEFINED ROOT_CONFIG_EXECUTABLE) FIND_PACKAGE_MESSAGE(RootFound "Found ROOT: ${ROOT_INCLUDE_DIRS} [${ROOT_VERSION}]" "[${ROOT_INCLUDE_DIRS}][${ROOT_LIBRARY_DIR}][${ROOT_VERSION}]") ENDIF() #---Define useful ROOT functions and macros (e.g. ROOT_GENERATE_DICTIONARY) IF(DEFINED ROOT_USE_FILE) FIND_PACKAGE_MESSAGE(RootInclude "Setup ROOT: ${ROOT_USE_FILE}" "[${ROOT_USE_FILE}]") INCLUDE(${ROOT_USE_FILE}) ELSE() FIND_PACKAGE_MESSAGE(RootInclude "Setup ROOT: ${ROOT_VERSION}" "[${ROOT_VERSION}]") # 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() # -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_