IAP GITLAB

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

4
######################################ONLY EDIT THIS######################################
5

6
# Enable/Disable models to be built
7
OPTION (__CRMCSTATIC__ "Build with static library" OFF)   #if ON should not combined DPMJET/PHOJET/PYTHIA because they use different version of pythia (for dynamic library no problem)
8

9
OPTION (__QGSJET01__   "Build with model" OFF)
10
OPTION (__GHEISHA__    "Build with model" OFF)
Tanguy Pierog's avatar
Tanguy Pierog committed
11
OPTION (__PYTHIA__     "Build with model" OFF)
12
OPTION (__HIJING__     "Build with model" OFF)
13
OPTION (__SIBYLL__     "Build with model" ON)
Tanguy Pierog's avatar
Tanguy Pierog committed
14
OPTION (__PHOJET__     "Build with model" OFF)
15
OPTION (__DPMJET__     "Build with model" ON)
Tanguy Pierog's avatar
Tanguy Pierog committed
16
OPTION (__QGSJETII03__ "Build with model" OFF)
Ralf Ulrich's avatar
Ralf Ulrich committed
17
OPTION (__QGSJETII04__ "Build with model" ON)
18 19
######################################ONLY EDIT THIS######################################

Ralf Ulrich's avatar
Ralf Ulrich committed
20 21 22 23 24 25 26 27 28 29
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
  set (CMAKE_INSTALL_PREFIX $ENV{PWD} CACHE PATH "default install path" FORCE )
endif()

SET(PROJECT_BINARY_DIR ${CMAKE_INSTALL_PREFIX})

MESSAGE(STATUS "source ${PROJECT_SOURCE_DIR}")
MESSAGE(STATUS "binary ${PROJECT_BINARY_DIR}")
MESSAGE(STATUS "build ${CMAKE_BINARY_DIR}")

30
## The version number. Only nummeric PLEASE!
31
SET (CRMC_VERSION_MAJOR 1)
Tanguy Pierog's avatar
Tanguy Pierog committed
32 33
SET (CRMC_VERSION_MINOR 6)
SET (CRMC_VERSION_PATCH 0)
34

35
##Compiler options
36
# hotfix for lxbatch not sure why he selects wrong compiler
Colin Baus's avatar
Colin Baus committed
37
#SET (CMAKE_Fortran_COMPILER gfortran)
38
#SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lgfortran")
39 40 41 42

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

43 44 45
#add some warning to the compiler flags
FOREACH(lang C CXX Fortran)
   IF(CMAKE_${lang}_COMPILER_ID STREQUAL GNU)
Colin Baus's avatar
Colin Baus committed
46
     SET (CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} -Wunused")
47
     SET (CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} -O -Wuninitialized")
Colin Baus's avatar
Colin Baus committed
48
     #SET (CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} -Wall")
49 50 51
   ENDIF()
ENDFOREACH()

52 53 54 55 56 57
## 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
58
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
59 60 61 62 63 64 65 66 67 68 69

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")
70

71 72 73 74 75 76 77 78 79 80 81 82
## check for c++11 support
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
        message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please consider updating your C++ compiler.")
endif()

