# ********************************* # ************ cmake ************** # ********************************* CMAKE_MINIMUM_REQUIRED(VERSION 3.0 FATAL_ERROR) CMAKE_POLICY(SET CMP0043 NEW) CMAKE_POLICY(SET CMP0048 NEW) IF(POLICY CMP0072) CMAKE_POLICY(SET CMP0072 NEW) # OpenGL vs OpenGLVND ENDIF() # 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=Debug) # 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) MESSAGE(STATUS "CMake Version " ${CMAKE_VERSION}) # ********************************* # ************ Project ************ # ********************************* STRING(TIMESTAMP VERSION %y.%U.%w.%H UTC) MESSAGE(STATUS "FACT++ V${VERSION}") PROJECT(fact++ 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.8) 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() # ===== Check for Anaconda ===== # Anacoda installation sometimes believe that they are the master of everything # and change the users environment such that the build system or the executable # loads, for example, anconda's libz rather than the system library. This might # work but usually creates serious troubles either during linking or during # execution. STRING(REPLACE ":" ";" PATHENV "$ENV{PATH}") FOREACH (DIR ${PATHENV}) IF(LDIR MATCHES .*anaconda.*) MESSAGE(WARNING "\n WARNING: Anaconda is altering your PATH environent: " ${DIR} "\n CMake, make or execution might fail, as non-system\n libraries might be mistaken for system libraries!\n Please make sure that there is no interference!") BREAK() ENDIF() ENDFOREACH() # ======== 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() # ********************************* # ******** FAMOUS / IceACT ******** # ********************************* #SET(OBSERVATORY "ORM" CACHE STRING "Select the observatory location (ORM, HAWC, SPM, RWTH: see nova.h)") IF (NOT TOOLS_ONLY AND NOT VIEWER_ONLY) IF(EXISTS "${CMAKE_SOURCE_DIR}/famous") MESSAGE(STATUS "Compilation of 'famous' enabled.") SET(FOUND_FAMOUS ON) ENDIF() IF(EXISTS "${CMAKE_SOURCE_DIR}/iceact") MESSAGE(STATUS "Compilation of 'iceact' enabled.") SET(FOUND_ICEACT ON) ENDIF() ENDIF(NOT TOOLS_ONLY AND NOT VIEWER_ONLY) # ********************************* # ********* Requirements ********** # ********************************* # =========== pkg-config ============ FIND_PACKAGE(PkgConfig) FIND_PACKAGE(PackageHandleStandardArgs) # ========== executables ========== FIND_PROGRAM(HELP2MAN_EXECUTABLE help2man) FIND_PROGRAM(ROFF2HTML_EXECUTABLE roff2html) FIND_PROGRAM(ROFF2PDF_EXECUTABLE roff2pdf) FIND_PROGRAM(GROFF_EXECUTABLE groff) FIND_PACKAGE_HANDLE_STANDARD_ARGS(help2man DEFAULT_MSG HELP2MAN_EXECUTABLE) FIND_PACKAGE_HANDLE_STANDARD_ARGS(roff2html DEFAULT_MSG ROFF2HTML_EXECUTABLE) FIND_PACKAGE_HANDLE_STANDARD_ARGS(roff2pdf DEFAULT_MSG ROFF2PDF_EXECUTABLE) FIND_PACKAGE_HANDLE_STANDARD_ARGS(groff DEFAULT_MSG GROFF_EXECUTABLE) IF (NOT HELP2MAN_EXECUTABLE OR NOT ROFF2HTML_EXECUTABLE OR NOT ROFF2PDF_EXECUTABLE OR NOT GROFF_EXECUTABLE) MESSAGE(STATUS "Documentation turned off (some executables missing).") ENDIF() IF (NOT TOOLS_ONLY AND NOT VIEWER_ONLY) FIND_PROGRAM(JSDOC_EXECUTABLE jsdoc) FIND_PROGRAM(MAILX_EXECUTABLE mailx) FIND_PROGRAM(CURL_EXECUTABLE curl) FIND_PACKAGE_HANDLE_STANDARD_ARGS(curl DEFAULT_MSG CURL_EXECUTABLE) FIND_PACKAGE_HANDLE_STANDARD_ARGS(mailx DEFAULT_MSG MAILX_EXECUTABLE) FIND_PACKAGE_HANDLE_STANDARD_ARGS(jsdoc DEFAULT_MSG JSDOC_EXECUTABLE) IF (curl_FOUND) ADD_DEFINITIONS(-DHAVE_CURL) ENDIF() IF (mailx_FOUND) ADD_DEFINITIONS(-DHAVE_MAILX) ENDIF() ENDIF (NOT TOOLS_ONLY AND NOT VIEWER_ONLY) #IF(NOT SOME_COND) # MESSAGE(FATAL_ERROR "At least one required executable was not found") #ENDIF() # =========== libraries ============= SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) # FIXME: Need to check which package finders accept REQUIERED. For all others implement checks FIND_PACKAGE(Threads REQUIRED) # Threads::Threads FIND_PACKAGE(ZLIB REQUIRED) # ZLIB::ZLIB SET(CURSES_NEED_NCURSES ON) FIND_PACKAGE(Curses REQUIRED) # CURSES_FOUND # Newer boost versions use timeout which is defined in ncurses.h # see for example: https://stackoverflow.com/questions/55265851/getting-errors-when-trying-to-compile-program-using-boost-and-ncurses-libraries ADD_DEFINITIONS(-DNCURSES_NOMACROS) # FIXME : Require panel IF(NOT TOOLS_ONLY OR VIEWER_ONLY) FIND_PACKAGE(OpenGL REQUIRED) # OpenGL::GL OpenGL::GLU / OPENGL_FOUND OPENGL_GLU_FOUND ENDIF(NOT TOOLS_ONLY OR VIEWER_ONLY) IF(NOT TOOLS_ONLY) # FIND_PACKAGE(DBus) => skaypeclient # FIND_PACKAGE(Motif) => did # MOTIF_FOUND FIND_PACKAGE(Readline REQUIRED) FIND_PACKAGE(Panel REQUIRED) FIND_PACKAGE(V8 REQUIRED) FIND_PACKAGE(CCfits REQUIRED) # First as Cfitsio is a dependency FIND_PACKAGE(Cfitsio REQUIRED) FIND_PACKAGE(OpenSSL REQUIRED) # Required for boost::asio::ssl ENDIF(NOT TOOLS_ONLY) FIND_PACKAGE(Nova REQUIRED) FIND_PACKAGE(Highlight) IF (HIGHLIGHT_FOUND) ADD_DEFINITIONS(-DHAVE_HIGHLIGHT) ENDIF() #INCLUDE_DIRECTORIES("/usr/include/mysql") # dbus-1 dbus-glib-1 # doxygen #MESSAGE("") #MESSAGE(${V8_LIBRARY}) #MESSAGE(${MYSQLPP_LIBRARY}) #MESSAGE(${PANEL_LIBRARY}) #MESSAGE(${CURSES_LIBRARIES}) #MESSAGE(${CCFITS_LIBRARY}) #MESSAGE(${CFITSIO_LIBRARY}) #MESSAGE(${MYSQL_LIBRARY}) #MESSAGE(${NOVA_LIBRARY}) #MESSAGE(${READLINE_LIBRARY}) #MESSAGE(${OPENSSL_SSL_LIBRARY}) #MESSAGE("") # =============== MySQL ============ INCLUDE(GetPrerequisites) # Deprecated since version 3.16: Use file(GET_RUNTIME_DEPENDENCIES) instead. FIND_PACKAGE(MySQL++ REQUIRED) IF(NOT DEFINED MYSQL_LIBRARY AND NOT CMAKE_VERSION VERSION_LESS 3.6) GET_PREREQUISITES(${MYSQLPP_LIBRARY} MYSQL_LIBRARY 0 0 "" "") LIST(FILTER MYSQL_LIBRARY INCLUDE REGEX .*mysqlclient.*) IF (MYSQL_LIB1RARY) FIND_PACKAGE_MESSAGE(MysqlLib "MySQL++ links to ${MYSQL_LIBRARY}" "[${MYSQL_LIBRARY}]") ELSE() UNSET(MYSQL_LIBRARY) ENDIF() ENDIF() FIND_PACKAGE(MySQL REQUIRED) INCLUDE_DIRECTORIES(${MYSQL_INCLUDE_DIR} ${MYSQLPP_INCLUDE_DIR}) # =============== BOOST ============ # 1.47.0 is the newest version available at ISDC FIND_PACKAGE(Boost 1.47.0 REQUIRED date_time filesystem program_options regex system thread) IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND Boost_VERSION LESS 106000 AND NOT NO_BOOST_HACK) MESSAGE(STATUS "Setting BOOST_REGEX_NO_EXTERNAL_TEMPLATES") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_REGEX_NO_EXTERNAL_TEMPLATES=1") ENDIF() # At least print some information for reference FIND_PACKAGE_HANDLE_STANDARD_ARGS(Boost FOUND_VAR Boost_FOUND REQUIRED_VARS Boost_INCLUDE_DIR Boost_LIBRARIES) # =============== Qt4/Qt5 ============== IF(NOT TOOLS_ONLY OR VIEWER_ONLY) IF (NOT FORCE_QT5) FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtOpenGL QtSql QtXml QUIET) ENDIF() IF(Qt4_FOUND) FIND_PACKAGE_MESSAGE(Qt4Found "Found Qt4 [Core Gui OpenGL Sql Xml]" "[${Qt4_FOUND}]") SET(Qt Qt4) SET(QtCore QtCore) SET(QtGui QtGui) SET(QtOpenGL QtOpenGL) SET(QtSql QtSql) SET(QtXml QtXml) ADD_DEFINITIONS(-DHAVE_QT4) ELSE() IF (NOT FORCE_QT5) FIND_PACKAGE_MESSAGE(Qt4NotFound "Qt4 [or one of: Core Gui OpenGL Sql Xml] NOT found, trying Qt5!" "[${Qt4_FOUND}]") ENDIF() FIND_PACKAGE(Qt5 QUIET) IF(DEFINED Qt5_DIR AND NOT Qt5_DIR) MESSAGE(WARNING " You need Qt5 but it seems that the development package\n with the cmake module file is missing.") ELSE() FIND_PACKAGE(Qt5 COMPONENTS Core Gui OpenGL Sql Xml REQUIRED) ENDIF() FIND_PACKAGE_MESSAGE(Qt5Found2 "Found Qt5: fact GUI will be disabled" "[${Qt5_FOUND}]") SET(Qt Qt5) SET(QtCore Core) SET(QtGui Gui) SET(QtOpenGL OpenGL) SET(QtSql Sql) SET(QtXml Xml) ENDIF() FIND_PACKAGE(Qwt REQUIRED) ENDIF(NOT TOOLS_ONLY OR VIEWER_ONLY) # ============== ROOT ================ IF(NOT NO_ROOT AND NOT VIEWER_ONLY) 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) # SET(ROOT_CONFIG_DEBUG 1) FIND_PACKAGE(ROOT REQUIRED COMPONENTS TreePlayer OPTIONAL_COMPONENTS GQt) IF(NOT DEFINED ROOT_CONFIG_EXECUTABLE) FIND_PACKAGE_MESSAGE(RootFound "Found ROOT: ${ROOT_INCLUDE_DIRS}" "[${ROOT_INCLUDE_DIRS}][${ROOT_LIBRARY_DIR}][${ROOT_VERSION}]") ENDIF() IF (NOT TOOLS_ONLY AND NOT VIEWER_ONLY AND NOT ROOT_GQt_LIBRARY) IF(ROOT_VERSION VERSION_LESS 6.18) MESSAGE(FATAL_ERROR "Root version [${ROOT_VERSION}] less than 6.18, but component GQt not found.") ELSE() MESSAGE(WARNING "Root version [${ROOT_VERSION}] does not support GQt, GUI [fact] turned off.") ENDIF() 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() # 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) 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_TARGET(thisroot ALL DEPENDS thisroot.sh) 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") ADD_DEFINITIONS(-DHAVE_ROOT) ENDIF(NOT NO_ROOT AND NOT VIEWER_ONLY) # Note that in root 5.34/38 (and maybe others?) the ROOT_xxx_FOUND macros are broken IF (NOT ROOT_GQt_FOUND) FIND_LIBRARY(ROOT_GQt_LIBRARY NAMES GQt PATHS ${ROOT_LIBRARY_DIR}) IF (ROOT_GQt_LIBRARY) FIND_PACKAGE_MESSAGE(RootQGtLib "Found libGQt: ${ROOT_GQt_LIBRARY}" "[${ROOT_GQt_LIBRARY}]") SET(ROOT_GQt_FOUND 1) ELSE() FIND_PACKAGE_MESSAGE(RootQGt "ROOT: libGQt not found, fact GUI disabled!" "[${ROOT_GQt_FOUND}]") ENDIF() 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_