1 | # *********************************
|
---|
2 | # ************ cmake **************
|
---|
3 | # *********************************
|
---|
4 | CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
---|
5 | CMAKE_POLICY(SET CMP0043 NEW)
|
---|
6 | CMAKE_POLICY(SET CMP0048 NEW)
|
---|
7 |
|
---|
8 | # Enable debug symbols by default
|
---|
9 | # must be done before project() statement
|
---|
10 | SET(CMAKE_BUILD_TYPE_INIT Release)
|
---|
11 | # (you can also set it on the command line: -D CMAKE_BUILD_TYPE=Release)
|
---|
12 |
|
---|
13 | # Enable CLANG as default compilers, to change this use
|
---|
14 | # cmake -DCMAKE_C_COMPILER=cc -DCMAKE_CXX_COMPILER=c++
|
---|
15 | # Note that if compilers are switched on the fly,
|
---|
16 | # the cache is deleted
|
---|
17 | IF(NOT DEFINED CMAKE_C_COMPILER)
|
---|
18 | FIND_PROGRAM(CMAKE_C_COMPILER NAMES $ENV{CC} clang gcc cc PATHS ENV PATH NO_DEFAULT_PATH DOC "C Compiler")
|
---|
19 | ENDIF()
|
---|
20 | IF(NOT DEFINED CMAKE_CXX_COMPILER)
|
---|
21 | FIND_PROGRAM(CMAKE_CXX_COMPILER NAMES $ENV{CXX} clang++ g++ c++ PATHS ENV PATH NO_DEFAULT_PATH DOC "C++ Compiler")
|
---|
22 | ENDIF()
|
---|
23 |
|
---|
24 | #SET(CMAKE_VERBOSE_MAKEFILE ON)
|
---|
25 |
|
---|
26 | # To check for an include file you do this:
|
---|
27 | #CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H)
|
---|
28 | # To check the size of a primitive type:
|
---|
29 | #CHECK_TYPE_SIZE("int" SIZEOF_INT)
|
---|
30 |
|
---|
31 |
|
---|
32 |
|
---|
33 | # *********************************
|
---|
34 | # ************ Project ************
|
---|
35 | # *********************************
|
---|
36 |
|
---|
37 | STRING(TIMESTAMP VERSION %y.%U.%w.%H UTC)
|
---|
38 |
|
---|
39 | MESSAGE(STATUS "Mars V${VERSION}")
|
---|
40 |
|
---|
41 | PROJECT(mars VERSION ${VERSION})
|
---|
42 |
|
---|
43 | INCLUDE(GNUInstallDirs)
|
---|
44 |
|
---|
45 | # ======== For config.h.in =========
|
---|
46 | SET(PACKAGE_MAINTAINER "Thomas Bretz")
|
---|
47 | SET(PACKAGE_BUGREPORT "tbretz@physik.rwth-aachen.de")
|
---|
48 | SET(PACKAGE_URL "https://www.fact-project.org")
|
---|
49 |
|
---|
50 |
|
---|
51 |
|
---|
52 | # *********************************
|
---|
53 | # ********* Requirements **********
|
---|
54 | # *********************************
|
---|
55 |
|
---|
56 | # =========== help2man ============
|
---|
57 | FIND_PROGRAM(HELP2MAN_EXECUTABLE help2man)
|
---|
58 |
|
---|
59 | # =========== pkg-config ============
|
---|
60 | FIND_PACKAGE(PkgConfig)
|
---|
61 | FIND_PACKAGE(PackageHandleStandardArgs)
|
---|
62 |
|
---|
63 |
|
---|
64 | # ============= libnova ==============
|
---|
65 |
|
---|
66 | PKG_CHECK_MODULES(Nova Nova)
|
---|
67 |
|
---|
68 | # Try to locate the package in the default path
|
---|
69 | # and in the path provided by pkg-config
|
---|
70 | FIND_PATH(NOVA_INCLUDE_DIR NAMES libnova/libnova.h PATHS ${NOVA_INCLUDE_DIRS})
|
---|
71 | FIND_LIBRARY(NOVA_LIBRARY NAMES nova PATHS ${NOVA_LIBRARY_DIRS})
|
---|
72 |
|
---|
73 | # Check if NOVA_LIBARARY and NOVA_INCLUDE_DIR is set
|
---|
74 | # Print a message otherwise
|
---|
75 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(Nova DEFAULT_MSG NOVA_LIBRARY NOVA_INCLUDE_DIR)
|
---|
76 |
|
---|
77 | # Mark those variables to be displayed as 'advanced' in the GUI
|
---|
78 | MARK_AS_ADVANCED(NOVA_LIBRARY NOVA_INCLUDE_DIR)
|
---|
79 |
|
---|
80 | # handle success
|
---|
81 | IF(NOVA_FOUND AND NOT NOVA_FIND_QUIETLY)
|
---|
82 | MESSAGE(STATUS "Found Nova ${NOVA_LIBRARY} in ${NOVA_INCLUDE_DIR}")
|
---|
83 | ENDIF()
|
---|
84 |
|
---|
85 |
|
---|
86 | # ============== libz ================
|
---|
87 |
|
---|
88 | FIND_PACKAGE(ZLIB REQUIRED)
|
---|
89 |
|
---|
90 |
|
---|
91 | # =========== Enable C++11 ===========
|
---|
92 |
|
---|
93 | SET(CMAKE_CXX_STANDARD 11)
|
---|
94 | SET(CMAKE_CXX_FLAGS
|
---|
95 | "${CMAKE_CXX_FLAGS} -Wall -Winit-self -Wpointer-arith \
|
---|
96 | -Wcast-align -Wformat -Woverloaded-virtual \
|
---|
97 | -Wnon-virtual-dtor -Wshadow -fPIC") # -Wextra
|
---|
98 |
|
---|
99 | SET(CMAKE_CXX_FLAGS
|
---|
100 | "${CMAKE_CXX_FLAGS} \
|
---|
101 | -DMARSVER=\\\"1.0\\\" -D_REENTRANT -D__MARS__ -D__LINUX__ \
|
---|
102 | -DPACKAGE_VERSION=\\\"1.0\\\" -DREVISION=\\\"1.0\\\" \
|
---|
103 | -DPACKAGE_NAME=\\\"MARS\\\" -DHAVE_ZLIB")
|
---|
104 |
|
---|
105 |
|
---|
106 | # --------- config.h -------------
|
---|
107 |
|
---|
108 | CONFIGURE_FILE("${PROJECT_SOURCE_DIR}/cmake/root.rc.in" "${PROJECT_BINARY_DIR}/.rootrc")
|
---|
109 | CONFIGURE_FILE("${PROJECT_SOURCE_DIR}/cmake/rootlogon.C.in" "${PROJECT_BINARY_DIR}/rootlogon.C")
|
---|
110 |
|
---|
111 | #INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")
|
---|
112 |
|
---|
113 | SET(CMAKE_MODULE_PATH $ENV{ROOTSYS}/etc/cmake ${CMAKE_MODULE_PATH})
|
---|
114 |
|
---|
115 |
|
---|
116 | # You need to tell CMake where to find the ROOT installation. This can be done in a number of ways:
|
---|
117 | # - ROOT built with classic configure/make use the provided $ROOTSYS/etc/cmake/FindROOT.cmake
|
---|
118 | # - ROOT built with CMake. Add in CMAKE_PREFIX_PATH the installation prefix for ROOT
|
---|
119 | #LIST(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS})
|
---|
120 |
|
---|
121 | #---Locate the ROOT package and defines a number of variables (e.g. ROOT_INCLUDE_DIRS)
|
---|
122 |
|
---|
123 | # -lGui -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree
|
---|
124 | # -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread
|
---|
125 | # -lASImage -lMinuit -lHistPainter -lThread
|
---|
126 |
|
---|
127 | FIND_PACKAGE(ROOT REQUIRED COMPONENTS Gui Minuit ASImage HistPainter)
|
---|
128 |
|
---|
129 |
|
---|
130 | #MESSAGE("INCL_DIRS: ${ROOT_INCLUDE_DIRS}")
|
---|
131 | #MESSAGE("LIBS: ${ROOT_LIBRARIES}")
|
---|
132 | #MESSAGE("DEFS: ${ROOT_DEFINITIONS}")
|
---|
133 | #MESSAGE("CXXFLAGS: ${ROOT_CXX_FLAGS}")
|
---|
134 | #MESSAGE("CXFLAGS: ${ROOT_CC_FLAGS}")
|
---|
135 | #MESSAGE("FOUND: ${ROOT_FOUND}")
|
---|
136 | #MESSAGE("FILE: ${ROOT_USE_FILE}")
|
---|
137 | #MESSAGE("DIR: ${CMAKE_CURRENT_SOURCE_DIR}")
|
---|
138 | #ROOT_<library>_LIBRARY PATH Full path for each of the ROOT libraries listed in COMPONENTS
|
---|
139 | #ROOT_<command>_CMD PATH Full path for each ROOT executable (rootcling, root, hadd, etc.)
|
---|
140 | #ROOT_<option>_FOUND BOOL True for each enabled build option (e.g. cocoa, python, xrootd, etc.)
|
---|
141 |
|
---|
142 | #---Define useful ROOT functions and macros (e.g. ROOT_GENERATE_DICTIONARY)
|
---|
143 | #INCLUDE(${ROOT_USE_FILE})
|
---|
144 |
|
---|
145 | # function ROOT_GENERATE_DICTIONARY( dictionary
|
---|
146 | # header1 header2 ...
|
---|
147 | # LINKDEF linkdef1 ...
|
---|
148 | # OPTIONS opt1...)
|
---|
149 |
|
---|
150 | # -------------------------------------------------------
|
---|
151 |
|
---|
152 | FILE(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/dictionary)
|
---|
153 |
|
---|
154 | MACRO(SRCFILES subdir)
|
---|
155 |
|
---|
156 | EXECUTE_PROCESS(COMMAND
|
---|
157 | ${PROJECT_SOURCE_DIR}/Makefile.extract.sh ${subdir}
|
---|
158 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/${subdir}
|
---|
159 | OUTPUT_VARIABLE _HEADERS)
|
---|
160 |
|
---|
161 | SEPARATE_ARGUMENTS(_HEADERS)
|
---|
162 |
|
---|
163 | LIST(GET _HEADERS 0 _CINT)
|
---|
164 | LIST(REMOVE_AT _HEADERS 0)
|
---|
165 |
|
---|
166 | SET(_SRCLIST ${_HEADERS})
|
---|
167 |
|
---|
168 | STRING(REPLACE "${subdir}/" " " _HEADERS ${_HEADERS}) # Remove directory
|
---|
169 | STRING(REPLACE ".cc" ".h" _HEADERS ${_HEADERS}) # change extension
|
---|
170 | STRING(REPLACE ".cxx" ".hxx" _HEADERS ${_HEADERS}) # special for files in mmc
|
---|
171 |
|
---|
172 | SEPARATE_ARGUMENTS(_HEADERS)
|
---|
173 |
|
---|
174 | ROOT_GENERATE_DICTIONARY(dictionary/${_CINT} ${_HEADERS} ${_CINT}Incl.h LINKDEF ${_CINT}LinkDef.h OPTIONS -p)
|
---|
175 | TARGET_SOURCES(mars PRIVATE dictionary/${_CINT}.cxx ${_SRCLIST})
|
---|
176 |
|
---|
177 | INSTALL(DIRECTORY ${subdir}/ DESTINATION "include" FILES_MATCHING PATTERN "*.h")
|
---|
178 |
|
---|
179 | ENDMACRO()
|
---|
180 |
|
---|
181 | # -------------------------------------------------------
|
---|
182 |
|
---|
183 | #SET(DIRECTORIES mmc)
|
---|
184 |
|
---|
185 | SET(DIRECTORIES
|
---|
186 | manalysis
|
---|
187 | mastro
|
---|
188 | mbadpixels
|
---|
189 | mbase
|
---|
190 | mcalib
|
---|
191 | mcamera
|
---|
192 | mcorsika
|
---|
193 | mdata
|
---|
194 | mdrs
|
---|
195 | melectronics
|
---|
196 | mextralgo
|
---|
197 | mfbase
|
---|
198 | mfileio
|
---|
199 | mfilter
|
---|
200 | mgeom
|
---|
201 | mgui
|
---|
202 | mhbase
|
---|
203 | mhcalib
|
---|
204 | mhflux
|
---|
205 | mhft
|
---|
206 | mhist
|
---|
207 | mhvstime
|
---|
208 | mimage
|
---|
209 | mjobs
|
---|
210 | mjoptim
|
---|
211 | mjtrain
|
---|
212 | mmain
|
---|
213 | mmc
|
---|
214 | mmovie
|
---|
215 | mmuon
|
---|
216 | mpedestal
|
---|
217 | mpointing
|
---|
218 | mranforest
|
---|
219 | mraw
|
---|
220 | mreport
|
---|
221 | msignal
|
---|
222 | msim
|
---|
223 | msimcamera
|
---|
224 | msimreflector
|
---|
225 | msql
|
---|
226 | mtools
|
---|
227 | mtrigger
|
---|
228 | )
|
---|
229 |
|
---|
230 | INCLUDE_DIRECTORIES(${ROOT_INCLUDE_DIRS} ${DIRECTORIES} mcore .)
|
---|
231 |
|
---|
232 | ROOT_GENERATE_DICTIONARY(dictionary/MARS
|
---|
233 | factofits.h
|
---|
234 | factfits.h
|
---|
235 | DrsCalib.h
|
---|
236 | PixelMap.h
|
---|
237 | Interpolator2D.h
|
---|
238 | nova.h
|
---|
239 | Prediction.h
|
---|
240 | MIncl.h
|
---|
241 | LINKDEF MLinkDef.h
|
---|
242 | OPTIONS -p -D__MARS__ -DHAVE_ZLIB)
|
---|
243 |
|
---|
244 | ADD_LIBRARY(mars SHARED dictionary/MARS.cxx) # CMAKE_POSITION_INDEPENDENT_CODE
|
---|
245 | TARGET_LINK_LIBRARIES(mars
|
---|
246 | ZLIB::ZLIB
|
---|
247 | ${NOVA_LIBRARY}
|
---|
248 | ${ROOT_LIBRARIES})
|
---|
249 |
|
---|
250 | ADD_EXECUTABLE(showplot showplot.cc)
|
---|
251 | ADD_EXECUTABLE(showlog showplot.cc)
|
---|
252 | ADD_EXECUTABLE(ceres ceres.cc)
|
---|
253 | TARGET_LINK_LIBRARIES(showplot mars ${ROOT_LIBRARIES})
|
---|
254 | TARGET_LINK_LIBRARIES(showlog mars ${ROOT_LIBRARIES})
|
---|
255 | TARGET_LINK_LIBRARIES(ceres mars ${ROOT_LIBRARIES})
|
---|
256 |
|
---|
257 |
|
---|
258 | FOREACH(DIR ${DIRECTORIES})
|
---|
259 | MESSAGE(STATUS "Reading source list from ${DIR}/Makefile")
|
---|
260 | SRCFILES(${DIR})
|
---|
261 | ENDFOREACH()
|
---|
262 |
|
---|
263 | # rootlogon.C finds the shared object only if the libmars.so is in the same directory than the dictionary files
|
---|
264 | # there is a way to create a map file with rootcling - but I haven#t yet fugured out how. Note that a link is not enough
|
---|
265 | ADD_CUSTOM_COMMAND(TARGET mars POST_BUILD
|
---|
266 | COMMAND cp -f ${PROJECT_BINARY_DIR}/libmars.so ${PROJECT_BINARY_DIR}/dictionary/libmars.so
|
---|
267 | COMMENT "Copying libmars.so to ${PROJECT_BINARY_DIR}/dictionary")
|
---|
268 |
|
---|
269 | #---Create a shared library with geneated dictionary
|
---|
270 | #ADD_LIBRARY(Event SHARED Event.cxx G__Event.cxx)
|
---|
271 | #TARGET_LINK_LIBRARIES(Event ${ROOT_LIBRARIES})
|
---|
272 |
|
---|
273 | #---Create a main program using the library
|
---|
274 | #ADD_EXECUTABLE(Main MainEvent.cxx)
|
---|
275 | #TARGET_LINK_LIBRARIES(Main Event)
|
---|
276 |
|
---|
277 |
|
---|
278 | # *********************************
|
---|
279 | # ************ Packaging **********
|
---|
280 | # *********************************
|
---|
281 |
|
---|
282 | #SET(PKG_SHARE "${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}")
|
---|
283 | #SET(PKG_APPS "${CMAKE_INSTALL_DATAROOTDIR}/applications")
|
---|
284 | #SET(PKG_PIXMAPS "${CMAKE_INSTALL_DATAROOTDIR}/pixmaps")
|
---|
285 |
|
---|
286 | # ====== Installation targets =====
|
---|
287 |
|
---|
288 | #INSTALL(TARGETS mars DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
---|
289 | INSTALL(TARGETS mars DESTINATION ".")
|
---|
290 | INSTALL(TARGETS showplot DESTINATION ".")
|
---|
291 | INSTALL(TARGETS showlog DESTINATION ".")
|
---|
292 | INSTALL(TARGETS ceres DESTINATION ".")
|
---|
293 | INSTALL(FILES .rootrc DESTINATION ".")
|
---|
294 | INSTALL(DIRECTORY macros DESTINATION "." FILES_MATCHING PATTERN "*.C")
|
---|
295 | INSTALL(DIRECTORY fact DESTINATION "." FILES_MATCHING PATTERN "*.C")
|
---|
296 | INSTALL(DIRECTORY datacenter DESTINATION ".")
|
---|
297 | INSTALL(DIRECTORY scripts DESTINATION ".")
|
---|
298 | INSTALL(DIRECTORY resources DESTINATION "." FILES_MATCHING PATTERN "*.rc" PATTERN "*.txt")
|
---|
299 | INSTALL(DIRECTORY resmc DESTINATION "." FILES_MATCHING PATTERN "*" )
|
---|
300 | INSTALL(DIRECTORY mcore/ DESTINATION "include" FILES_MATCHING PATTERN "*.h")
|
---|
301 |
|
---|
302 |
|
---|
303 | # ======== General packaging ======
|
---|
304 | # https://cmake.org/cmake/help/latest/module/CPack.html
|
---|
305 |
|
---|
306 | INCLUDE(InstallRequiredSystemLibraries)
|
---|
307 |
|
---|
308 | # SET(CPACK_STRIP_FILES ON) # Strip debug sysmbold from files
|
---|
309 |
|
---|
310 | SET(CPACK_PACKAGE_VERSION "${mars_VERSION}")
|
---|
311 | SET(CPACK_PACKAGE_CONTACT "${PACKAGE_BUGREPORT}")
|
---|
312 | SET(CPACK_PACKAGE_MAINTAINER "${PACKAGE_MAINTAINER}")
|
---|
313 | #SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
|
---|
314 | #SET(CPACK_PACKAGE_VENDOR "Me, myself, and I")
|
---|
315 |
|
---|
316 |
|
---|
317 | SET(CPACK_SOURCE_IGNORE_FILES "/old/;/build/;/[.].*/;/autom4te[.]cache/;.*~;.log$")
|
---|
318 |
|
---|
319 | # Maybe the text displayed in synaptic?
|
---|
320 | #SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README")
|
---|
321 | SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MARS - Environment")
|
---|
322 | #CPACK_RESOURCE_FILE_README ReadMe file to be embedded in the installer.
|
---|
323 |
|
---|
324 | SET(CPACK_GENERATOR TBZ2) # TGZ DEB
|
---|
325 | #SET(CPACK_SOURCE_GENERATOR TBZ2) # TGZ
|
---|
326 | #SET(CPACK_PROJECT_CONFIG_FILE ${CMAKE_SOURCE_DIR}/cmake/Package.txt)
|
---|
327 | #SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt")
|
---|
328 |
|
---|
329 |
|
---|
330 | # ======== Debian packaging =======
|
---|
331 | # https://cmake.org/cmake/help/latest/module/CPackDeb.html
|
---|
332 | # https://www.debian.org/doc/debian-policy
|
---|
333 |
|
---|
334 | #SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libao4 (>=1.0), libsfm-system2.3v5 (>=2.3), libsfml-graphicsv2.3v5 (>=2.3), libsfml-audio2.3v5 (>=2.3), libsfm-window2.3v5 (>2.3)")
|
---|
335 | SET(CPACK_DEBIAN_PACKAGE_SHLIBDEPS 1) # generate better (atomatic?) dependecies
|
---|
336 | SET(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY ">=")
|
---|
337 | SET(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE)
|
---|
338 | SET(CPACK_DEBIAN_PACKAGE_SECTION utils)
|
---|
339 | SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "${PACKAGE_URL}")
|
---|
340 | SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION
|
---|
341 | "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}
|
---|
342 | This package contains the MARS Analysis Environment.")
|
---|
343 | #indent the long description with spaces
|
---|
344 |
|
---|
345 | #CPACK_INSTALL_CMAKE_PROJECTS
|
---|
346 | #List of four values that specify what project to install. Build directory, Project Name, Project Component, Directory.
|
---|
347 |
|
---|
348 | INCLUDE(CPack)
|
---|