forked from uiowahep/Analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
153 lines (138 loc) · 4.92 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#
# build everything with cmake
#
# min version for cmake
cmake_minimum_required(VERSION 2.8.0)
# project name
project (Analysis)
message (SOURCE DIRECTORY = ${PROJECT_SOURCE_DIR})
message (BUILD DIRECTORY = ${PROJECT_BINARY_DIR})
#
# Compiler flags and some definitions
#
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
add_definitions(-DSTANDALONE=1)
#
# project's versions and some other env vars to pass
#
set (Analysis_VERSION_MAJOR 1)
set (Analysis_VERSION_MINOR 0)
configure_file(
"${PROJECT_SOURCE_DIR}/config/config.h.in"
"${PROJECT_BINARY_DIR}/config/config.h"
)
#
# add the config.h to the search include path and enable
#
include_directories("${PROJECT_BINARY_DIR}/config")
option (STANDALONE
"Compile and build in standalone mode without CMSSW" ON
)
#
# Find BOOST
#
find_package(Boost COMPONENTS program_options system REQUIRED )
include_directories("${Boost_INCLUDE_DIRS}")
set (EXTRA_LIBS ${EXTRA_LIBS} ${Boost_LIBRARIES})
add_definitions(${})
#
# find and add ROOT
#
set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/config)
find_package(ROOT REQUIRED COMPONENTS RHTTP)
include_directories("${ROOT_INCLUDE_DIR}")
add_definitions(${ROOT_CXX_FLAGS})
#
# add ROOT to the eet of libraries to link against
#
set (EXTRA_LIBS ${EXTRA_LIBS} ${ROOT_LIBRARIES})
#
# add the includes to the search path
#
include_directories ("${PROJECT_SOURCE_DIR}/Core/interface")
include_directories ("${PROJECT_SOURCE_DIR}/AuxTools/interface")
include_directories ("${PROJECT_SOURCE_DIR}/Drivers/interface")
#
# Generate ROOT Dictionary and Shared Lib
#
ROOT_GENERATE_DICTIONARY(G__Core
${PROJECT_SOURCE_DIR}/Core/interface/Object.h
${PROJECT_SOURCE_DIR}/Core/interface/Track.h
${PROJECT_SOURCE_DIR}/Core/interface/Muon.h
${PROJECT_SOURCE_DIR}/Core/interface/GenJet.h
${PROJECT_SOURCE_DIR}/Core/interface/Jet.h
${PROJECT_SOURCE_DIR}/Core/interface/GenParticle.h
${PROJECT_SOURCE_DIR}/Core/interface/MET.h
${PROJECT_SOURCE_DIR}/Core/interface/Vertex.h
${PROJECT_SOURCE_DIR}/Core/interface/Event.h
${PROJECT_SOURCE_DIR}/Core/interface/QIE8Frame.h
${PROJECT_SOURCE_DIR}/Core/interface/MetaHiggs.h
${PROJECT_SOURCE_DIR}/Core/interface/QIE10Frame.h
${PROJECT_SOURCE_DIR}/Core/interface/Electron.h
${PROJECT_SOURCE_DIR}/Core/interface/Tau.h
${PROJECT_SOURCE_DIR}/Core/interface/TestClass1.h
${PROJECT_SOURCE_DIR}/Core/interface/TestClass2.h
${PROJECT_SOURCE_DIR}/Core/interface/TestClass3.h
${PROJECT_SOURCE_DIR}/Core/interface/Root4jTestSet.h
LINKDEF ${PROJECT_SOURCE_DIR}/config/LinkDef.h
OPTIONS -DSTANDALONE=1
)
add_library(AnalysisCore SHARED G__Core.cxx)
target_link_libraries(AnalysisCore ${ROOT_LIBRARIES})
set (EXTRA_LIBS ${EXTRA_LIBS} AnalysisCore)
#
# Add Ntuple Processing as shared lib but compiled as a ROOT dictionary
#
ROOT_GENERATE_DICTIONARY(G__AuxTools
${PROJECT_SOURCE_DIR}/AuxTools/interface/Streamer.h
LINKDEF ${PROJECT_SOURCE_DIR}/config/LinkDef.h
OPTIONS -DSTANDALONE=1
)
add_library(AnalysisAuxTools SHARED
${PROJECT_SOURCE_DIR}/AuxTools/src/Streamer.cc
G__AuxTools.cxx
)
target_link_libraries(AnalysisAuxTools ${ROOT_LIBRARIES})
set (EXTRA_LIBS ${EXTRA_LIBS} AnalysisAuxTools)
#
# Add the headers to compile against
#
file (GLOB HEADERS ${PROJECT_SOURCE_DIR}/AuxTools/interface/*.h)
file (GLOB HEADERS1 ${PROJECT_SOURCE_DIR}/Drivers/interface/*.h)
set (HEADERS ${HEADERS} ${HEADERS1})
#
# add all the executables and link against ROOT
#
file (GLOB MAIN_FILES1 ${PROJECT_SOURCE_DIR}/Drivers/test/*.cc)
file (GLOB MAIN_FILES2 ${PROJECT_SOURCE_DIR}/Drivers/src/*.cc)
foreach (MAIN_FILE ${MAIN_FILES1})
string(REPLACE ".cc" "" EXECUTABLE_NAME ${MAIN_FILE})
string(REPLACE "${PROJECT_SOURCE_DIR}/Drivers/test/" ""
EXECUTABLE_NAME ${EXECUTABLE_NAME}
)
message("Adding Executable: ${EXECUTABLE_NAME}")
# add_executable(${EXECUTABLE_NAME} ${MAIN_FILE} ${SOURCES} ${HEADERS})
add_executable(${EXECUTABLE_NAME} ${MAIN_FILE} ${HEADERS})
target_link_libraries (${EXECUTABLE_NAME} ${EXTRA_LIBS})
endforeach(MAIN_FILE)
foreach (MAIN_FILE ${MAIN_FILES2})
string(REPLACE ".cc" "" EXECUTABLE_NAME ${MAIN_FILE})
string(REPLACE "${PROJECT_SOURCE_DIR}/Drivers/src/" ""
EXECUTABLE_NAME ${EXECUTABLE_NAME}
)
message("Adding Executable: ${EXECUTABLE_NAME}")
#add_executable(${EXECUTABLE_NAME} ${MAIN_FILE} ${SOURCES} ${HEADERS})
add_executable(${EXECUTABLE_NAME} ${MAIN_FILE} ${HEADERS})
target_link_libraries (${EXECUTABLE_NAME} ${EXTRA_LIBS})
endforeach(MAIN_FILE)
#
# copy whatever you need
# For Python Processing - copy python folders as well with purely python stuff
#
file (GLOB ALL_SCRIPTS ${PROJECT_SOURCE_DIR}/scripts/*.*)
file (GLOB ALL_CONFIG ${PROJECT_SOURCE_DIR}/config/*.*)
file (GLOB ALL_RESOURCES ${PROJECT_SOURCE_DIR}/resources/*.*)
file (COPY ${ALL_SCRIPTS} DESTINATION ${PROJECT_BINARY_DIR}/scripts)
file (COPY ${ALL_CONFIG} DESTINATION ${PROJECT_BINARY_DIR}/config)
file (COPY ${ALL_RESOURCES} DESTINATION ${PROJECT_BINARY_DIR}/resources)
file (COPY ${PROJECT_SOURCE_DIR}/AuxTools/python DESTINATION ${PROJECT_BINARY_DIR}/AuxTools)