source: trunk/Mars/CMakeLists.txt@ 20020

Last change on this file since 20020 was 20009, checked in by tbretz, 4 years ago
Allow compilation also without libnova support.
File size: 20.8 KB
Line 
1# *********************************
2# ************ cmake **************
3# *********************************
4CMAKE_MINIMUM_REQUIRED(VERSION 3.1 FATAL_ERROR)
5CMAKE_POLICY(SET CMP0043 NEW)
6CMAKE_POLICY(SET CMP0048 NEW)
7
8# TARGET_SOURCES requires v3.1
9
10# Enable debug symbols by default
11# must be done before project() statement
12SET(CMAKE_BUILD_TYPE_INIT Release)
13# (you can also set it on the command line: -D CMAKE_BUILD_TYPE=Release)
14
15# Enable CLANG as default compilers, to change this use
16# cmake -DCMAKE_C_COMPILER=cc -DCMAKE_CXX_COMPILER=c++
17# Note that if compilers are switched on the fly,
18# the cache is deleted
19IF(NOT DEFINED CMAKE_C_COMPILER)
20 FIND_PROGRAM(CMAKE_C_COMPILER NAMES $ENV{CC} clang gcc cc PATHS ENV PATH NO_DEFAULT_PATH DOC "C Compiler")
21ENDIF()
22IF(NOT DEFINED CMAKE_CXX_COMPILER)
23 FIND_PROGRAM(CMAKE_CXX_COMPILER NAMES $ENV{CXX} clang++ g++ c++ PATHS ENV PATH NO_DEFAULT_PATH DOC "C++ Compiler")
24ENDIF()
25
26#SET(CMAKE_VERBOSE_MAKEFILE ON)
27
28# To check for an include file you do this:
29#CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H)
30# To check the size of a primitive type:
31#CHECK_TYPE_SIZE("int" SIZEOF_INT)
32
33# *********************************
34# ************ Project ************
35# *********************************
36
37STRING(TIMESTAMP VERSION %y.%U.%w.%H UTC)
38
39MESSAGE(STATUS "Cmake V${CMAKE_VERSION}")
40MESSAGE(STATUS "Mars V${VERSION}")
41
42PROJECT(mars VERSION ${VERSION})
43
44INCLUDE(GNUInstallDirs)
45
46IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
47 SET(GCC_MIN 4.4.7)
48 IF (CMAKE_C_COMPILER_VERSION VERSION_LESS GCC_MIN OR
49 CMAKE_CXX_COMPILER_VERSION VERSION_LESS GCC_MIN)
50 MESSAGE(FATAL_ERROR "\n gcc/g++ ${GCC_MIN} or higher is required.\n You are running version ${CMAKE_C_COMPILER_VERSION}/${CMAKE_CXX_COMPILER_VERSION}.")
51 ENDIF()
52ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
53 SET(CLANG_MIN 3.5)
54 IF (CMAKE_C_COMPILER_VERSION VERSION_LESS CLANG_MIN OR
55 CMAKE_CXX_COMPILER_VERSION VERSION_LESS CLANG_MIN)
56 MESSAGE(FATAL_ERROR "\n clang/clang++ ${CLANG_MIN} or higher is required.\n You are running version ${CMAKE_C_COMPILER_VERSION}/${CMAKE_CXX_COMPILER_VERSION}.")
57 ENDIF()
58ELSE()
59 MESSAGE(WARNING "You are using an unsupported compiler! Compilation has only been tested only with clang/clang++ and gcc/g++.")
60ENDIF()
61
62# ======== For config.h.in =========
63SET(PACKAGE_MAINTAINER "Thomas Bretz")
64SET(PACKAGE_BUGREPORT "tbretz@physik.rwth-aachen.de")
65SET(PACKAGE_URL "https://www.fact-project.org")
66
67FIND_PROGRAM(LSB_RELEASE_EXE NAMES lsb_release)
68IF (DEFINED LSB_RELEASE_EXE)
69 EXECUTE_PROCESS(COMMAND ${LSB_RELEASE_EXE} -d OUTPUT_VARIABLE LSB_RELEASE OUTPUT_STRIP_TRAILING_WHITESPACE)
70 MESSAGE(STATUS ${LSB_RELEASE})
71ENDIF()
72
73# *********************************
74# ********* Requirements **********
75# *********************************
76
77# Inlclude the main source AND build dir itself
78#SET(CMAKE_INCLUDE_CURRENT_DIR ON)
79SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
80
81# =========== help2man ============
82FIND_PROGRAM(HELP2MAN_EXECUTABLE help2man)
83
84# =========== pkg-config ============
85FIND_PACKAGE(PkgConfig)
86FIND_PACKAGE(PackageHandleStandardArgs)
87
88
89# ============= libnova ==============
90
91PKG_CHECK_MODULES(Nova QUIET Nova)
92
93# Try to locate the package in the default path
94# and in the path provided by pkg-config
95FIND_PATH(NOVA_INCLUDE_DIR NAMES libnova/libnova.h PATHS ${NOVA_INCLUDE_DIRS})
96FIND_LIBRARY(NOVA_LIBRARY NAMES nova PATHS ${NOVA_LIBRARY_DIRS})
97
98# Check if NOVA_LIBARARY and NOVA_INCLUDE_DIR is set
99# Print a message otherwise
100FIND_PACKAGE_HANDLE_STANDARD_ARGS(Nova DEFAULT_MSG NOVA_LIBRARY NOVA_INCLUDE_DIR)
101
102# Mark those variables to be displayed as 'advanced' in the GUI
103MARK_AS_ADVANCED(NOVA_LIBRARY NOVA_INCLUDE_DIR)
104
105# handle success
106FIND_PACKAGE_MESSAGE(NovaInc "Found Nova headers in ${NOVA_INCLUDE_DIR}" "[${NOVA_LIBRARY}][${NOVA_INCLUDE_DIR}]")
107
108IF(NOT NOVA_FOUND)
109 MESSAGE(WARNING "You are compiling without support for libnova!")
110ENDIF()
111
112
113# ============== libz ================
114
115FIND_PACKAGE(ZLIB REQUIRED)
116
117# *********************************
118# ********** HEAL Pix **********
119# *********************************
120
121SET(HEALPIX_PREFIX "${CMAKE_SOURCE_DIR}/RootHealPix" CACHE FILEPATH "Base path to the RootHealPix code.")
122
123IF(EXISTS ${HEALPIX_PREFIX})
124 FIND_PACKAGE_MESSAGE(HealPixPrefix "RootHealPix prefix: ${HEALPIX_PREFIX}" "[${HEALPIX_PREFIX}]")
125 SET(FOUND_HEALPIX ON)
126ENDIF()
127
128# ============== ROOT ================
129
130FIND_PROGRAM(ROOTCONFIG_EXECUTABLE NAMES root-config)
131FIND_PACKAGE_HANDLE_STANDARD_ARGS(root-config DEFAULT_MSG ROOTCONFIG_EXECUTABLE)
132IF(NOT ROOTCONFIG_EXECUTABLE)
133 MESSAGE(FATAL_ERROR "Please make sure `root-config` is accessible in your path. In case of an installation from source, you might need to source\n . [path-to-root]/bin/thisroot.sh")
134ENDIF()
135
136# You need to tell CMake where to find the ROOT installation. This can be done in a number of ways:
137# - ROOT built with classic configure/make use the provided $ROOTSYS/etc/cmake/FindROOT.cmake
138# - ROOT built with CMake. Add in CMAKE_PREFIX_PATH the installation prefix for ROOT
139IF(EXISTS $ENV{ROOTSYS}/ROOTConfig.cmake)
140 IF(NOT DEFINED ENV{CMAKE_PREFIX_PATH})
141 LIST(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS})
142 ENDIF()
143ENDIF()
144SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "$ENV{ROOTSYS}/etc/cmake")
145
146SET(ROOT_PACKAGES Gui Minuit ASImage HistPainter)
147IF(FOUND_HEALPIX)
148 SET(ROOT_PACKAGES ${ROOT_PACKAGES} FITSIO)
149ENDIF()
150
151#---Locate the ROOT package and defines a number of variables (e.g. ROOT_INCLUDE_DIRS)
152#SET(ROOT_CONFIG_DEBUG 1)
153FIND_PACKAGE(ROOT REQUIRED COMPONENTS ${ROOT_PACKAGES})
154
155IF(NOT DEFINED ROOT_CONFIG_EXECUTABLE)
156 FIND_PACKAGE_MESSAGE(RootFound "Found ROOT: ${ROOT_INCLUDE_DIRS}" "[${ROOT_INCLUDE_DIRS}][${ROOT_LIBRARY_DIR}][${ROOT_VERSION}]")
157ENDIF()
158
159#---Define useful ROOT functions and macros (e.g. ROOT_GENERATE_DICTIONARY)
160FIND_PACKAGE_MESSAGE(RootInclude "Setup ROOT: [${ROOT_VERSION}] ${ROOT_USE_FILE}" "[${ROOT_VERSION}][${ROOT_USE_FILE}]")
161IF(DEFINED ROOT_USE_FILE)
162 INCLUDE(${ROOT_USE_FILE})
163ELSE()
164 # From RootUseFile.cmake (root 6)
165 INCLUDE_DIRECTORIES(${ROOT_INCLUDE_DIRS})
166 LINK_DIRECTORIES(${ROOT_LIBRARY_DIR})
167 ADD_DEFINITIONS(${ROOT_DEFINITIONS})
168 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ROOT_CXX_FLAGS}")
169 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ROOT_C_FLAGS}")
170 SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${ROOT_fortran_FLAGS}")
171ENDIF()
172
173# Replace separators to make the version consistent
174# (older version might use the '/')
175STRING(REPLACE "/" "." ROOT_VERSION ${ROOT_VERSION})
176
177# This happens when root is used from its build directory
178# Create the version components manually
179IF(ROOT_VERSION AND NOT ROOT_VERSION_MAJOR)
180 # Create a list of components
181 STRING(REPLACE "." ";" ROOT_VERSION_LIST ${ROOT_VERSION})
182 # Split version string
183 LIST(GET ROOT_VERSION_LIST 0 ROOT_VERSION_MAJOR)
184 LIST(GET ROOT_VERSION_LIST 1 ROOT_VERSION_MINOR)
185 LIST(GET ROOT_VERSION_LIST 2 ROOT_VERSION_PATCH)
186 # Remove trailing 0's
187 STRING(REGEX REPLACE "0+([0-9]+)" "\\1" ROOT_VERSION_MINOR ${ROOT_VERSION_MINOR})
188 STRING(REGEX REPLACE "0+([0-9]+)" "\\1" ROOT_VERSION_PATCH ${ROOT_VERSION_PATCH})
189ENDIF()
190
191# Is this is a local or a global installation?
192IF(DEFINED ENV{ROOTSYS})
193 IF(ROOTSYS AND NOT ROOTSYS STREQUAL "$ENV{ROOTSYS}")
194 MESSAGE(WARNING
195 " \n"
196 " ROOT Location changed!\n"
197 " Present ROOTSYS: $ENV{ROOTSYS}\n"
198 " Previous ROOTSYS: ${ROOTSYS}")
199 FILE(REMOVE thisroot.sh)
200 FILE(REMOVE root)
201 ENDIF()
202
203 SET(ROOTSYS $ENV{ROOTSYS} CACHE INTERNAL "Internal variable to check for consistency in ROOTSYS")
204
205 # For convenience and easy tracking
206 ADD_CUSTOM_COMMAND(OUTPUT thisroot.sh COMMAND ln -sf ${ROOTSYS}/bin/thisroot.sh VERBATIM)
207 ADD_CUSTOM_COMMAND(OUTPUT root COMMAND ln -sf ${ROOTSYS}/bin/root VERBATIM)
208 ADD_CUSTOM_TARGET(thisroot ALL DEPENDS thisroot.sh)
209 ADD_CUSTOM_TARGET(lnroot ALL DEPENDS root)
210ENDIF()
211
212IF(ROOTVER AND NOT ROOTVER VERSION_EQUAL ROOT_VERSION)
213 MESSAGE(WARNING
214 " \n"
215 " ROOT Version changed!\n"
216 " Present: ${ROOT_VERSION}\n"
217 " Previous: ${ROOTVER}")
218ENDIF()
219
220SET(ROOTVER ${ROOT_VERSION} CACHE INTERNAL "Internal variable to check for consistency of root version")
221
222IF(ROOT_VERSION VERSION_LESS 6.20)
223 SET(ROOT_DICTIONARY_OPTION -p)
224ENDIF()
225
226
227
228# -lGui -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree
229# -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread
230# -lASImage -lMinuit -lHistPainter -lThread
231
232#MESSAGE("INCL_DIRS: ${ROOT_INCLUDE_DIRS}")
233#MESSAGE("LIBS: ${ROOT_LIBRARIES}")
234#MESSAGE("DEFS: ${ROOT_DEFINITIONS}")
235#MESSAGE("CXXFLAGS: ${ROOT_CXX_FLAGS}")
236#MESSAGE("CXFLAGS: ${ROOT_CC_FLAGS}")
237#MESSAGE("FOUND: ${ROOT_FOUND}")
238#MESSAGE("FILE: ${ROOT_USE_FILE}")
239#MESSAGE("DIR: ${CMAKE_CURRENT_SOURCE_DIR}")
240#ROOT_<library>_LIBRARY PATH Full path for each of the ROOT libraries listed in COMPONENTS
241#ROOT_<command>_CMD PATH Full path for each ROOT executable (rootcling, root, hadd, etc.)
242#ROOT_<option>_FOUND BOOL True for each enabled build option (e.g. cocoa, python, xrootd, etc.)
243
244# function ROOT_GENERATE_DICTIONARY( dictionary
245# header1 header2 ...
246# LINKDEF linkdef1 ...
247# OPTIONS opt1...)
248
249# *********************************
250# ********** Observatory **********
251# *********************************
252
253SET(OBSERVATORY "ORM" CACHE STRING "Select the observatory location (ORM, HAWC, SPM, RWTH: see nova.h)")
254
255IF(NOT OBSERVATORY STREQUAL "ORM" AND
256 NOT OBSERVATORY STREQUAL "HAWC" AND
257 NOT OBSERVATORY STREQUAL "SPM" AND
258 NOT OBSERVATORY STREQUAL "RWTH")
259 MESSAGE(FATAL_ERROR "OBSERVATORY=${OBSERVATORY} invalid. Only ORM, HAWC, SPM and RWTH allowd!")
260ENDIF()
261
262FIND_PACKAGE_MESSAGE(PresetObservatory "Preset Observatory: ${OBSERVATORY}" "[${OBSERVATORY}]")
263
264
265# *********************************
266# *********** Compiler ************
267# *********************************
268
269SET(CMAKE_CXX_STANDARD 11)
270SET(CMAKE_CXX_FLAGS
271 "${CMAKE_CXX_FLAGS} -Wall -Winit-self -Wpointer-arith \
272 -Wcast-align -Wformat -Woverloaded-virtual \
273 -Wnon-virtual-dtor -Wshadow -fPIC") # -Wextra
274
275# /opt/root-6.18.04-bin/include/Bytes.h:72:6: warning: cast from 'char *' to 'UShort_t *'
276# (aka 'unsigned short *') increases required alignment from 1 to 2 [-Wcast-align]
277# *((UShort_t *)buf) = Rbswap_16(x);
278# ^~~~~~~~~~~~~~~
279
280IF(NOT ROOT_VERSION VERSION_LESS 6.18 AND ROOT_VERSION VERSION_LESS 6.23)
281 SET(CMAKE_CXX_FLAGS
282 "${CMAKE_CXX_FLAGS} -Wno-cast-align")
283ENDIF()
284
285SET(CMAKE_CXX_FLAGS
286 "${CMAKE_CXX_FLAGS} \
287 -DMARSVER=\\\"1.0\\\" -D_REENTRANT -D__MARS__ -D__LINUX__ \
288 -DPACKAGE_VERSION=\\\"1.0\\\" -DREVISION=\\\"1.0\\\" \
289 -DPACKAGE_NAME=\\\"MARS\\\" -DHAVE_ZLIB")
290
291CONFIGURE_FILE("${PROJECT_SOURCE_DIR}/cmake/root.rc.in" "${PROJECT_BINARY_DIR}/.rootrc")
292CONFIGURE_FILE("${PROJECT_SOURCE_DIR}/cmake/rootlogon.C.in" "${PROJECT_BINARY_DIR}/rootlogon.C")
293CONFIGURE_FILE("${PROJECT_SOURCE_DIR}/cmake/dohtml.C.in" "${PROJECT_BINARY_DIR}/dohtml.C")
294
295# -------------------------------------------------------
296
297FILE(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/dictionary)
298
299MACRO(SRCFILES subdir)
300
301 MESSAGE(STATUS "Reading source list from ${DIR}/Makefile")
302
303 EXECUTE_PROCESS(COMMAND
304 ${PROJECT_SOURCE_DIR}/Makefile.extract.sh ${subdir}
305 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/${subdir}
306 OUTPUT_VARIABLE _HEADERS)
307
308 SEPARATE_ARGUMENTS(_HEADERS)
309
310 LIST(GET _HEADERS 0 _CINT)
311 LIST(REMOVE_AT _HEADERS 0)
312
313 SET(_SRCLIST ${_HEADERS})
314
315 STRING(REPLACE "${subdir}/" " " _HEADERS ${_HEADERS}) # Remove directory
316 STRING(REPLACE ".cc" ".h" _HEADERS ${_HEADERS}) # change extension
317 STRING(REPLACE ".cxx" ".hxx" _HEADERS ${_HEADERS}) # special for files in mmc
318
319 SEPARATE_ARGUMENTS(_HEADERS)
320
321 # - This adds the rule how the dictionary is created
322 ROOT_GENERATE_DICTIONARY(dictionary/${_CINT} ${_HEADERS} ${_CINT}Incl.h LINKDEF ${subdir}/${_CINT}LinkDef.h OPTIONS ${ROOT_DICTIONARY_OPTION} -D__MARS__ -DHAVE_ZLIB)
323 # - This makes sure that it is compiled
324 TARGET_SOURCES(mars PRIVATE dictionary/${_CINT}.cxx ${_SRCLIST})
325 SET_SOURCE_FILES_PROPERTIES(dictionary/${_CINT}.cxx PROPERTIES COMPILE_FLAGS "-Wno-deprecated-register")
326
327 INSTALL(DIRECTORY ${subdir}/ DESTINATION "include" FILES_MATCHING PATTERN "*.h")
328
329 # This is a hack if somebody tries to run root from
330 # the compile directory rather than from a package
331 # install directory. In this case, the pcm files
332 # are not where the library is where they should be
333 IF(TARGET ${_CINT})
334 ADD_CUSTOM_COMMAND(TARGET ${_CINT} POST_BUILD
335 COMMAND test -f ../dictionary/${CINT}_rdict.pcm && ln -s ../dictionary/${_CINT}_rdict.pcm ${_CINT}_rdict.pcm || true
336 WORKING_DIRECTORY lib
337 VERBATIM)
338 ENDIF()
339
340ENDMACRO()
341
342# -------------------------------------------------------
343
344#SET(DIRECTORIES mmc)
345
346SET(DIRECTORIES
347 manalysis
348 mastro
349 mbadpixels
350 mbase
351 mcalib
352 mcamera
353 mcorsika
354 mdata
355 mdrs
356 melectronics
357 mextralgo
358 mfbase
359 mfileio
360 mfilter
361 mgeom
362 mgui
363 mhbase
364 mhcalib
365 mhflux
366 mhft
367 mhist
368 mhvstime
369 mimage
370 mjobs
371 mjoptim
372 mjtrain
373 mmain
374 mmc
375 mmovie
376 mmuon
377 mpedestal
378 mpointing
379 mranforest
380 mraw
381 mreport
382 msignal
383 msim
384 msimcamera
385 msimreflector
386 msql
387 mtools
388 mtrigger
389)
390
391INCLUDE_DIRECTORIES(${DIRECTORIES} mcore .)
392
393IF(NOVA_FOUND)
394 INCLUDE_DIRECTORIES(${NOVA_INCLUDE_DIR})
395ENDIF()
396
397
398SET(CORE_HEADERS
399 mcore/factofits.h
400 mcore/factfits.h
401 mcore/DrsCalib.h
402 mcore/PixelMap.h
403 mcore/Interpolator2D.h
404 MIncl.h)
405
406IF(NOVA_FOUND)
407 LIST(APPEND CORE_HEADERS mcore/nova.h mcore/Prediction.h)
408ENDIF()
409
410ROOT_GENERATE_DICTIONARY(dictionary/Core ${CORE_HEADERS} MIncl.h
411 LINKDEF MLinkDef.h
412 OPTIONS -p -D__MARS__ -DHAVE_ZLIB)
413
414ADD_LIBRARY(mars SHARED dictionary/Core.cxx) # CMAKE_POSITION_INDEPENDENT_CODE
415SET_SOURCE_FILES_PROPERTIES(dictionary/Core.cxx PROPERTIES COMPILE_FLAGS "-Wno-deprecated-register")
416
417# This is a hack if somebody tries to run root from
418# the compile directory rather than from a package
419# install directory. In this case, the pcm files
420# are not where the library is where they should be
421IF(TARGET Core)
422 ADD_CUSTOM_COMMAND(TARGET Core POST_BUILD
423 COMMAND test -f ../dictionary/Core_rdict.pcm && ln -s ../dictionary/Core_rdict.pcm Core_rdict.pcm || true
424 WORKING_DIRECTORY lib
425 VERBATIM)
426ENDIF()
427
428
429TARGET_LINK_LIBRARIES(mars ZLIB::ZLIB ${ROOT_LIBRARIES})
430IF(NOVA_FOUND)
431 TARGET_LINK_LIBRARIES(mars ${NOVA_LIBRARY})
432ENDIF()
433
434ADD_EXECUTABLE(showplot showplot.cc)
435ADD_EXECUTABLE(showlog showplot.cc)
436ADD_EXECUTABLE(ceres ceres.cc)
437TARGET_LINK_LIBRARIES(showplot mars ${ROOT_LIBRARIES})
438TARGET_LINK_LIBRARIES(showlog mars ${ROOT_LIBRARIES})
439TARGET_LINK_LIBRARIES(ceres mars ${ROOT_LIBRARIES})
440
441
442FOREACH(DIR ${DIRECTORIES})
443 SRCFILES(${DIR})
444ENDFOREACH()
445
446# -------------------------------------------------------
447
448IF(FOUND_HEALPIX)
449 # https://github.com/akira-okumura/RootHealPix.git
450 # THealPixD de("name", "", 2); for (int i=0; i<100; i++) de.Fill(gRandom->Uniform()*90, gRandom->Uniform()*180); de.Draw("COLZ");
451
452 # INCLUDE_DIRECTORIES(${HEALPIX_PREFIX}/include)
453 # - The first one is required to make ROOT_GENERATE_DICTIONARY
454 # find absolute paths. The second one is required for
455 # compilation. Note that any later ROOT_GENERALE_DICTIONARY
456 # might find the LinkDef.h in RootHealPix/include
457 INCLUDE_DIRECTORIES(/ ${HEALPIX_PREFIX}/include)
458
459 ROOT_GENERATE_DICTIONARY(dictionary/HealPix
460 ${HEALPIX_PREFIX}/include/Healoption.h
461 ${HEALPIX_PREFIX}/include/THealAlm.h
462 ${HEALPIX_PREFIX}/include/THealFFT.h
463 ${HEALPIX_PREFIX}/include/THealPainter.h
464 ${HEALPIX_PREFIX}/include/THealPaletteAxis.h
465 ${HEALPIX_PREFIX}/include/THealPixCube.h
466 ${HEALPIX_PREFIX}/include/THealPix.h
467 ${HEALPIX_PREFIX}/include/THealUtil.h
468 ${HEALPIX_PREFIX}/include/TVirtualHealPainter.h
469 LINKDEF ${HEALPIX_PREFIX}/include/LinkDef.h OPTIONS -p)
470
471 # - Define the source files of the library
472 ADD_LIBRARY(RootHealPix SHARED dictionary/HealPix.cxx
473 ${HEALPIX_PREFIX}/src/THealAlm.cxx
474 ${HEALPIX_PREFIX}/src/THealFFT.cxx
475 ${HEALPIX_PREFIX}/src/THealPainter.cxx
476 ${HEALPIX_PREFIX}/src/THealPaletteAxis.cxx
477 ${HEALPIX_PREFIX}/src/THealPixCube.cxx
478 ${HEALPIX_PREFIX}/src/THealPix.cxx
479 ${HEALPIX_PREFIX}/src/THealUtil.cxx
480 ${HEALPIX_PREFIX}/src/TVirtualHealPainter.cxx)
481
482 # - Tweak some warnings
483 SET_TARGET_PROPERTIES(RootHealPix PROPERTIES COMPILE_FLAGS
484 "-Wno-unused-variable -Wno-unused-function -Wno-unneeded-internal-declaration -Wno-shadow")
485
486 # - Link with the root libraries for auto-loading
487 TARGET_LINK_LIBRARIES(mars RootHealPix)
488
489 # - Install the corresponding header files
490 INSTALL(DIRECTORY ${HEALPIX_PREFIX}/include/ DESTINATION "include" FILES_MATCHING PATTERN "*.h")
491
492 # - Install the library
493 INSTALL(TARGETS RootHealPix DESTINATION ".")
494ENDIF()
495
496
497# rootlogon.C finds the shared object only if the libmars.so is in the same directory than the dictionary files
498# 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
499#ADD_CUSTOM_COMMAND(TARGET mars POST_BUILD
500# COMMAND cp -f ${PROJECT_BINARY_DIR}/libmars.so ${PROJECT_BINARY_DIR}/dictionary/libmars.so
501# COMMENT "Copying libmars.so to ${PROJECT_BINARY_DIR}/dictionary")
502
503#---Create a shared library with geneated dictionary
504#ADD_LIBRARY(Event SHARED Event.cxx G__Event.cxx)
505#TARGET_LINK_LIBRARIES(Event ${ROOT_LIBRARIES})
506
507#---Create a main program using the library
508#ADD_EXECUTABLE(Main MainEvent.cxx)
509#TARGET_LINK_LIBRARIES(Main Event)
510
511
512# *********************************
513# ************ Packaging **********
514# *********************************
515
516#SET(PKG_SHARE "${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}")
517#SET(PKG_APPS "${CMAKE_INSTALL_DATAROOTDIR}/applications")
518#SET(PKG_PIXMAPS "${CMAKE_INSTALL_DATAROOTDIR}/pixmaps")
519
520# ====== Installation targets =====
521
522#INSTALL(TARGETS mars DESTINATION "${CMAKE_INSTALL_BINDIR}")
523INSTALL(TARGETS mars DESTINATION ".")
524INSTALL(TARGETS showplot DESTINATION ".")
525INSTALL(TARGETS showlog DESTINATION ".")
526INSTALL(TARGETS ceres DESTINATION ".")
527INSTALL(FILES .rootrc DESTINATION ".")
528INSTALL(DIRECTORY lib DESTINATION ".")
529INSTALL(DIRECTORY macros DESTINATION "." FILES_MATCHING PATTERN "*.C")
530INSTALL(DIRECTORY fact DESTINATION "." FILES_MATCHING PATTERN "*.C")
531INSTALL(DIRECTORY datacenter DESTINATION ".")
532INSTALL(DIRECTORY scripts DESTINATION ".")
533INSTALL(DIRECTORY resources DESTINATION "." FILES_MATCHING PATTERN "*.rc" PATTERN "*.txt")
534INSTALL(DIRECTORY resmc DESTINATION "." FILES_MATCHING PATTERN "*" )
535INSTALL(DIRECTORY mcore/ DESTINATION "include" FILES_MATCHING PATTERN "*.h")
536
537
538# ======== General packaging ======
539# https://cmake.org/cmake/help/latest/module/CPack.html
540
541INCLUDE(InstallRequiredSystemLibraries)
542
543# SET(CPACK_STRIP_FILES ON) # Strip debug sysmbold from files
544
545SET(CPACK_PACKAGE_VERSION "${mars_VERSION}")
546SET(CPACK_PACKAGE_CONTACT "${PACKAGE_BUGREPORT}")
547SET(CPACK_PACKAGE_MAINTAINER "${PACKAGE_MAINTAINER}")
548#SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
549#SET(CPACK_PACKAGE_VENDOR "Me, myself, and I")
550
551
552SET(CPACK_SOURCE_IGNORE_FILES "/old/;/build/;/[.].*/;/autom4te[.]cache/;.*~;.log$")
553
554# Maybe the text displayed in synaptic?
555#SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README")
556SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MARS - Environment")
557#CPACK_RESOURCE_FILE_README ReadMe file to be embedded in the installer.
558
559SET(CPACK_GENERATOR TBZ2) # TGZ DEB
560#SET(CPACK_SOURCE_GENERATOR TBZ2) # TGZ
561#SET(CPACK_PROJECT_CONFIG_FILE ${CMAKE_SOURCE_DIR}/cmake/Package.txt)
562#SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt")
563
564
565# ======== Debian packaging =======
566# https://cmake.org/cmake/help/latest/module/CPackDeb.html
567# https://www.debian.org/doc/debian-policy
568
569#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)")
570SET(CPACK_DEBIAN_PACKAGE_SHLIBDEPS 1) # generate better (atomatic?) dependecies
571SET(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY ">=")
572SET(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE)
573SET(CPACK_DEBIAN_PACKAGE_SECTION utils)
574SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "${PACKAGE_URL}")
575SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION
576"${CPACK_PACKAGE_DESCRIPTION_SUMMARY}
577 This package contains the MARS Analysis Environment.")
578#indent the long description with spaces
579
580#CPACK_INSTALL_CMAKE_PROJECTS
581#List of four values that specify what project to install. Build directory, Project Name, Project Component, Directory.
582
583INCLUDE(CPack)
Note: See TracBrowser for help on using the repository browser.