83 84
## find packages
SET (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules" CACHE PATH "Module Path" FORCE)
Ralf Ulrich's avatar
Ralf Ulrich committed
85 86 87 88 89

SET (CRMC_SOURCES src/crmcMain.cc src/CRMC.cc src/CRMCinterface.cc src/CRMCoptions.cc src/OutputPolicyLHE.cc src/OutputPolicyNone.cc src/CRMCtrapfpe.c)


FIND_PACKAGE (Root)
90
if (Root_FOUND)
Ralf Ulrich's avatar
Ralf Ulrich committed
91 92 93 94 95 96 97 98
  INCLUDE_DIRECTORIES ("${ROOT_INCLUDE_DIR}")
  LIST(APPEND CRMC_SOURCES src/OutputPolicyROOT.cc)
  add_definitions(-DWITH_ROOT)
  MESSAGE("Build ROOT Output Interface")
else (Root_FOUND)
  MESSAGE("Cannot Build ROOT Output Interface")
endif (Root_FOUND)

99
# SET(Boost_DEBUG TRUE)
100
FIND_PACKAGE (Boost 1.35 REQUIRED COMPONENTS filesystem iostreams system program_options)
Ralf Ulrich's avatar
Ralf Ulrich committed
101

102
FIND_PACKAGE (HepMC REQUIRED COMPONENTS HepMC HepMCfio)
Ralf Ulrich's avatar
Ralf Ulrich committed
103 104 105 106 107
INCLUDE_DIRECTORIES ("${HepMC_INCLUDE_DIRS}")
LIST(APPEND CRMC_SOURCES src/OutputPolicyHepMC.cc)
add_definitions(-DWITH_HEPMC)
MESSAGE("Build HEPMC Output Interface")

108
FIND_PACKAGE (Fastjet COMPONENTS fastjet)
Ralf Ulrich's avatar
Ralf Ulrich committed
109 110 111 112 113 114
if (FASTJET_FOUND)
  include_directories("${Fastjet_INCLUDE_DIRS}")
  add_definitions(-DWITH_FASTJET)
  MESSAGE("Include fastjet filter")
endif (FASTJET_FOUND)

115

116
# prepare crmc to use same size HEPMC common block than HepMC was compiled with
117
STRING ( STRIP ${HepMC_HEPEVT_SIZE} Replace_String )
118
FILE(READ ${PROJECT_SOURCE_DIR}/src/epos.inc-HEPMC-TEMPLATE template)
119
STRING( REGEX REPLACE "HEPEVT_SIZE_REPLACE" "${Replace_String}" template2 "${template}")
120
FILE(WRITE ${PROJECT_SOURCE_DIR}/src/epos.inc "${template2}")
121

122
FILE(READ ${PROJECT_SOURCE_DIR}/src/CRMCinterface.h-HEPMC-TEMPLATE template3)
123
STRING( REGEX REPLACE "HEPEVT_SIZE_REPLACE" "${Replace_String}" template4 "${template3}")
124 125
FILE(WRITE ${PROJECT_SOURCE_DIR}/src/CRMCinterface.h "${template4}")

126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
FILE(READ ${PROJECT_SOURCE_DIR}/src/pythia/pythia6115.f-HEPMC-TEMPLATE template5)
STRING( REGEX REPLACE "HEPEVT_SIZE_REPLACE" "${Replace_String}" template6 "${template5}")
FILE(WRITE ${PROJECT_SOURCE_DIR}/src/pythia/pythia6115.f "${template6}")

FILE(READ ${PROJECT_SOURCE_DIR}/src/pythia/pythia6215.f-HEPMC-TEMPLATE template7)
STRING( REGEX REPLACE "HEPEVT_SIZE_REPLACE" "${Replace_String}" template8 "${template7}")
FILE(WRITE ${PROJECT_SOURCE_DIR}/src/pythia/pythia6215.f "${template8}")

FILE(READ ${PROJECT_SOURCE_DIR}/src/pythia/pythia-6.4.28.f-HEPMC-TEMPLATE template9)
STRING( REGEX REPLACE "HEPEVT_SIZE_REPLACE" "${Replace_String}" template10 "${template9}")
FILE(WRITE ${PROJECT_SOURCE_DIR}/src/pythia/pythia-6.4.28.f "${template10}")

FILE(READ ${PROJECT_SOURCE_DIR}/src/hijing/hipyset1.35.f-HEPMC-TEMPLATE template11)
STRING( REGEX REPLACE "HEPEVT_SIZE_REPLACE" "${Replace_String}" template12 "${template11}")
FILE(WRITE ${PROJECT_SOURCE_DIR}/src/hijing/hipyset1.35.f "${template12}")

142
FILE(READ ${PROJECT_SOURCE_DIR}/src/dpmjet/3.2017-1/pythia-6427_cors.f-HEPMCTEMPLATE template13)
143
STRING( REGEX REPLACE "HEPEVT_SIZE_REPLACE" "${Replace_String}" template14 "${template13}")
144 145 146 147 148 149 150 151 152
FILE(WRITE ${PROJECT_SOURCE_DIR}/src/dpmjet/3.2017-1/pythia-6427_cors.f "${template14}")

FILE(READ ${PROJECT_SOURCE_DIR}/src/dpmjet/3.2017-1/phojet.f-HEPMCTEMPLATE template15)
STRING( REGEX REPLACE "HEPEVT_SIZE_REPLACE" "${Replace_String}" template16 "${template15}")
FILE(WRITE ${PROJECT_SOURCE_DIR}/src/dpmjet/3.2017-1/phojet.f "${template16}")

FILE(READ ${PROJECT_SOURCE_DIR}/src/dpmjet/3.2017-1/dpmjet.f-HEPMCTEMPLATE template17)
STRING( REGEX REPLACE "HEPEVT_SIZE_REPLACE" "${Replace_String}" template18 "${template17}")
FILE(WRITE ${PROJECT_SOURCE_DIR}/src/dpmjet/3.2017-1/dpmjet.f "${template18}")
153 154 155



156

157 158
## configure a header file to pass some of the CMake settings to the source code
CONFIGURE_FILE (
Ralf Ulrich's avatar
Ralf Ulrich committed
159 160
  "${PROJECT_SOURCE_DIR}/src/CRMCconfig.h.in"
  "${PROJECT_BINARY_DIR}/src/CRMCconfig.h"
161 162 163
  )

INCLUDE_DIRECTORIES ("${PROJECT_SOURCE_DIR}/src")
164 165

#add epos (must!)
166 167
ADD_SUBDIRECTORY (src/epos)

Ralf Ulrich's avatar
Ralf Ulrich committed
168 169 170 171 172 173 174 175 176 177 178
SET (TABS "")

# data tables for epos
LIST(APPEND TABS epos.inics)
LIST(APPEND TABS epos.inics.lhc)
LIST(APPEND TABS epos.inidi)
LIST(APPEND TABS epos.iniev)
LIST(APPEND TABS epos.inirj)
LIST(APPEND TABS epos.inirj.lhc)
LIST(APPEND TABS epos.initl)

179 180
IF (__QGSJET01__)
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/src/qgsjet")
Ralf Ulrich's avatar
Ralf Ulrich committed
181 182
LIST(APPEND TABS qgsjet.dat)
LIST(APPEND TABS qgsjet.ncs)
183 184 185
SET(STATIC_LIBS ${STATIC_LIBS} Qgsjet01)
get_property(HELPER SOURCE src/models.F PROPERTY COMPILE_FLAGS)
set_property(SOURCE src/models.F PROPERTY COMPILE_FLAGS "${HELPER} -D __QGSJET01__") #set properties APPEND has a bug
186 187 188 189
ENDIF (__QGSJET01__)

IF (__GHEISHA__)
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/src/gheisha")
190 191 192
SET(STATIC_LIBS ${STATIC_LIBS} Gheisha)
get_property(HELPER SOURCE src/models.F PROPERTY COMPILE_FLAGS)
set_property(SOURCE src/models.F PROPERTY COMPILE_FLAGS "${HELPER} -D __GHEISHA__")
193 194 195 196
ENDIF (__GHEISHA__)

IF (__PYTHIA__)
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/src/pythia")
197 198 199
SET(STATIC_LIBS ${STATIC_LIBS} Pythia)
get_property(HELPER SOURCE src/models.F PROPERTY COMPILE_FLAGS)
set_property(SOURCE src/models.F PROPERTY COMPILE_FLAGS "${HELPER} -D __PYTHIA__")
200 201 202 203
ENDIF (__PYTHIA__)

IF (__HIJING__)
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/src/hijing")
204 205 206
SET(STATIC_LIBS ${STATIC_LIBS} Hijing)
get_property(HELPER SOURCE src/models.F PROPERTY COMPILE_FLAGS)
set_property(SOURCE src/models.F PROPERTY COMPILE_FLAGS "${HELPER} -D __HIJING__")
207 208 209 210
ENDIF (__HIJING__)

IF (__SIBYLL__)
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/src/sibyll")
211 212 213
SET(STATIC_LIBS ${STATIC_LIBS} Sibyll)
get_property(HELPER SOURCE src/models.F PROPERTY COMPILE_FLAGS)
set_property(SOURCE src/models.F PROPERTY COMPILE_FLAGS "${HELPER} -D __SIBYLL__")
214 215
ENDIF (__SIBYLL__)

Colin Baus's avatar
Colin Baus committed
216 217
IF (__PHOJET__)
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/src/phojet")
218 219 220
SET(STATIC_LIBS ${STATIC_LIBS} Phojet)
get_property(HELPER SOURCE src/models.F PROPERTY COMPILE_FLAGS)
set_property(SOURCE src/models.F PROPERTY COMPILE_FLAGS "${HELPER} -D __PHOJET__")
Colin Baus's avatar
Colin Baus committed
221 222
ENDIF (__PHOJET__)

Colin Baus's avatar
Colin Baus committed
223
IF (__DPMJET__)
224 225
LIST(APPEND TABS dpmjpar.dat)
LIST(APPEND TABS dpmCT14LL.pds)
226
LIST(APPEND TABS conextar.glb)
227
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/src/dpmjet/3.2017-1")
228 229 230
SET(STATIC_LIBS ${STATIC_LIBS} Dpmjet)
get_property(HELPER SOURCE src/models.F PROPERTY COMPILE_FLAGS)
set_property(SOURCE src/models.F PROPERTY COMPILE_FLAGS "${HELPER} -D __DPMJET__")
Colin Baus's avatar
Colin Baus committed
231 232
ENDIF (__DPMJET__)

233 234
#put definition outside "if" because it is always is crmc.param file
SET (QGSJETII_TABS "03")
235
IF (__QGSJETII03__)
236
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/src/qgsjetII")
237 238 239
SET(STATIC_LIBS ${STATIC_LIBS} QgsjetII03)
get_property(HELPER SOURCE src/models.F PROPERTY COMPILE_FLAGS)
set_property(SOURCE src/models.F PROPERTY COMPILE_FLAGS "${HELPER} -D __QGSJETII03__")
Ralf Ulrich's avatar
Ralf Ulrich committed
240 241
LIST(APPEND TABS qgsdat-II-03.lzma)
LIST(APPEND TABS sectnu-II-03)
242
ENDIF (__QGSJETII03__)
243

244 245
IF (__QGSJETII04__)
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/src/qgsjetII-04")
246 247 248
SET(STATIC_LIBS ${STATIC_LIBS} QgsjetII04)
get_property(HELPER SOURCE src/models.F PROPERTY COMPILE_FLAGS)
set_property(SOURCE src/models.F PROPERTY COMPILE_FLAGS "${HELPER} -D __QGSJETII04__")
249
SET (QGSJETII_TABS "04")
Ralf Ulrich's avatar
Ralf Ulrich committed
250 251
LIST(APPEND TABS qgsdat-II-04.lzma)
LIST(APPEND TABS sectnu-II-04)
252 253
ENDIF (__QGSJETII04__)

254 255 256 257 258 259 260 261 262 263
IF (__CRMCSTATIC__)
#has to be after all other models since variables must be set for fortran precompiler
add_library(CrmcFortranStatic STATIC src/crmc-aaa.f src/models.F)
INSTALL (TARGETS CrmcFortranStatic
        RUNTIME DESTINATION bin
        LIBRARY DESTINATION lib
        ARCHIVE DESTINATION lib/static
        )
TARGET_LINK_LIBRARIES (CrmcFortranStatic ${STATIC_LIBS})
ELSE (__CRMCSTATIC__)
Colin Baus's avatar
Colin Baus committed
264 265 266 267 268 269 270 271
#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
        )
