IAP GITLAB

CMakeLists.txt 3.85 KB
Newer Older
1 2 3 4 5 6 7
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
PROJECT (crmc)
# The version number.
SET (CRMC_VERSION_MAJOR 0)
SET (CRMC_VERSION_MINOR 1)

#hotfix for lxbatch not sure why he selects wrong compiler
Colin Baus's avatar
Colin Baus committed
8
#SET (CMAKE_Fortran_COMPILER gfortran)
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116

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

# Enable/Disble models to be built
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 (__QGSJETII__ "Build with model" ON)

OPTION (CRMC_USE_BOOST  "Build with boost and compression capability" ON)

## find packages
SET (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules" CACHE PATH "Module Path" FORCE)
FIND_PACKAGE (Root REQUIRED)
IF (CRMC_USE_BOOST)
   FIND_PACKAGE (Boost REQUIRED COMPONENTS filesystem iostreams)
ELSE (CRMC_USE_BOOST)
   FIND_PACKAGE (Boost REQUIRED COMPONENTS filesystem iostreams)
ENDIF (CRMC_USE_BOOST)
FIND_PACKAGE (HepMC REQUIRED COMPONENTS HepMC HepMCfio)

## configure a header file to pass some of the CMake settings to the source code
CONFIGURE_FILE (
  "${PROJECT_SOURCE_DIR}/src/crmcconfig.h.in"
  "${PROJECT_BINARY_DIR}/src/crmcconfig.h"
  )

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

IF (__QGSJET01__)
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/src/qgsjet")
SET (EXTRA_MODELS ${EXTRA_MODELS} Qgsjet01)
SET (CMAKE_Fortran_FLAGS "-D __QGSJET01__ ")

ENDIF (__QGSJET01__)

IF (__GHEISHA__)
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/src/gheisha")
SET (EXTRA_MODELS ${EXTRA_MODELS} Gheisha)
SET (CMAKE_Fortran_FLAGS "-D __GHEISHA__ ")
ENDIF (__GHEISHA__)

IF (__PYTHIA__)
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/src/pythia")
SET (EXTRA_MODELS ${EXTRA_MODELS} Pythia)
SET (CMAKE_Fortran_FLAGS "-D __PYTHIA__ ")
ENDIF (__PYTHIA__)

IF (__HIJING__)
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/src/hijing")
SET (EXTRA_MODELS ${EXTRA_MODELS} Hijing)
SET (CMAKE_Fortran_FLAGS "-D __HIJING__ ")
ENDIF (__HIJING__)

IF (__SIBYLL__)
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/src/sibyll")
SET (EXTRA_MODELS ${EXTRA_MODELS} Sibyll)
SET (CMAKE_Fortran_FLAGS "-D __SIBYLL__ ")
ENDIF (__SIBYLL__)

IF (__QGSJETII__)
ADD_SUBDIRECTORY ("${PROJECT_SOURCE_DIR}/src/qgsjetII")
SET (EXTRA_MODELS ${EXTRA_MODELS} QgsjetII)
SET (CMAKE_Fortran_FLAGS "-D __QGSJETII__ ")
ENDIF (__QGSJETII__)

# add the executable
INCLUDE_DIRECTORIES ("${PROJECT_BINARY_DIR}/src") #cmake config file
INCLUDE_DIRECTORIES ("${HepMC_INCLUDE_DIRS}")
INCLUDE_DIRECTORIES ("${Boost_INCLUDE_DIRS}")
INCLUDE_DIRECTORIES ("${ROOT_INCLUDE_DIR}")
ADD_EXECUTABLE(Crmc src/crmchep.cc src/crmctrapfpe.c src/crmc-aaa.f src/models.F)

TARGET_LINK_LIBRARIES (Crmc ${HepMC_LIBRARIES})
TARGET_LINK_LIBRARIES (Crmc ${Boost_LIBRARIES})
TARGET_LINK_LIBRARIES (Crmc ${ROOT_LIBRARIES})
TARGET_LINK_LIBRARIES (Crmc ${EXTRA_MODELS})

## installation
SET (CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR})

# configure the parameter file
install(CODE "SET (CRMCROOT \"${PROJECT_BINARY_DIR}\")")
install(CODE "CONFIGURE_FILE (\"${PROJECT_SOURCE_DIR}/src/crmc.param.in\" \"${PROJECT_BINARY_DIR}/crmc.param\" @ONLY IMMEDIATE)")

# 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
INSTALL (PROGRAMS ${PROJECT_SOURCE_DIR}/src/crmc.py DESTINATION bin)
INSTALL (PROGRAMS ${PROJECT_BINARY_DIR}/Crmc DESTINATION bin RENAME crmc)

# enable dashboard scripting
include (CTest)
ADD_TEST (CrmcRuns bin/crmc -s 123 -f ctest)
ADD_TEST (CrmcCheckFile md5sum "ctest")
SET_TESTS_PROPERTIES (CrmcCheckFile PROPERTIES PASS_REGULAR_EXPRESSION ".*13a1067a443279b3e397eab0e58e2e4e  ctest")
ADD_TEST (CrmcRemoveFile rm "ctest")