IAP GITLAB

CMakeLists.txt 5.45 KB
Newer Older
1 2 3
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
PROJECT (crmc)

4 5
######################################ONLY EDIT THIS######################################
SET (CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR})
6

7
# Enable/Disable models to be built
8
OPTION (__QGSJET01__ "Build with model" ON)
9 10 11
OPTION (__GHEISHA__  "Build with model" OFF)
OPTION (__PYTHIA__   "Build with model" OFF)
OPTION (__HIJING__   "Build with model" OFF)
Colin Baus's avatar
Colin Baus committed
12
OPTION (__SIBYLL__   "Build with model" OFF)
13
OPTION (__PHOJET__   "Build with model" OFF)
14
OPTION (__PYTHIA__   "Build with model" OFF)
15
OPTION (__QGSJETII__ "Build with model" OFF)
Colin Baus's avatar
Colin Baus committed
16
OPTION (__QGSJETII04__ "Build with model" OFF)
17
# TODO want to disable epos, too <-- from TP : not completely possible without rewritting a lot (it is done in CONEX)
18
# TODO better support for model versions
19 20 21 22
######################################ONLY EDIT THIS######################################

# The version number
SET (CRMC_VERSION_MAJOR 0)
Colin Baus's avatar
Colin Baus committed
23
SET (CRMC_VERSION_MINOR 5)
24 25

# hotfix for lxbatch not sure why he selects wrong compiler
Colin Baus's avatar
Colin Baus committed
26
SET (CMAKE_Fortran_COMPILER gfortran)
27 28 29 30 31 32 33 34 35 36

# comprehensible compiler languages (default c cxx)
ENABLE_LANGUAGE (Fortran)

## RPATH (where to find library)
# use, i.e. don't skip the full RPATH for the build tree
SET(CMAKE_SKIP_BUILD_RPATH  FALSE)

# when building, don't use the install RPATH already
# (but later on when installing)
Colin Baus's avatar
Colin Baus committed
37
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
38 39 40 41 42 43 44 45 46 47 48

SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

# the RPATH to be used when installing, but only if it's not a system directory
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
IF("${isSystemDir}" STREQUAL "-1")
  SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
ENDIF("${isSystemDir}" STREQUAL "-1")
49 50 51

