IAP GITLAB

CMakeLists.txt 7.15 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 8 9 10 11 12
OPTION (__QGSJET01__   "Build with model" ON)
OPTION (__GHEISHA__    "Build with model" OFF)
OPTION (__PYTHIA__     "Build with model" OFF)
OPTION (__HIJING__     "Build with model" OFF)
OPTION (__SIBYLL__     "Build with model" ON)
OPTION (__PHOJET__     "Build with model" OFF)
Colin Baus's avatar
Colin Baus committed
13
OPTION (__DPMJET__     "Build with model" ON)
14
OPTION (__QGSJETII03__ "Build with model" ON)
Colin Baus's avatar
Colin Baus committed
15
OPTION (__QGSJETII04__ "Build with model" ON)
16 17
######################################ONLY EDIT THIS######################################

Ralf Ulrich's avatar
Ralf Ulrich committed
18 19 20 21 22 23 24 25 26 27
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}")

28
## The version number
29
SET (CRMC_VERSION_MAJOR 1)
Ralf Ulrich's avatar
Ralf Ulrich committed
30
SET (CRMC_VERSION_MINOR 1)
31

32
##Compiler options
33
# hotfix for lxbatch not sure why he selects wrong compiler
Colin Baus's avatar
Colin Baus committed
34
#SET (CMAKE_Fortran_COMPILER gfortran)
35 36 37 38

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

39 40 41
#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
42
     SET (CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} -Wunused")
43
     SET (CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} -O -Wuninitialized")
Colin Baus's avatar
Colin Baus committed
44
     #SET (CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} -Wall")
45 46 47
   ENDIF()
ENDFOREACH()

48 49 50 51 52 53
## 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
54
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
55 56 57 58 59 60 61 62 63 64 65

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")
66 67 68

## find packages
SET (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules" CACHE PATH "Module Path" FORCE)
69
# TODO ROOT NOT REQUIRED
70
FIND_PACKAGE (Root REQUIRED)
71
# SET(Boost_DEBUG TRUE)
72
FIND_PACKAGE (Boost 1.35 REQUIRED COMPONENTS filesystem iostreams system program_options)
73
# TODO HepMC NOT REQUIRED
74 75
FIND_PACKAGE (HepMC REQUIRED COMPONENTS HepMC HepMCfio)

76 77 78 79 80 81 82 83 84
# prepare crmc to use same size HEPMC common block than HepMC was compiled with
FILE(READ ${PROJECT_SOURCE_DIR}/src/epos.inc-HEPMC-TEMPLATE template)
STRING( REGEX REPLACE "HEPEVT_SIZE_REPLACE" "${HepMC_HEPEVT_SIZE}" template2 "${template}")
FILE(WRITE ${PROJECT_SOURCE_DIR}/src/epos.inc "${template2}")
FILE(READ ${PROJECT_SOURCE_DIR}/src/CRMCinterface.h-HEPMC-TEMPLATE template3)
STRING( REGEX REPLACE "HEPEVT_SIZE_REPLACE" "${HepMC_HEPEVT_SIZE}" template4 "${template3}")
FILE(WRITE ${PROJECT_SOURCE_DIR}/src/CRMCinterface.h "${template4}")


85 86
## configure a header file to pass some of the CMake settings to the source code
CONFIGURE_FILE (
Ralf Ulrich's avatar
Ralf Ulrich committed
87 88
  "${PROJECT_SOURCE_DIR}/src/CRMCconfig.h.in"
  "${PROJECT_BINARY_DIR}/src/CRMCconfig.h"
89 90 91 92 93
  )

#add epos (must!)
INCLUDE_DIRECTORIES ("${PROJECT_SOURCE_DIR}/src")
ADD_SUBDIRECTORY (src/epos)
94
SET (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -D __EPOS__")
95

Ralf Ulrich's avatar
Ralf Ulrich committed
96 97 98 99 100 101 102 103 104 105 106
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)

107 108
IF (__QGSJET01__)
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/src/qgsjet")
Ralf Ulrich's avatar
Ralf Ulrich committed
109 110
LIST(APPEND TABS qgsjet.dat)
LIST(APPEND TABS qgsjet.ncs)
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
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
129 130 131 132
IF (__PHOJET__)
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/src/phojet")
ENDIF (__PHOJET__)

Colin Baus's avatar
Colin Baus committed
133 134 135 136 137
IF (__DPMJET__)
LIST(APPEND TABS dpmjet.dat)
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/src/dpmjet/3.0-6")
ENDIF (__DPMJET__)

138 139
#put definition outside "if" because it is always is crmc.param file
SET (QGSJETII_TABS "03")
140
IF (__QGSJETII03__)
141
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/src/qgsjetII")
Ralf Ulrich's avatar
Ralf Ulrich committed
142 143
LIST(APPEND TABS qgsdat-II-03.lzma)
LIST(APPEND TABS sectnu-II-03)
144
ENDIF (__QGSJETII03__)
145

146 147 148
IF (__QGSJETII04__)
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/src/qgsjetII-04")
SET (QGSJETII_TABS "04")
Ralf Ulrich's avatar
Ralf Ulrich committed
149 150
LIST(APPEND TABS qgsdat-II-04.lzma)
LIST(APPEND TABS sectnu-II-04)
151 152
ENDIF (__QGSJETII04__)

Colin Baus's avatar
Colin Baus committed
153 154 155 156 157 158 159 160 161 162 163
#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")
164 165 166
INCLUDE_DIRECTORIES ("${HepMC_INCLUDE_DIRS}")
INCLUDE_DIRECTORIES ("${Boost_INCLUDE_DIRS}")
INCLUDE_DIRECTORIES ("${ROOT_INCLUDE_DIR}")
Colin Baus's avatar
Colin Baus committed
167
# the executable
Ralf Ulrich's avatar
Ralf Ulrich committed
168
ADD_EXECUTABLE(crmc src/crmcMain.cc src/CRMC.cc src/CRMCinterface.cc src/CRMCoptions.cc src/OutputPolicyROOT.cc src/OutputPolicyHepMC.cc src/OutputPolicyLHE.cc src/CRMCtrapfpe.c)
169

170
# linking of modules
171 172 173
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
174
TARGET_LINK_LIBRARIES (crmc HepEvtDummy)
175 176 177 178

## installation
# configure the parameter file
install(CODE "SET (CRMCROOT \"${PROJECT_BINARY_DIR}\")")
179
install(CODE "SET (QIITAB \"${QGSJETII_TABS}\")")
180 181 182 183
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
184
             ENDIF(NOT EXISTS ${PROJECT_BINARY_DIR}/crmc.param)
185
             ")
186 187

# install tabs
Ralf Ulrich's avatar
Ralf Ulrich committed
188 189 190 191 192 193
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)")
194 195

# install executable
Ralf Ulrich's avatar
Ralf Ulrich committed
196
INSTALL (PROGRAMS ${CMAKE_BINARY_DIR}/crmc DESTINATION bin)
197 198 199

# enable dashboard scripting
include (CTest)
Tanguy Pierog's avatar
Tanguy Pierog committed
200 201 202
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")
203
ADD_TEST (crmcRemoveFile rm "ctest.hepmc")
204