272 273 274
ENDIF (__CRMCSTATIC__)


Colin Baus's avatar
Colin Baus committed
275 276 277

#include directories for headers
INCLUDE_DIRECTORIES ("${PROJECT_BINARY_DIR}/src")
278
INCLUDE_DIRECTORIES ("${Boost_INCLUDE_DIRS}")
Colin Baus's avatar
Colin Baus committed
279
# the executable
Ralf Ulrich's avatar
Ralf Ulrich committed
280
ADD_EXECUTABLE(crmc ${CRMC_SOURCES})
281

282
# linking of modules
Ralf Ulrich's avatar
Ralf Ulrich committed
283
TARGET_LINK_LIBRARIES (crmc ${CMAKE_DL_LIBS})
284 285
TARGET_LINK_LIBRARIES (crmc ${HepMC_LIBRARIES})
TARGET_LINK_LIBRARIES (crmc ${Boost_LIBRARIES})
Ralf Ulrich's avatar
Ralf Ulrich committed
286 287 288
if (Root_FOUND)
  TARGET_LINK_LIBRARIES (crmc ${ROOT_LIBRARIES})
endif (Root_FOUND)
289
IF (__CRMCSTATIC__)
Ralf Ulrich's avatar
Ralf Ulrich committed
290 291
  TARGET_LINK_LIBRARIES (crmc CrmcBasic)
  TARGET_LINK_LIBRARIES (crmc CrmcFortranStatic)
