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