|
@@ -0,0 +1,161 @@
|
|
|
|
+# CMakeLists.txt for FAS package. It creates a library with dictionary and a main program
|
|
|
|
+cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
|
|
|
|
+project(ModelConverter)
|
|
|
|
+
|
|
|
|
+# 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 EG)
|
|
|
|
+
|
|
|
|
+#---Define useful ROOT functions and macros (e.g. ROOT_GENERATE_DICTIONARY)
|
|
|
|
+include(${ROOT_USE_FILE})
|
|
|
|
+
|
|
|
|
+add_definitions(${ROOT_CXX_FLAGS})
|
|
|
|
+
|
|
|
|
+#---Locate MCINI package
|
|
|
|
+find_library(MCINI NAMES McIniData PATHS $ENV{MCINI}/build)
|
|
|
|
+IF(MCINI)
|
|
|
|
+ message(STATUS "mcini is found: ${MCINI}")
|
|
|
|
+ add_definitions("-D_MCINI_")
|
|
|
|
+endif()
|
|
|
|
+IF(NOT MCINI)
|
|
|
|
+ message(STATUS "mcini is not found. Building without it.")
|
|
|
|
+endif()
|
|
|
|
+
|
|
|
|
+#---Locate PHQMDEvent library
|
|
|
|
+find_library(PHQMD NAMES PHQMDEvent PATHS $ENV{PHQMD_PATH}/phqmd2root/lib/)
|
|
|
|
+if(PHQMD)
|
|
|
|
+ message(STATUS "libPHQMDEvent is found: ${PHQMD}")
|
|
|
|
+ add_definitions("-D_PHQMD_")
|
|
|
|
+ add_definitions("-D_HSD_ROOT_")
|
|
|
|
+endif()
|
|
|
|
+if(NOT PHQMD)
|
|
|
|
+ message(STATUS "libPHQMDEvent is not found. Building without it.")
|
|
|
|
+endif()
|
|
|
|
+
|
|
|
|
+set(CMAKE_BUILD_TYPE Debug)
|
|
|
|
+#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -Wall -pthread")
|
|
|
|
+# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall -ffast-math")
|
|
|
|
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall")
|
|
|
|
+
|
|
|
|
+set(MCONVERTER_INCLUDE_DIRECTORIES
|
|
|
|
+ ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
+ ${CMAKE_CURRENT_SOURCE_DIR}/bin
|
|
|
|
+ ${CMAKE_CURRENT_SOURCE_DIR}/format
|
|
|
|
+ ${CMAKE_CURRENT_SOURCE_DIR}/readers
|
|
|
|
+ ${CMAKE_CURRENT_SOURCE_DIR}/writers
|
|
|
|
+ ${CMAKE_CURRENT_SOURCE_DIR}/utility
|
|
|
|
+ ${ROOT_INLCUDE_DIRS}
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+set(MCONVERTER_INCLUDE_LIBRARIES
|
|
|
|
+ ${ROOT_LIBRARIES}
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+set(MCONVERTER_LIBRARY_h_files
|
|
|
|
+ ${CMAKE_CURRENT_SOURCE_DIR}/format/mciParticle.h
|
|
|
|
+ ${CMAKE_CURRENT_SOURCE_DIR}/format/mciEvent.h
|
|
|
|
+ ${CMAKE_CURRENT_SOURCE_DIR}/readers/mciReader_smash_root.h
|
|
|
|
+ ${CMAKE_CURRENT_SOURCE_DIR}/readers/mciReader_mcpico.h
|
|
|
|
+ ${CMAKE_CURRENT_SOURCE_DIR}/readers/mciReader_manager.h
|
|
|
|
+ ${CMAKE_CURRENT_SOURCE_DIR}/writers/mciWriter_mcpico.h
|
|
|
|
+ ${CMAKE_CURRENT_SOURCE_DIR}/writers/mciWriter_manager.h
|
|
|
|
+ ${CMAKE_CURRENT_SOURCE_DIR}/utility/Utility.h
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+set(MCONVERTER_LIBRARY_cxx_files
|
|
|
|
+ ${CMAKE_CURRENT_SOURCE_DIR}/format/mciParticle.cxx
|
|
|
|
+ ${CMAKE_CURRENT_SOURCE_DIR}/format/mciEvent.cxx
|
|
|
|
+ ${CMAKE_CURRENT_SOURCE_DIR}/readers/mciReader_smash_root.cxx
|
|
|
|
+ ${CMAKE_CURRENT_SOURCE_DIR}/readers/mciReader_mcpico.cxx
|
|
|
|
+ ${CMAKE_CURRENT_SOURCE_DIR}/readers/mciReader_manager.cxx
|
|
|
|
+ ${CMAKE_CURRENT_SOURCE_DIR}/writers/mciWriter_mcpico.cxx
|
|
|
|
+ ${CMAKE_CURRENT_SOURCE_DIR}/writers/mciWriter_manager.cxx
|
|
|
|
+ ${CMAKE_CURRENT_SOURCE_DIR}/utility/Utility.cxx
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+if(MCINI)
|
|
|
|
+ list(APPEND MCONVERTER_INCLUDE_DIRECTORIES $ENV{MCINI}/include)
|
|
|
|
+ list(APPEND MCONVERTER_INCLUDE_LIBRARIES ${MCINI})
|
|
|
|
+ list(APPEND MCONVERTER_LIBRARY_h_files ${CMAKE_CURRENT_SOURCE_DIR}/readers/mciReader_mcini.h)
|
|
|
|
+ list(APPEND MCONVERTER_LIBRARY_cxx_files ${CMAKE_CURRENT_SOURCE_DIR}/readers/mciReader_mcini.cxx)
|
|
|
|
+endif()
|
|
|
|
+
|
|
|
|
+if(PHQMD)
|
|
|
|
+ list(APPEND MCONVERTER_INCLUDE_DIRECTORIES $ENV{PHQMD_PATH})
|
|
|
|
+ list(APPEND MCONVERTER_INCLUDE_LIBRARIES ${PHQMD})
|
|
|
|
+ list(APPEND MCONVERTER_LIBRARY_h_files ${CMAKE_CURRENT_SOURCE_DIR}/readers/mciReader_phqmd.h)
|
|
|
|
+ list(APPEND MCONVERTER_LIBRARY_cxx_files ${CMAKE_CURRENT_SOURCE_DIR}/readers/mciReader_phqmd.cxx)
|
|
|
|
+ list(APPEND MCONVERTER_LIBRARY_h_files ${CMAKE_CURRENT_SOURCE_DIR}/readers/mciReader_hsd_root.h)
|
|
|
|
+ list(APPEND MCONVERTER_LIBRARY_cxx_files ${CMAKE_CURRENT_SOURCE_DIR}/readers/mciReader_hsd_root.cxx)
|
|
|
|
+endif()
|
|
|
|
+
|
|
|
|
+include_directories(${MCONVERTER_INCLUDE_DIRECTORIES})
|
|
|
|
+
|
|
|
|
+set(MCONVERTER_LinkDef
|
|
|
|
+ ${CMAKE_CURRENT_SOURCE_DIR}/mConverter.LinkDef.h
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+#---Generate dictionary
|
|
|
|
+ROOT_GENERATE_DICTIONARY(G__mConverter
|
|
|
|
+ ${MCONVERTER_LIBRARY_h_files}
|
|
|
|
+ LINKDEF ${MCONVERTER_LinkDef}
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+#---Compile library
|
|
|
|
+add_library(mConverter SHARED ${MCONVERTER_LIBRARY_cxx_files} G__mConverter.cxx)
|
|
|
|
+target_link_libraries(mConverter ${MCONVERTER_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.0)
|
|
|
|
+endif()
|
|
|
|
+
|
|
|
|
+set_target_properties (mConverter
|
|
|
|
+ PROPERTIES
|
|
|
|
+ VERSION ${GIT_TAG_VERSION} SOVERSION ${GIT_BRANCH}-${GIT_COMMIT_HASH}
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+#---Compile main executable
|
|
|
|
+add_executable(ModelConverter "${CMAKE_CURRENT_SOURCE_DIR}/bin/main.cpp")
|
|
|
|
+target_link_libraries(ModelConverter mConverter)
|