## find packages
SET (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules" CACHE PATH "Module Path" FORCE)
52
# TODO ROOT NOT REQUIRED
53
FIND_PACKAGE (Root REQUIRED)
54
# SET(Boost_DEBUG TRUE)
55
FIND_PACKAGE (Boost 1.35 REQUIRED COMPONENTS filesystem iostreams system program_options)
56
# TODO HepMC NOT REQUIRED
57 58 59 60
FIND_PACKAGE (HepMC REQUIRED COMPONENTS HepMC HepMCfio)

## configure a header file to pass some of the CMake settings to the source code
CONFIGURE_FILE (
Ralf Ulrich's avatar
Ralf Ulrich committed
61 62
  "${PROJECT_SOURCE_DIR}/src/CRMCconfig.h.in"
  "${PROJECT_BINARY_DIR}/src/CRMCconfig.h"
63 64 65 66 67
  )

#add epos (must!)
INCLUDE_DIRECTORIES ("${PROJECT_SOURCE_DIR}/src")
ADD_SUBDIRECTORY (src/epos)
68
SET (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -D __EPOS__")
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89

IF (__QGSJET01__)
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/src/qgsjet")
ENDIF (__QGSJET01__)

IF (__GHEISHA__)
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/src/gheisha")
ENDIF (__GHEISHA__)

IF (__PYTHIA__)
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/src/pythia")
ENDIF (__PYTHIA__)

IF (__HIJING__)
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/src/hijing")
ENDIF (__HIJING__)

IF (__SIBYLL__)
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/src/sibyll")
ENDIF (__SIBYLL__)

Colin Baus's avatar
Colin Baus committed
90 91 92 93
IF (__PHOJET__)
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/src/phojet")
ENDIF (__PHOJET__)

94 95
#put definition outside "if" because it is always is crmc.param file
SET (QGSJETII_TABS "03")
96 97 98 99
IF (__QGSJETII__)
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/src/qgsjetII")
ENDIF (__QGSJETII__)

100 101 102 103 104
IF (__QGSJETII04__)
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/src/qgsjetII-04")
SET (QGSJETII_TABS "04")
ENDIF (__QGSJETII04__)

Colin Baus's avatar
Colin Baus committed
105 106 107 108 109 110 111 112 113 114 115
#Dummy library which includes epos.inc file so HEPMC will find the symbol for hepevt_
#with fPIC linker option it should always point to right symbol also for other libs
add_library(HepEvtDummy SHARED src/dummy.f)
INSTALL (TARGETS HepEvtDummy
        RUNTIME DESTINATION bin
        LIBRARY DESTINATION lib
        ARCHIVE DESTINATION lib/static
        )

#include directories for headers
INCLUDE_DIRECTORIES ("${PROJECT_BINARY_DIR}/src")
116 117 118
INCLUDE_DIRECTORIES ("${HepMC_INCLUDE_DIRS}")
INCLUDE_DIRECTORIES ("${Boost_INCLUDE_DIRS}")
INCLUDE_DIRECTORIES ("${ROOT_INCLUDE_DIR}")
Colin Baus's avatar
Colin Baus committed
119 120
# the executable
ADD_EXECUTABLE(crmc src/crmc.cc src/CRMC.cc src/CRMCinterface.cc src/CRMCoptions.cc src/OutputPolicyROOT.cc src/OutputPolicyHepMC.cc src/OutputPolicyLHE.cc src/CRMCtrapfpe.c)
121

122
# linking of modules
123 124 125
TARGET_LINK_LIBRARIES (crmc ${HepMC_LIBRARIES})
TARGET_LINK_LIBRARIES (crmc ${Boost_LIBRARIES})
TARGET_LINK_LIBRARIES (crmc ${ROOT_LIBRARIES})
Colin Baus's avatar
Colin Baus committed
126
TARGET_LINK_LIBRARIES (crmc HepEvtDummy)
127 128 129 130

## installation
# configure the parameter file
install(CODE "SET (CRMCROOT \"${PROJECT_BINARY_DIR}\")")
131
install(CODE "SET (QIITAB \"${QGSJETII_TABS}\")")
132 133 134 135
install(CODE "
             IF(NOT EXISTS ${PROJECT_BINARY_DIR}/crmc.param)
             MESSAGE (STATUS \"(Re)creating crmc.param\")
             CONFIGURE_FILE (\"${PROJECT_SOURCE_DIR}/src/crmc.param.in\" \"${PROJECT_BINARY_DIR}/crmc.param\" @ONLY IMMEDIATE)
Colin Baus's avatar
Colin Baus committed
136
             ENDIF(NOT EXISTS ${PROJECT_BINARY_DIR}/crmc.param)
137
             ")
138 139 140 141 142 143 144

# install tabs
if(CMAKE_HOST_UNIX)
    install(CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink ${PROJECT_SOURCE_DIR}/tabs ${PROJECT_BINARY_DIR}/tabs)")
endif(CMAKE_HOST_UNIX)

# install executable
Colin Baus's avatar
Colin Baus committed
145 146
INSTALL (PROGRAMS ${PROJECT_BINARY_DIR}/crmc
         DESTINATION bin)
147 148 149

# enable dashboard scripting
include (CTest)
Tanguy Pierog's avatar
Tanguy Pierog committed
150 151 152
ADD_TEST (crmcRuns bin/crmc -o hepmc -f ctest.hepmc -T 1)
#ADD_TEST (crmcCheckFile md5sum "ctest.hepmc")
#SET_TESTS_PROPERTIES (crmcCheckFile PROPERTIES PASS_REGULAR_EXPRESSION ".*777cb7e60b7c8104393a4fb22b137538  ctest.hepmc")
153
ADD_TEST (crmcRemoveFile rm "ctest.hepmc")
154