Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
255 lines (210 loc) · 9.7 KB
/
Copy pathCMakeLists.txt
File metadata and controls
255 lines (210 loc) · 9.7 KB
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# @authors S.V. Paulauskas, K. Smith, and C. Thronsberry
cmake_minimum_required(VERSION 3.5)
project(PAASS C CXX Fortran)
#Set the C++ standard to c++11.
set(CMAKE_CXX_STANDARD 11)
#Use rpath on Mac OS
set(CMAKE_MACOSX_RPATH TRUE)
if (CMAKE_COMPILER_IS_GNUCXX)
#Make compiler messages nice with colored tags.
if (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER "4.9")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=auto")
endif ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -fPIC")
endif ()
#if user does not specify prefix we assign it to the install directory
#@TODO I do not like the fact that it makes the install directory before I'm
#ready for it. There are cases where I do not want to actually install just
#build. This configuration adds additional junk to my directory that I may
#not actually want or need.
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
message(STATUS "Install Prefix not specified.")
file(MAKE_DIRECTORY install)
get_filename_component(INSTALL_DIR ${CMAKE_BINARY_DIR}/../install REALPATH)
set(CMAKE_INSTALL_PREFIX ${INSTALL_DIR} CACHE PATH "Install Prefix" FORCE)
endif ()
message(STATUS "Installing to ${CMAKE_INSTALL_PREFIX}")
#Define the default build type to be Release
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Build type, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
message(STATUS "Build type not defined, using default: ${CMAKE_BUILD_TYPE}")
endif (NOT CMAKE_BUILD_TYPE)
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
#Add additional CXX flags if we use the Debug option
if (CMAKE_BUILD_TYPE MATCHES "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
endif (CMAKE_BUILD_TYPE MATCHES "Debug")
#------------------------------------------------------------------------------
#We are going to include this additional module here since it could be useful
#when setting all of the following options.
include(CMakeDependentOption)
#Install options
option(PAASS_BUILD_ACQ "Build and install Acquisition software" ON)
option(PAASS_BUILD_SETUP "Include the older setup programs in installation" OFF)
if ( ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
option(PAASS_BUILD_SCAN_UTILITIES "Build and install the Analysis Utilities" OFF)
option(PAASS_BUILD_SHARED_LIBS "Install only scan libraries" OFF)
else()
option(PAASS_BUILD_SCAN_UTILITIES "Build and install the Analysis Utilities" ON)
option(PAASS_BUILD_SHARED_LIBS "Install only scan libraries" ON)
endif()
option(PAASS_BUILD_TESTS "Builds programs designed to test the package. Including UnitTest++ test." OFF)
option(PAASS_BUILD_UTKSCAN "Build utkscan" OFF)
option(PAASS_USE_DAMM "Use DAMM for MCA" ON)
option(PAASS_USE_NCURSES "Use ncurses for terminal" ON)
option(PAASS_USE_ROOT "Use ROOT (Currently REQUIRED!!)" ON)
mark_as_advanced(PAASS_USE_NCURSES)
mark_as_advanced(PAASS_USE_DAMM)
mark_as_advanced(PAASS_USE_ROOT)
option(PAASS_EXPORT_COMPILE_COMMANDS "CMAKE_EXPORT_COMPILE_COMMANDS WRAPPER" ON)
mark_as_advanced(PAASS_EXPORT_COMPILE_COMMANDS)
#Generate the compile_commands.json file which is used by VSCode (among others) to generate the clang autocomplete
#Needs the PAASS_EXPORT_COMPILE_COMMANDS wrapper because of the "FORCE" which is required to even set the var from CMakeList.txt,
#while maintaining the ability to toggle it on/off without wiping the build dir
if(PAASS_EXPORT_COMPILE_COMMANDS)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Generates compile_commands.json, needed for some IDEs among other things" FORCE)
else ()
set(CMAKE_EXPORT_COMPILE_COMMANDS OFF CACHE BOOL "Generates compile_commands.json, needed for some IDEs among other things" FORCE)
endif (PAASS_EXPORT_COMPILE_COMMANDS)
#------------------------------------------------------------------------------
#Definitions with compiler options
#The MCA will write DAMM histograms as output
if (PAASS_USE_DAMM)
add_definitions("-D USE_DAMM")
endif (PAASS_USE_DAMM)
#------------------------------------------------------------------------------
#Find packages needed for the software.
#Load additional find_package scripts.
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/Cmake/modules/")
#Find thread library for poll2 and scanLib
find_package(Threads REQUIRED)
#Find the PLX Library
find_package(PLX)
#Find the Pixie Firmware
find_package(XIA)
#Find curses library used for pretty much everything at this point.
if (PAASS_USE_NCURSES)
find_package(Curses REQUIRED)
endif (PAASS_USE_NCURSES)
if (CURSES_FOUND)
add_definitions("-D USE_NCURSES")
mark_as_advanced(FORCE CURSES_HAVE_CURSES_H CURSES_CURSES_H_PATH CURSES_FORM_LIBRARY)
else ()
message(STATUS "Curses unavailable, basic terminal will be used.")
set(PAASS_USE_NCURSES OFF)
endif (CURSES_FOUND)
#Find the UnitTest++ Package. This package can be obtained from
#https://github.com/unittest-cpp/unittest-cpp.git
if (PAASS_BUILD_TESTS)
find_package(UnitTest++ REQUIRED)
link_directories(${UNITTEST++_LIBRARY_DIR})
include_directories(${UNITTEST++_INCLUDE_DIR})
endif (PAASS_BUILD_TESTS)
if (PAASS_BUILD_ACQ)
if (NOT PAASS_BUILD_ACQ_ATTEMPTED AND NOT (PLX_FOUND AND XIA_FOUND))
set(PAASS_BUILD_ACQ OFF CACHE BOOL "Build and install Acquisition" FORCE)
else (PLX_FOUND OR XIA_FOUND)
#Find the PLX Library
find_package(PLX REQUIRED)
link_directories(${PLX_LIBRARY_DIR})
#Find the Pixie Firmware
find_package(XIA REQUIRED)
include_directories(${XIA_INCLUDE_DIR})
link_directories(${XIA_LIBRARY_DIR})
#Create pixie.cfg and copy slot_def.set as well as default.set to current.set
XIA_CONFIG()
endif ()
set(PAASS_BUILD_ACQ_ATTEMPTED ON CACHE INTERNAL "Build Suite Attempted")
endif (PAASS_BUILD_ACQ)
#Find ROOT if USE_ROOT was set.
if (PAASS_USE_ROOT)
find_package(ROOT REQUIRED COMPONENTS TreePlayer)
set(ROOTSYS $ENV{ROOTSYS} CACHE STRING "ROOT directory.")
find_program(ROOT_CONFIG_EXECUTABLE root-config PATHS ${ROOTSYS}/bin)
find_program(ROOTCINT_EXECUTABLE rootcint PATHS $ENV{ROOTSYS}/bin)
find_program(GENREFLEX_EXECUTABLE genreflex PATHS $ENV{ROOTSYS}/bin)
if (ROOT_CONFIG_EXECUTABLE)
execute_process(
COMMAND ${ROOT_CONFIG_EXECUTABLE} --prefix
OUTPUT_VARIABLE ROOTSYS
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND ${ROOT_CONFIG_EXECUTABLE} --version
OUTPUT_VARIABLE ROOT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND ${ROOT_CONFIG_EXECUTABLE} --incdir
OUTPUT_VARIABLE ROOT_INCLUDE_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND ${ROOT_CONFIG_EXECUTABLE} --libs
OUTPUT_VARIABLE ROOT_LIBRARIES
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND ${ROOT_CONFIG_EXECUTABLE} --glibs
OUTPUT_VARIABLE ROOT_GUI_LIBRARIES
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(ROOT_LIBRARY_DIR ${ROOTSYS}/lib)
execute_process(
COMMAND ${ROOT_CONFIG_EXECUTABLE} --has-minuit2
OUTPUT_VARIABLE ROOT_HAS_MINUIT2
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND ${ROOT_CONFIG_EXECUTABLE} --has-cxx17
OUTPUT_VARIABLE ROOT_HAS_CXX17)
execute_process(
COMMAND ${ROOT_CONFIG_EXECUTABLE} --has-cxx14
OUTPUT_VARIABLE ROOT_HAS_CXX14)
execute_process(
COMMAND ${ROOT_CONFIG_EXECUTABLE} --has-cxx11
OUTPUT_VARIABLE ROOT_HAS_CXX11)
endif ()
if (${ROOT_VERSION} VERSION_LESS "6.10")
message(FATAL_ERROR "Minimum ROOT version is 6.10.00.")
endif (${ROOT_VERSION} VERSION_LESS "6.10")
mark_as_advanced(FORCE GENREFLEX_EXECUTABLE ROOTCINT_EXECUTABLE ROOT_CONFIG_EXECUTABLE)
if ( ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
include_directories(${ROOT_INCLUDE_DIR})
link_directories(${ROOT_LIBRARY_DIR})
else()
include_directories(SYSTEM ${ROOT_INCLUDE_DIR})
link_directories(SYSTEM ${ROOT_LIBRARY_DIR})
endif()
add_definitions("-D USE_ROOT")
add_definitions("-D useroot")
if (ROOT_HAS_CXX11 MATCHES "yes")
message(STATUS "ROOT was built with cxx11. Setting CMAKE_CXX_STANDARD to match")
set(CMAKE_CXX_STANDARD 11)
elseif (ROOT_HAS_CXX14 MATCHES "yes")
message(STATUS "ROOT was built with cxx14. Setting CMAKE_CXX_STANDARD to match")
set(CMAKE_CXX_STANDARD 14)
elseif (ROOT_HAS_CXX17 MATCHES "yes")
message(STATUS "ROOT was built with cxx17. Setting CMAKE_CXX_STANDARD to match")
set(CMAKE_CXX_STANDARD 17)
endif()
endif (PAASS_USE_ROOT)
#------------------------------------------------------------------------------
#Put all the include directories that we might need at this point. Ensure
#that the Third party includes come before the Resources.
include_directories(ThirdParty/include)
include_directories(Resources/include)
include_directories(Core/include)
#Build the Third party software since it's useful for other programs
add_subdirectory(ThirdParty)
#Add the resources to compilation
add_subdirectory(Resources)
#Build the PaassCoreLibrary.
add_subdirectory(Core)
#Build Acquisition software, we don't have this broken into as fine of a
#granularity as the Analysis software, so we just wrap the whole thing in an if.
if (PAASS_BUILD_ACQ)
add_subdirectory(Acquisition)
else ()
#Ensure that we can still build set2* even when BUILD_ACQ is off
add_subdirectory(Acquisition/set2root)
endif (PAASS_BUILD_ACQ)
#Build any of the analysis related things that we need to build.
add_subdirectory(Analysis)
#Build/install the miscellaneous stuff
add_subdirectory(Share)