source: trunk/Mars/CMakeLists.txt@ 19004

Last change on this file since 19004 was 18957, checked in by tbretz, 7 years ago
Improved compiler warnings.
File size: 6.6 KB
Line 
1# ------------ cmake --------------
2CMAKE_MINIMUM_REQUIRED(VERSION 3.0 FATAL_ERROR)
3CMAKE_POLICY(SET CMP0048 NEW)
4
5# Enable debug symbols by default
6# must be done before project() statement
7IF (NOT CMAKE_BUILD_TYPE)
8 SET(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build (Debug or Release)" FORCE)
9ENDIF()
10# (you can also set it on the command line: -D CMAKE_BUILD_TYPE=Release)
11
12# --------- Project --------------
13PROJECT(Mars VERSION 1.8.3.13)
14
15# ------- For config.h.in --------
16SET(PACKAGE_MAINTAINER "Thomas Bretz")
17SET(PACKAGE_BUGREPORT "tbretz@physik.rwth-aachen.de")
18#SET(PACKAGE_URL "")
19
20#SET(CMAKE_VERBOSE_MAKEFILE ON)
21
22# To check for an include file you do this:
23#CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H)
24# To check the size of a primitive type:
25#CHECK_TYPE_SIZE("int" SIZEOF_INT)
26
27# =========== pkg-config ============
28FIND_PACKAGE(PkgConfig)
29FIND_PACKAGE(PackageHandleStandardArgs)
30
31
32# ============= libnova ==============
33
34PKG_CHECK_MODULES(Nova Nova)
35
36# Try to locate the package in the default path
37# and in the path provided by pkg-config
38FIND_PATH(NOVA_INCLUDE_DIR NAMES libnova/libnova.h PATHS ${NOVA_INCLUDE_DIRS})
39FIND_LIBRARY(NOVA_LIBRARY NAMES nova PATHS ${NOVA_LIBRARY_DIRS})
40
41# Check if NOVA_LIBARARY and NOVA_INCLUDE_DIR is set
42# Print a message otherwise
43FIND_PACKAGE_HANDLE_STANDARD_ARGS(libnova DEFAULT_MSG NOVA_LIBRARY NOVA_INCLUDE_DIR)
44
45# Mark those variables to be displayed as 'advanced' in the GUI
46MARK_AS_ADVANCED(NOVA_LIBRARY NOVA_INCLUDE_DIR)
47
48# handle success
49IF(NOVA_FOUND AND NOT NOVA_FIND_QUIETLY)
50 MESSAGE(STATUS "Found Nova ${NOVA_LIBRARY} in ${NOVA_INCLUDE_DIR}")
51ENDIF()
52
53
54# ============== libz ================
55
56FIND_PACKAGE(ZLIB REQUIRED)
57
58
59# =========== Enable C++11 ===========
60
61SET(CMAKE_CXX_STANDARD 11)
62SET(CMAKE_CXX_FLAGS
63 "${CMAKE_CXX_FLAGS} -Wall -Winit-self -Wpointer-arith \
64 -Wcast-align -Wformat=1 -Woverloaded-virtual \
65 -Wnon-virtual-dtor -Wshadow -fPIC") # -Wextra
66
67SET(CMAKE_CXX_FLAGS
68 "${CMAKE_CXX_FLAGS} \
69 -DMARSVER=\\\"1.0\\\" -D_REENTRANT -D__MARS__ -D__LINUX__ \
70 -DPACKAGE_VERSION=\\\"1.0\\\" -DREVISION=\\\"1.0\\\" \
71 -DPACKAGE_NAME=\\\"MARS\\\" -DHAVE_ZLIB")
72
73
74# --------- config.h -------------
75
76#CONFIGURE_FILE("${PROJECT_SOURCE_DIR}/config.h.in" "${PROJECT_BINARY_DIR}/config.h")
77#INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")
78
79SET(CMAKE_MODULE_PATH $ENV{ROOTSYS}/etc/cmake ${CMAKE_MODULE_PATH})
80
81
82# You need to tell CMake where to find the ROOT installation. This can be done in a number of ways:
83# - ROOT built with classic configure/make use the provided $ROOTSYS/etc/cmake/FindROOT.cmake
84# - ROOT built with CMake. Add in CMAKE_PREFIX_PATH the installation prefix for ROOT
85#LIST(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS})
86
87#---Locate the ROOT package and defines a number of variables (e.g. ROOT_INCLUDE_DIRS)
88
89# -lGui -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree
90# -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread
91# -lASImage -lMinuit -lHistPainter -lThread
92
93FIND_PACKAGE(ROOT REQUIRED COMPONENTS Gui Minuit)
94
95
96#MESSAGE("INCL_DIRS: ${ROOT_INCLUDE_DIRS}")
97#MESSAGE("LIBS: ${ROOT_LIBRARIES}")
98#MESSAGE("DEFS: ${ROOT_DEFINITIONS}")
99#MESSAGE("CXXFLAGS: ${ROOT_CXX_FLAGS}")
100#MESSAGE("CXFLAGS: ${ROOT_CC_FLAGS}")
101#MESSAGE("FOUND: ${ROOT_FOUND}")
102#MESSAGE("FILE: ${ROOT_USE_FILE}")
103#MESSAGE("DIR: ${CMAKE_CURRENT_SOURCE_DIR}")
104#ROOT_<library>_LIBRARY PATH Full path for each of the ROOT libraries listed in COMPONENTS
105#ROOT_<command>_CMD PATH Full path for each ROOT executable (rootcling, root, hadd, etc.)
106#ROOT_<option>_FOUND BOOL True for each enabled build option (e.g. cocoa, python, xrootd, etc.)
107
108#---Define useful ROOT functions and macros (e.g. ROOT_GENERATE_DICTIONARY)
109#INCLUDE(${ROOT_USE_FILE})
110
111# function ROOT_GENERATE_DICTIONARY( dictionary
112# header1 header2 ...
113# LINKDEF linkdef1 ...
114# OPTIONS opt1...)
115
116# -------------------------------------------------------
117
118FILE(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/dictionary)
119
120MACRO(SRCFILES subdir)
121
122 EXECUTE_PROCESS(COMMAND
123 ${PROJECT_SOURCE_DIR}/Makefile.extract.sh ${subdir}
124 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/${subdir}
125 OUTPUT_VARIABLE _HEADERS)
126
127 SEPARATE_ARGUMENTS(_HEADERS)
128
129 LIST(GET _HEADERS 0 _CINT)
130 LIST(REMOVE_AT _HEADERS 0)
131
132 SET(_SRCLIST ${_HEADERS})
133
134 STRING(REPLACE "${subdir}/" " " _HEADERS ${_HEADERS}) # Remove directory
135 STRING(REPLACE ".cc" ".h" _HEADERS ${_HEADERS}) # change extension
136 STRING(REPLACE ".cxx" ".hxx" _HEADERS ${_HEADERS}) # special for files in mmc
137
138 SEPARATE_ARGUMENTS(_HEADERS)
139
140 ROOT_GENERATE_DICTIONARY(dictionary/${_CINT} ${_HEADERS} ${_CINT}Incl.h LINKDEF ${_CINT}LinkDef.h OPTIONS -p)
141 TARGET_SOURCES(mars PRIVATE dictionary/${_CINT}.cxx ${_SRCLIST})
142
143ENDMACRO()
144
145# -------------------------------------------------------
146
147#SET(DIRECTORIES mmc)
148
149SET(DIRECTORIES
150 manalysis
151 mastro
152 mbadpixels
153 mbase
154 mcalib
155 mcamera
156 mcorsika
157 mdata
158 mdrs
159 melectronics
160 mextralgo
161 mfbase
162 mfileio
163 mfilter
164 mgeom
165 mgui
166 mhbase
167 mhcalib
168 mhflux
169 mhft
170 mhist
171 mhvstime
172 mimage
173 mjobs
174 mjoptim
175 mjtrain
176 mmain
177 mmc
178 mmovie
179 mmuon
180 mpedestal
181 mpointing
182 mranforest
183 mraw
184 mreport
185 msignal
186 msim
187 msimcamera
188 msimreflector
189 msql
190 mtools
191 mtrigger
192)
193
194INCLUDE_DIRECTORIES(${ROOT_INCLUDE_DIRS} ${DIRECTORIES} mcore .)
195
196ROOT_GENERATE_DICTIONARY(dictionary/MARS
197 factofits.h
198 factfits.h
199 DrsCalib.h
200 PixelMap.h
201 Interpolator2D.h
202 nova.h
203 Prediction.h
204 MIncl.h
205 LINKDEF MLinkDef.h
206 OPTIONS -p -D__MARS__ -DHAVE_ZLIB)
207
208ADD_LIBRARY(mars SHARED dictionary/MARS.cxx)
209TARGET_LINK_LIBRARIES(mars ${ROOT_LIBRARIES})
210TARGET_LINK_LIBRARIES(mars ${NOVA_LIBRARY})
211TARGET_LINK_LIBRARIES(mars ZLIB::ZLIB)
212
213FOREACH(DIR ${DIRECTORIES})
214 MESSAGE(STATUS "Reading source list from ${DIR}/Makefile")
215 SRCFILES(${DIR})
216ENDFOREACH()
217
218ADD_CUSTOM_COMMAND(TARGET mars POST_BUILD
219 COMMAND ln -sf ${PROJECT_BINARY_DIR}/libmars.so ${PROJECT_SOURCE_DIR}/
220 COMMENT "Creating symlink for libmars.so to ${PROJECT_BINARY_DIR}")
221
222#---Create a shared library with geneated dictionary
223#ADD_LIBRARY(Event SHARED Event.cxx G__Event.cxx)
224#TARGET_LINK_LIBRARIES(Event ${ROOT_LIBRARIES})
225
226#---Create a main program using the library
227#ADD_EXECUTABLE(Main MainEvent.cxx)
228#TARGET_LINK_LIBRARIES(Main Event)
Note: See TracBrowser for help on using the repository browser.