-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
169 lines (149 loc) · 5.98 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#
# source /nusoft/app/externals/setup
# setup cmake
# setup genie v2_8_0a -q debug:e4
# setup root v5_34_05 -q debug:e4
#
# cd /nova/app/users/$USER
#
# mkdir dk2nu-build dk2n-install
# cd dk2nu-build
#
# cmake [ -DWITH_GENIE=ON ] \
# [ -DGENIE_ONLY=OFF -DDK2NUDATA_DIR=<path-to-dk2nudata-install> ] \
# [ -DWITH_TBB=OFF ] \
# -DCMAKE_INSTALL_PREFIX:PATH=<path-to-install>/dk2nu-install \
# <path-to-source>/dk2nu
#
# Required environment variables:
# ROOTSYS e.g. /nusoft/app/externals/root/v5_34_05/Linux64bit+2.6-2.5-e2-debug
# Optional
# GENIE
# if GENIE, also requires $LIBXML2_INC and $LOG4CPP_INC
#
#----------------------------------------------------------------------------
# Setup the project
#
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(dk2nu)
set(CMAKE_BUILD_TYPE Debug)
set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib")
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")
#----------------------------------------------------------------------------
# By default attempt to build GENIE flux driver
# You can set WITH_GENIE to OFF via the command line or ccmake/cmake-gui
# to build only the base class library
#
option(WITH_GENIE "Build GENIE flux driver" ON)
option(GENIE_ONLY "Build only GENIE flux driver" OFF)
option(DK2NUDATA_DIR "path the dk2nu data half of package if GENIE_ONLY" "")
option(WITH_TBB "Build in linkage to TBB library" ON)
option(COPY_AUX "install etc, convert, snippets subdirectories" ON)
execute_process(COMMAND root-config --version OUTPUT_VARIABLE ROOT_VERSION)
string(STRIP ${ROOT_VERSION} ROOT_VERSION)
string(SUBSTRING ${ROOT_VERSION} 0 1 ROOT_MAJOR_VERSION)
MESSAGE("--DK2NU-- ROOT_VERSION=${ROOT_VERSION} major=${ROOT_MAJOR_VERSION}")
# for now this still has to work with both 5 & 6
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake
$ENV{ROOTSYS}/cmake/modules
$ENV{ROOTSYS}/etc/cmake
${CMAKE_MODULE_PATH} )
#MESSAGE("CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}")
#MESSAGE(" ")
find_package(ROOT REQUIRED)
include(Darwin)
if( ${ROOT_MAJOR_VERSION} LESS 6 )
# older ROOT wasn't so helpful, mimic what ROOT 6 does
MESSAGE("--DK2NU-- start ROOT 5 config")
include(CMakeParseArguments)
## $ENV{ROOTSYS}/etc/cmake/ROOTUseFile.cmake)
execute_process(COMMAND root-config --auxcflags
OUTPUT_VARIABLE ROOT_CXX_FLAGS)
### has a troublesome trailing \n
string(STRIP ${ROOT_CXX_FLAGS} ROOT_CXX_FLAGS)
MESSAGE("--DK2NU-- ROOT_CXX_FLAGS ${ROOT_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${ROOT_CXX_FLAGS})
include(CMakeParseArguments)
find_library(ROOT_Physics_LIBRARY NAMES Physics PATHS
$ENV{ROOTSYS}/lib NO_DEFAULT_PATH )
find_library(ROOT_Matrix_LIBRARY NAMES Matrix PATHS
$ENV{ROOTSYS}/lib NO_DEFAULT_PATH )
else()
MESSAGE("--DK2NU-- start ROOT 6 config")
# don't know who defines the ${ROOT_DIR} used here
# seems to be $ENV{ROOTSYS}/cmake
include(${ROOT_DIR}/ROOTUseFile.cmake)
endif()
MESSAGE("--DK2NU-- finish ROOT X config")
if( WITH_TBB )
MESSAGE("--DK2NU-- enabled WITH_TBB")
find_library(TBB_LIBRARY NAMES tbb PATHS ENV TBB_LIB NO_DEFAULT_PATH )
# ROOT_Imt_LIBRARY = implicit multi-threading
set(ADD_ROOT_Imt_LIBRARY ${ROOT_Imt_LIBRARY})
else()
MESSAGE("--DK2NU-- WITH_TBB disabled")
set(TBB_LIBRARY "")
set(ADD_ROOT_Imt_LIBRARY "")
endif()
#----------------------------------------------------------------------------
if( ${ROOT_MAJOR_VERSION} LESS 6 )
#### / ) # add abs path for find_file() in FindROOT.cmake
set(ROOT5_NEEDS_FULL_PATH / )
endif()
MESSAGE("====> PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}")
set(INCLUDE_DIRECTORIES ${PROJECT_SOURCE_DIR}/..
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/dk2nu
$${ROOT_INCLUDE_DIR}
${ROOT5_NEEDS_FULL_PATH} )
set(GENIE $ENV{GENIE})
if( GENIE_ONLY )
set(COPY_AUX OFF)
add_subdirectory(genie)
MESSAGE("--DK2NU-- Disabled dk2nu tree (dk2nudata) building")
else()
add_subdirectory(tree)
if ( NOT WITH_GENIE )
MESSAGE("--DK2NU-- Disabled GENIE flux driver building")
else()
add_subdirectory(genie)
MESSAGE("--DK2NU-- Both tree & GENIE flux driver building enabled")
endif()
endif()
#----------------------------------------------------------------------------
# Install support files and scripts
if(COPY_AUX)
# install(FILES README DESTINATION doc RENAME dk2nu.README)
install(FILES etc/locations.txt
etc/NuMIlocations.txt
etc/LBNElocations.txt
DESTINATION etc)
install(FILES scripts/load_dk2nu.C
DESTINATION scripts)
install(FILES scripts/convert/common_convert.C
DESTINATION scripts/convert)
install(FILES scripts/convert/aux/mkgclasses3.sh
DESTINATION scripts/convert/aux)
install(FILES scripts/convert/g3numi/g3numi.C
scripts/convert/g3numi/g3numi.h
DESTINATION scripts/convert/g3numi)
install(FILES scripts/convert/g4numi/g4numi.C
scripts/convert/g4numi/g4numi.h
DESTINATION scripts/convert/g4numi)
install(FILES scripts/convert/g4minerva/g4minerva.C
scripts/convert/g4minerva/g4minerva.h
scripts/convert/g4minerva/convert_g4minerva.C
DESTINATION scripts/convert/g4minerva)
install(FILES scripts/convert/flugg/flugg.C
scripts/convert/flugg/flugg.h
scripts/convert/flugg/convert_flugg.C
DESTINATION scripts/convert/flugg)
install(FILES scripts/convert/g4lbne/g4lbne.C
scripts/convert/g4lbne/g4lbne.h
scripts/convert/g4lbne/convert_g4lbne.C
DESTINATION scripts/convert/g4lbne)
install(FILES scripts/examples/test_read_locations.C
scripts/examples/test_fill_dk2nu.C
scripts/examples/test_read_dk2nu.C
DESTINATION scripts/examples)
endif()