123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- # CMakeLists.txt for FAS package. It creates a library with dictionary and a main program
- cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
- project(MpdFlow)
- #---Add PicoDst submodule with PicoDst shared library
- add_subdirectory(PicoDst)
- # 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
- find_package(Git)
- list(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS})
- #---Locate the ROOT package and defines a number of variables (e.g. ROOT_INCLUDE_DIRS)
- find_package(ROOT REQUIRED COMPONENTS MathCore RIO Hist Tree Net MathMore EG)
- #---Define useful ROOT functions and macros (e.g. ROOT_GENERATE_DICTIONARY)
- include(${ROOT_USE_FILE})
- #---Add PicoDst library. Make sure setPicoDst.sh is executed
- # find_library(PicoDst NAMES PicoDst PATHS $ENV{PICO_DST_BIN})
- # if (PicoDst)
- # message(STATUS "PicoDst is found: ${PicoDst}")
- # endif()
- # if (NOT PicoDst)
- # message(FATAL_ERROR "PicoDst is NOT found! Make sure you have sourced setPicoDst.sh")
- # endif()
- set (CMAKE_CXX_STANDARD 11)
- add_definitions(${ROOT_CXX_FLAGS})
- set(CMAKE_BUILD_TYPE Debug)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wall -g")
- set(MPD_FLOW_INCLUDE_DIRECTORIES
- ${CMAKE_CURRENT_SOURCE_DIR}
- "${CMAKE_CURRENT_SOURCE_DIR}/utils"
- "${CMAKE_CURRENT_SOURCE_DIR}/qvector"
- "${CMAKE_CURRENT_SOURCE_DIR}/selector"
- "${CMAKE_CURRENT_SOURCE_DIR}/corrections"
- "${CMAKE_CURRENT_SOURCE_DIR}/inputreader"
- "${CMAKE_CURRENT_SOURCE_DIR}/eventanalysis"
- "${CMAKE_CURRENT_SOURCE_DIR}/bin"
- ${ROOT_INCLUDE_DIRS}
- $ENV{PICO_DST_INC}
- )
- include_directories(${MPD_FLOW_INCLUDE_DIRECTORIES})
- set(MPD_FLOW_INCLUDE_LIBRARIES
- PicoDst
- ${ROOT_LIBRARIES}
- )
- set(MpdFlow_LinkDef "${CMAKE_CURRENT_SOURCE_DIR}/MpdFlow.LinkDef.h")
- file(GLOB MpdFlow_h_files
- "*/*.h"
- )
- list (REMOVE_ITEM MpdFlow_h_files ${MpdFlow_LinkDef})
- file(GLOB MpdFlow_cxx_files
- "*/*.cxx"
- )
- #---Generate dictionary
- ROOT_GENERATE_DICTIONARY(G__MpdFlow
- ${MpdFlow_h_files}
- LINKDEF ${MpdFlow_LinkDef}
- )
- #---Compile library
- add_library(MpdFlow SHARED ${MpdFlow_cxx_files} G__MpdFlow.cxx)
- target_link_libraries(MpdFlow ${MPD_FLOW_INCLUDE_LIBRARIES})
- #---Get the current working branch
- execute_process(
- COMMAND git rev-parse --abbrev-ref HEAD
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- OUTPUT_VARIABLE GIT_BRANCH
- RESULT_VARIABLE GIT_BRANCH_ERROR_CODE
- OUTPUT_STRIP_TRAILING_WHITESPACE
- )
- if( GIT_BRANCH_ERROR_CODE )
- set(GIT_BRANCH 0)
- endif()
- #---Get the latest abbreviated commit hash of the working branch
- execute_process(
- COMMAND git rev-parse --short HEAD
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- OUTPUT_VARIABLE GIT_COMMIT_HASH
- RESULT_VARIABLE GIT_COMMIT_HASH_ERROR_CODE
- OUTPUT_STRIP_TRAILING_WHITESPACE
- )
- if( GIT_COMMIT_HASH_ERROR_CODE )
- set(GIT_COMMIT_HASH 0)
- endif()
- #---Get the current version
- execute_process(
- COMMAND git describe --tags --match "*"
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- OUTPUT_VARIABLE GIT_TAG_VERSION
- RESULT_VARIABLE GIT_TAG_VERSION_ERROR_CODE
- OUTPUT_STRIP_TRAILING_WHITESPACE
- )
- if( GIT_TAG_VERSION_ERROR_CODE )
- set(GIT_TAG_VERSION 0)
- endif()
- #---Set libMpdFlow.so properties
- set_target_properties(MpdFlow PROPERTIES
- VERSION ${GIT_TAG_VERSION} SOVERSION ${GIT_BRANCH}-${GIT_COMMIT_HASH}
- )
- #---Compile executables
- add_subdirectory(bin)
|