292
ELSE (__CRMCSTATIC__)
Ralf Ulrich's avatar
Ralf Ulrich committed
293
  TARGET_LINK_LIBRARIES (crmc HepEvtDummy)
294
ENDIF (__CRMCSTATIC__)
295 296 297 298

## installation
# configure the parameter file
install(CODE "SET (CRMCROOT \"${PROJECT_BINARY_DIR}\")")
299
install(CODE "SET (QIITAB \"${QGSJETII_TABS}\")")
300 301 302 303
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
304
             ENDIF(NOT EXISTS ${PROJECT_BINARY_DIR}/crmc.param)
305
             ")
306 307

# install tabs
Ralf Ulrich's avatar
Ralf Ulrich committed
308 309 310 311 312 313
SET (TABSDIR "")
foreach(theTab ${TABS})
  list(APPEND TABSDIR ${PROJECT_SOURCE_DIR}/tabs/${theTab} )
endforeach()
INSTALL (FILES ${TABSDIR} DESTINATION ${PROJECT_BINARY_DIR}/tabs)
#    install(CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/tabs ${PROJECT_BINARY_DIR}/tabs)")
314 315

# install executable
Ralf Ulrich's avatar
Ralf Ulrich committed
316
INSTALL (PROGRAMS ${CMAKE_BINARY_DIR}/crmc DESTINATION bin)
317 318 319

# enable dashboard scripting
include (CTest)
Tanguy Pierog's avatar
Tanguy Pierog committed
320 321 322
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")
323
ADD_TEST (crmcRemoveFile rm "ctest.hepmc")