This repository has been archived by the owner on Nov 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
116 lines (89 loc) · 4.08 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
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
# CMakeLists.txt for event package. It creates a library with dictionary and a main program
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(generate VERSION 1.0
DESCRIPTION "generate neutrino event with GENIE"
LANGUAGES CXX)
#---Check "ROOT" environment variable is set
#message("THING:" $ENV{THING})
if(NOT DEFINED ENV{ROOTSYS})
message(FATAL_ERROR "ROOTSYS environment variable not defined")
endif()
#---Check "GENIE" environment variable is set
#message("THING:" $ENV{THING})
if(NOT DEFINED ENV{GENIE})
message(FATAL_ERROR "GENIE environment variable not defined")
endif()
#---Check "LOG4CPP" environment variable is set
#message("THING:" $ENV{THING})
if(NOT DEFINED ENV{LOG4CPP})
message(FATAL_ERROR "LOG4CPP environment variable not defined")
endif()
# 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
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 RIO Net Geom EGPythia6 XMLParser XMLIO)
#---Define useful ROOT functions and macros (e.g. ROOT_GENERATE_DICTIONARY)
include(${ROOT_USE_FILE})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
#---Create a shared library with geneated dictionary
#add_library(Event SHARED Event.cxx G__Event.cxx)
#target_link_libraries(Event ${ROOT_LIBRARIES})
#---Define GENIE environment variables
set(GENIE_DIR "$ENV{GENIE}")
set(GENIE_INC_DIR "${GENIE_DIR}/src")
set(GENIE_LIB_DIR "${GENIE_DIR}/lib")
set(GENIE_LIBRARIES)
foreach(_cpt GFwMsg GFwReg GFwAlg GFwInt GFwGHEP GFwNum GFwUtl GFwParDat GFwEG GFwNtp GPhXSIg GPhPDF GPhNuclSt GPhCmn GPhDcy GPhHadTransp GPhHadnz GPhDeEx GPhAMNGXS GPhAMNGEG GPhChmXS GPhCohXS GPhCohEG GPhDISXS GPhDISEG GPhDfrcXS GPhDfrcEG GPhGlwResXS GPhGlwResEG GPhIBDXS GPhIBDEG GPhMNucXS GPhMNucEG GPhMEL GPhNuElXS GPhNuElEG GPhQELXS GPhQELEG GPhResXS GPhResEG GPhStrXS GPhStrEG GPhNDcy GPhNNBarOsc GPhBDMXS GPhBDMEG GTlGeo GTlFlx)
find_library(GENIE_${_cpt}_LIBRARY ${_cpt} HINTS ${GENIE_LIB_DIR})
if(GENIE_${_cpt}_LIBRARY)
mark_as_advanced(GENIE_${_cpt}_LIBRARY)
list(APPEND GENIE_LIBRARIES ${GENIE_${_cpt}_LIBRARY})
endif()
endforeach()
if(GENIE_LIBRARIES)
list(REMOVE_DUPLICATES GENIE_LIBRARIES)
endif()
include_directories("${GENIE_INC_DIR}")
#---Add LOG4CPP library
set(LOG4CPP_DIR "$ENV{LOG4CPP}")
set(LOG4CPP_INC_DIR "${LOG4CPP_DIR}/include")
set(LOG4CPP_LIB_DIR "${LOG4CPP_DIR}/lib")
set(LOG4CPP_LIBRARIES)
find_library(LOG4CPP_LIBRARY log4cpp HINTS ${LOG4CPP_LIB_DIR})
if(LOG4CPP_LIBRARY)
mark_as_advanced(LOG4CPP_LIBRARY)
list(APPEND LOG4CPP_LIBRARIES ${LOG4CPP_LIBRARY})
endif()
if(LOG4CPP_LIBRARIES)
list(REMOVE_DUPLICATES LOG4CPP_LIBRARIES)
endif()
include_directories("${LOG4CPP_INC_DIR}")
#---Add DK2NU library if DK2NU environment variable is defined
set(DK2NU_LIBRARIES)
if(DEFINED ENV{DK2NU})
set(DK2NU_DIR "$ENV{DK2NU}")
set(DK2NU_INC_DIR "${DK2NU_DIR}/include")
set(DK2NU_LIB_DIR "${DK2NU_DIR}/lib")
find_library(DK2NU_LIBRARY dk2nuGenie HINTS ${DK2NU_LIB_DIR} REQUIRED)
if(DK2NU_LIBRARY)
mark_as_advanced(DK2NU_LIBRARY)
list(APPEND DK2NU_LIBRARIES ${DK2NU_LIBRARY})
endif()
if(DK2NU_LIBRARIES)
list(REMOVE_DUPLICATES DK2NU_LIBRARIES)
endif()
include_directories("${DK2NU_INC_DIR}")
add_definitions(-DWITH_DK2NU)
endif()
#---Create a main program using the library
add_executable(generate ${CMAKE_CURRENT_SOURCE_DIR}/src/generate.cpp)
#add_executable(Main MainEvent.cxx)
target_link_libraries(generate ${ROOT_LIBRARIES} ${GENIE_LIBRARIES} ${LOG4CPP_LIBRARIES} ${DK2NU_LIBRARIES})
install(TARGETS generate
EXPORT generate
LIBRARY DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/lib
ARCHIVE DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/lib
RUNTIME DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/bin
)