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 | IF (NOT CMAKE_BUILD_TYPE)
|
---|
11 | SET(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build (Debug or Release)" FORCE)
|
---|
12 | ENDIF()
|
---|
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
|
---|
19 |
|
---|
20 | IF (NOT DEFINED CMAKE_C_COMPILER)
|
---|
21 | SET(CMAKE_C_COMPILER "clang")# CACHE STRING "Choose the compiler (c++, g++, clang++)" FORCE)
|
---|
22 | ENDIF()
|
---|
23 | #
|
---|
24 | IF (NOT DEFINED CMAKE_CXX_COMPILER)
|
---|
25 | SET(CMAKE_CXX_COMPILER "clang++")# CACHE STRING "Choose the compiler (c++, g++, clang++)" FORCE)
|
---|
26 | ENDIF()
|
---|
27 |
|
---|
28 | #SET(CMAKE_VERBOSE_MAKEFILE ON)
|
---|
29 |
|
---|
30 | # To check for an include file you do this:
|
---|
31 | #CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H)
|
---|
32 | # To check the size of a primitive type:
|
---|
33 | #CHECK_TYPE_SIZE("int" SIZEOF_INT)
|
---|
34 |
|
---|
35 |
|
---|
36 |
|
---|
37 | # *********************************
|
---|
38 | # ************ Project ************
|
---|
39 | # *********************************
|
---|
40 |
|
---|
41 | STRING(TIMESTAMP VERSION %y.%U.%w.%H UTC)
|
---|
42 |
|
---|
43 | MESSAGE(STATUS "Mars V${VERSION}")
|
---|
44 |
|
---|
45 | PROJECT(mars VERSION ${VERSION})
|
---|
46 |
|
---|
47 | INCLUDE(GNUInstallDirs)
|
---|
48 |
|
---|
49 | # ======== For config.h.in =========
|
---|
50 | SET(PACKAGE_MAINTAINER "Thomas Bretz")
|
---|
51 | SET(PACKAGE_BUGREPORT "tbretz@physik.rwth-aachen.de")
|
---|
52 | SET(PACKAGE_URL "https://www.fact-project.org")
|
---|
53 |
|
---|
54 |
|
---|
55 |
|
---|
56 | # *********************************
|
---|
57 | # ********* Requirements **********
|
---|
58 | # *********************************
|
---|
59 |
|
---|
60 | # =========== help2man ============
|
---|
61 | FIND_PROGRAM(HELP2MAN_EXECUTABLE help2man)
|
---|
62 |
|
---|
63 | # =========== pkg-config ============
|
---|
64 | FIND_PACKAGE(PkgConfig)
|
---|
65 | FIND_PACKAGE(PackageHandleStandardArgs)
|
---|
66 |
|
---|
67 |
|
---|
68 | # ============= libnova ==============
|
---|
69 |
|
---|
70 | PKG_CHECK_MODULES(Nova Nova)
|
---|
71 |
|
---|
72 | # Try to locate the package in the default path
|
---|
73 | # and in the path provided by pkg-config
|
---|
74 | FIND_PATH(NOVA_INCLUDE_DIR NAMES libnova/libnova.h PATHS ${NOVA_INCLUDE_DIRS})
|
---|
75 | FIND_LIBRARY(NOVA_LIBRARY NAMES nova PATHS ${NOVA_LIBRARY_DIRS})
|
---|
76 |
|
---|
77 | # Check if NOVA_LIBARARY and NOVA_INCLUDE_DIR is set
|
---|
78 | # Print a message otherwise
|
---|
79 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(libnova DEFAULT_MSG NOVA_LIBRARY NOVA_INCLUDE_DIR)
|
---|
80 |
|
---|
81 | # Mark those variables to be displayed as 'advanced' in the GUI
|
---|
82 | MARK_AS_ADVANCED(NOVA_LIBRARY NOVA_INCLUDE_DIR)
|
---|
83 |
|
---|
84 | # handle success
|
---|
85 | IF(NOVA_FOUND AND NOT NOVA_FIND_QUIETLY)
|
---|
86 | MESSAGE(STATUS "Found Nova ${NOVA_LIBRARY} in ${NOVA_INCLUDE_DIR}")
|
---|
87 | ENDIF()
|
---|
88 |
|
---|
89 |
|
---|
90 | # ============== libz ================
|
---|
91 |
|
---|
92 | FIND_PACKAGE(ZLIB REQUIRED)
|
---|
93 |
|
---|
94 |
|
---|
95 | # =========== Enable C++11 ===========
|
---|
96 |
|
---|
97 | SET(CMAKE_CXX_STANDARD 11)
|
---|
98 | SET(CMAKE_CXX_FLAGS
|
---|
99 | "${CMAKE_CXX_FLAGS} -Wall -Winit-self -Wpointer-arith \
|
---|
100 | -Wcast-align -Wformat -Woverloaded-virtual \
|
---|
101 | -Wnon-virtual-dtor -Wshadow -fPIC") # -Wextra
|
---|
102 |
|
---|
103 | SET(CMAKE_CXX_FLAGS
|
---|
104 | "${CMAKE_CXX_FLAGS} \
|
---|
105 | -DMARSVER=\\\"1.0\\\" -D_REENTRANT -D__MARS__ -D__LINUX__ \
|
---|
106 | -DPACKAGE_VERSION=\\\"1.0\\\" -DREVISION=\\\"1.0\\\" \
|
---|
107 | -DPACKAGE_NAME=\\\"MARS\\\" -DHAVE_ZLIB")
|
---|
108 |
|
---|
109 |
|
---|
110 | # --------- config.h -------------
|
---|
111 |
|
---|
112 | #CONFIGURE_FILE("${PROJECT_SOURCE_DIR}/config.h.in" "${PROJECT_BINARY_DIR}/config.h")
|
---|
113 | #INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")
|
---|
114 |
|
---|
115 | SET(CMAKE_MODULE_PATH $ENV{ROOTSYS}/etc/cmake ${CMAKE_MODULE_PATH})
|
---|
116 |
|
---|
117 |
|
---|
118 | # You need to tell CMake where to find the ROOT installation. This can be done in a number of ways:
|
---|
119 | # - ROOT built with classic configure/make use the provided $ROOTSYS/etc/cmake/FindROOT.cmake
|
---|
120 | # - ROOT built with CMake. Add in CMAKE_PREFIX_PATH the installation prefix for ROOT
|
---|
121 | #LIST(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS})
|
---|
122 |
|
---|
123 | #---Locate the ROOT package and defines a number of variables (e.g. ROOT_INCLUDE_DIRS)
|
---|
124 |
|
---|
125 | # -lGui -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree
|
---|
126 | # -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread
|
---|
127 | # -lASImage -lMinuit -lHistPainter -lThread
|
---|
128 |
|
---|
129 | FIND_PACKAGE(ROOT REQUIRED COMPONENTS Gui Minuit)
|
---|
130 |
|
---|
131 |
|
---|
132 | #MESSAGE("INCL_DIRS: ${ROOT_INCLUDE_DIRS}")
|
---|
133 | #MESSAGE("LIBS: ${ROOT_LIBRARIES}")
|
---|
134 | #MESSAGE("DEFS: ${ROOT_DEFINITIONS}")
|
---|
135 | #MESSAGE("CXXFLAGS: ${ROOT_CXX_FLAGS}")
|
---|
136 | #MESSAGE("CXFLAGS: ${ROOT_CC_FLAGS}")
|
---|
137 | #MESSAGE("FOUND: ${ROOT_FOUND}")
|
---|
138 | #MESSAGE("FILE: ${ROOT_USE_FILE}")
|
---|
139 | #MESSAGE("DIR: ${CMAKE_CURRENT_SOURCE_DIR}")
|
---|
140 | #ROOT_<library>_LIBRARY PATH Full path for each of the ROOT libraries listed in COMPONENTS
|
---|
141 | #ROOT_<command>_CMD PATH Full path for each ROOT executable (rootcling, root, hadd, etc.)
|
---|
142 | #ROOT_<option>_FOUND BOOL True for each enabled build option (e.g. cocoa, python, xrootd, etc.)
|
---|
143 |
|
---|
144 | #---Define useful ROOT functions and macros (e.g. ROOT_GENERATE_DICTIONARY)
|
---|
145 | #INCLUDE(${ROOT_USE_FILE})
|
---|
146 |
|
---|
147 | # function ROOT_GENERATE_DICTIONARY( dictionary
|
---|
148 | # header1 header2 ...
|
---|
149 | # LINKDEF linkdef1 ...
|
---|
150 | # OPTIONS opt1...)
|
---|
151 |
|
---|
152 | # -------------------------------------------------------
|
---|
153 |
|
---|
154 | FILE(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/dictionary)
|
---|
155 |
|
---|
156 | MACRO(SRCFILES subdir)
|
---|
157 |
|
---|
158 | EXECUTE_PROCESS(COMMAND
|
---|
159 | ${PROJECT_SOURCE_DIR}/Makefile.extract.sh ${subdir}
|
---|
160 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/${subdir}
|
---|
161 | OUTPUT_VARIABLE _HEADERS)
|
---|
162 |
|
---|
163 | SEPARATE_ARGUMENTS(_HEADERS)
|
---|
164 |
|
---|
165 | LIST(GET _HEADERS 0 _CINT)
|
---|
166 | LIST(REMOVE_AT _HEADERS 0)
|
---|
167 |
|
---|
168 | SET(_SRCLIST ${_HEADERS})
|
---|
169 |
|
---|
170 | STRING(REPLACE "${subdir}/" " " _HEADERS ${_HEADERS}) # Remove directory
|
---|
171 | STRING(REPLACE ".cc" ".h" _HEADERS ${_HEADERS}) # change extension
|
---|
172 | STRING(REPLACE ".cxx" ".hxx" _HEADERS ${_HEADERS}) # special for files in mmc
|
---|
173 |
|
---|
174 | SEPARATE_ARGUMENTS(_HEADERS)
|
---|
175 |
|
---|
176 | ROOT_GENERATE_DICTIONARY(dictionary/${_CINT} ${_HEADERS} ${_CINT}Incl.h LINKDEF ${_CINT}LinkDef.h OPTIONS -p)
|
---|
177 | TARGET_SOURCES(mars PRIVATE dictionary/${_CINT}.cxx ${_SRCLIST})
|
---|
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 |
|
---|
251 | FOREACH(DIR ${DIRECTORIES})
|
---|
252 | MESSAGE(STATUS "Reading source list from ${DIR}/Makefile")
|
---|
253 | SRCFILES(${DIR})
|
---|
254 | ENDFOREACH()
|
---|
255 |
|
---|
256 | ADD_CUSTOM_COMMAND(TARGET mars POST_BUILD
|
---|
257 | COMMAND ln -sf ${PROJECT_BINARY_DIR}/libmars.so ${PROJECT_SOURCE_DIR}/
|
---|
258 | COMMENT "Creating symlink for libmars.so to ${PROJECT_BINARY_DIR}")
|
---|
259 |
|
---|
260 | #---Create a shared library with geneated dictionary
|
---|
261 | #ADD_LIBRARY(Event SHARED Event.cxx G__Event.cxx)
|
---|
262 | #TARGET_LINK_LIBRARIES(Event ${ROOT_LIBRARIES})
|
---|
263 |
|
---|
264 | #---Create a main program using the library
|
---|
265 | #ADD_EXECUTABLE(Main MainEvent.cxx)
|
---|
266 | #TARGET_LINK_LIBRARIES(Main Event)
|
---|