Update: removed request of 4 points in ITS (Renu)
[u/mrichter/AliRoot.git] / cmake / modules / CreateHLTSubCMakeFiles.cmake
CommitLineData
96c0c856 1Macro(CreateHLTSubCMakeFiles)
2
3 set(_dir HLT)
4
5 # Check if ROOT was compile with xml and alien support
6 # This is needed later to set properly the definitions during
7 # compilation
8 Execute_process(
9 COMMAND root-config --has-xml
10 OUTPUT_VARIABLE ROOT_HAS_XML
11 OUTPUT_STRIP_TRAILING_WHITESPACE)
12
13 Execute_process(
14 COMMAND root-config --has-alien
15 OUTPUT_VARIABLE ROOT_HAS_ALIEN
16 OUTPUT_STRIP_TRAILING_WHITESPACE)
17
18 # Loop over the subdirectories, extract the package files and
19 # call for each of the package files a macro which creates the
20 # corresponding CMake input files in the subdirectory
21
22 file(GLOB Package RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/${_dir}/*.pkg)
23 get_filename_component(__path ${_dir} NAME)
24 set(EINCLUDE_SUBDIR ${__path} STEER)
25 set(PACKCXXFLAGS_SUBDIR)
26 set(PACKAGES)
27
28 ParseHLTPackageFile(HLT/hlt.conf)
29 set(PACKCXXFLAGS_SUBDIR ${PACKCXXFLAGS_SUBDIR} ${PACKCXXFLAGS_PACKAGE})
7f40fabf 30# MESSAGE("${Package}")
96c0c856 31
7f40fabf 32# set(Package HLT/libHLTrec.pkg)
96c0c856 33 Foreach(_pack ${Package})
34 GenerateHLTInputFiles(${_pack})
35 set(EINCLUDE_SUBDIR ${EINCLUDE_SUBDIR} ${EINCLUDE_PACKAGE})
36 set(PACKCXXFLAGS_SUBDIR ${PACKCXXFLAGS_SUBDIR} ${PACKCXXFLAGS_PACKAGE})
37 EndForeach(_pack ${Package})
38 list(REMOVE_DUPLICATES EINCLUDE_SUBDIR)
39 CreateHLTMainCMakeFile(${__path})
40
41EndMacro(CreateHLTSubCMakeFiles)
42
43Macro(GenerateHLTInputFiles Package)
44
45 get_filename_component(_path ${Package} PATH)
46 get_filename_component(_name ${Package} NAME)
47
48 STRING(REGEX REPLACE "^(lib.*).pkg$" "\\1" _lib "${_name}")
49 STRING(REGEX REPLACE "^(bin.*).pkg$" "\\1" _bin "${_name}")
50
51 ParseHLTPackageFile(${Package})
52
53 If(_name MATCHES "^lib.*$")
54 Set(PACKAGES ${PACKAGES} ${_lib})
55# SpecialHLTSettingsMadeByHand(${_lib}) # Correct the Parser
56 CreateHLTLibPackageFile(${_path} ${_lib})
57# Message("Would create ${_lib}")
58 Else(_name MATCHES "^lib.*$")
59 Set(PACKAGES ${PACKAGES} ${_bin})
60 CreateHLTBinPackageFile(${_path} ${_bin})
61# Message("Would create ${_bin}")
62 EndIf(_name MATCHES "^lib.*$")
63
64EndMacro(GenerateHLTInputFiles Package)
65
66Macro(ParseHLTPackageFile Package)
67
68 Set(CXXSRCS_PACKAGE)
69 Set(CSRCS_PACKAGE)
70 Set(FSRCS_PACKAGE)
71 Set(EINCLUDE_PACKAGE)
72 Set(DHDR_PACKAGE)
73 Set(ELIBS_PACKAGE)
74 Set(HDRS_PACKAGE)
75 Set(PACKCXXFLAGS_PACKAGE)
76 Set(PACKFFLAGS_PACKAGE)
77 Set(ADD_HEADERS)
78 Set(EXCLUDE_PART FALSE)
79 Set(MATCHED FALSE)
80 Set(_file_glob FALSE)
81 Set(_file_glob_dir)
82 Set(SRCS_PACKAGE)
83
84 # Read the complete text file into variable contents
85
86 FILE(READ "${Package}" contents)
87
88 # Convert file contents into a CMake list (where each element in the list
89 # is one line of the file)
90 # Replace as first step ";" to "\". One "\" in a regex must be "\\\\"
91 # After that replace line breaks by a semicolon, which is in cmake the
92 # separator between list elements. The nice feature is that if there is a
93 # follow up line this is indicated with an "\" at the end of the line
94 # directly before the line break. In the generated string this two letters
95 # together becomes "\;" which is not the separator between two list elements
96 # but a single ";" in a liste element. With this trick one gets all
97 # follow up lines in one list element which can be parsed
98
99 STRING(REGEX REPLACE ";" "\\\\;" contents "${contents}")
100 STRING(REGEX REPLACE "\n" ";" contents "${contents}")
101
102 # Iterate over the lines of the input file
103 Foreach(line ${contents})
104
105
106 # Simple technique to handle if statements in the package files
107 # If you hit an endif or an else at the begining of a line read
108 # again lines below this point. In case of else check if it is a
109 # nested "if else if else endif endif" structure. If the correct
110 # case is already found don't read the following lines
111
112 STRING(REGEX REPLACE "\t" "" line "${line}")
113
114 If(line MATCHES "^[#].*$")
115 Set(EXCLUDE_COMMENT TRUE)
116# MESSAGE("This is a comment")
117 Else(line MATCHES "^[#].*$")
118 Set(EXCLUDE_COMMENT FALSE)
119# MESSAGE("This is not a comment")
120 EndIf(line MATCHES "^[#].*$")
121
122 If(line MATCHES "^endif.*$")
123 Set(EXCLUDE_PART FALSE)
124 EndIf(line MATCHES "^endif.*$")
125
126 If(line MATCHES "^else.*$")
127 If(NOT MATCHED)
128 Set(EXCLUDE_PART FALSE)
129 Else(NOT MATCHED)
130 Set(EXCLUDE_PART TRUE)
131 EndIf(NOT MATCHED)
132 EndIf(line MATCHES "^else.*$")
133
134 # Special handling in case ther is a if statement
135
136 If(line MATCHES "^if.*$")
137
138 # Special handling in case ther is a ifeq statement
139
140 If(line MATCHES "^ifeq.*$")
141
142 Set(EXCLUDE_PART TRUE)
143
144 # Remove ifeq from text. The rest is the interesting part of
145 # the statement
146
147 STRING(REGEX REPLACE "ifeq" "" statement "${line}")
148
149 # check if "ifeq" compares for ALICE_TARGET. If required target is
150 # equal to ALICE_TARGET, then read the following lines until endif
151 # or else is found
152 # Since only one target is possible mark that a target was already
153 # found. A short summary of regular expressions can be found at the
154 # end of this file.
155
156 If(line MATCHES "^.*ALICE_TARGET.*$")
157 STRING(REGEX REPLACE "^.*[(](.*),[$][(]ALICE_TARGET[)][)].*$" "\\1" _result "${line}")
158 If(_result STREQUAL ${ALICE_TARGET})
159 Set(MATCHED TRUE)
160 Set(EXCLUDE_PART FALSE)
161 Else(_result STREQUAL ${ALICE_TARGET})
162 Set(EXCLUDE_PART TRUE)
163 EndIf(_result STREQUAL ${ALICE_TARGET})
164 EndIf(line MATCHES "^.*ALICE_TARGET.*$")
165
166
167 # check if "if" statement checks for Alien or XML installation.
168 # If ROOT is installed with Alien or XML switch on the compile
169 # flags
170
171 If(line MATCHES "^.*CHECK.*$")
172 STRING(REGEX REPLACE "^.*[(](.*),[$][(]CHECKXML[)][)].*$" "\\1" _result_xml "${line}")
173 STRING(REGEX REPLACE "^.*[(](.*),[$][(]CHECKALIEN[)][)].*$" "\\1" _result_alien "${line}")
174 If(${_result_xml} STREQUAL ${ROOT_HAS_XML} OR ${_result_alien} STREQUAL ${ROOT_HAS_ALIEN})
175 Set(EXCLUDE_PART FALSE)
176 Else(${_result_xml} STREQUAL ${ROOT_HAS_XML} OR ${_result_alien} STREQUAL ${ROOT_HAS_ALIEN})
177 Set(EXCLUDE_PART TRUE)
178 EndIf(${_result_xml} STREQUAL ${ROOT_HAS_XML} OR ${_result_alien} STREQUAL ${ROOT_HAS_ALIEN})
179# MESSAGE("HIER")
180 EndIf(line MATCHES "^.*CHECK.*$")
181
182# MESSAGE("EXCLUDE: ${EXCLUDE_PART}")
183
184 If(line MATCHES "^.*CCM.*$")
185 STRING(REGEX REPLACE "^.*[(][$][(]CCMAJORV[)],(.*)[)].*$" "\\1" _result_maj "${line}")
186 STRING(REGEX REPLACE "^.*[(][$][(]CCMINORV[)],(.*)[)].*$" "\\1" _result_min "${line}")
187 If(${_result_maj} EQUAL 4 OR ${_result_min} EQUAL 3)
188 Set(EXCLUDE_PART FALSE)
189 Else(${_result_maj} EQUAL 4 OR ${_result_min} EQUAL 3)
190 Set(EXCLUDE_PART TRUE)
191 EndIf(${_result_maj} EQUAL 4 OR ${_result_min} EQUAL 3)
192 EndIf(line MATCHES "^.*CCM.*$")
193
194# MESSAGE("EXCLUDE: ${EXCLUDE_PART}")
195
196 If(line MATCHES "^.*F77.*$")
197 STRING(REGEX REPLACE "^.*[(](.*),[$][(]F77[)][)].*$" "\\1" _result_f77 "${line}")
198 If(${_result_f77} STREQUAL g95)
199 Set(EXCLUDE_PART FALSE)
200 Else(${_result_f77} STREQUAL g95)
201 Set(EXCLUDE_PART TRUE)
202 EndIf(${_result_f77} STREQUAL g95)
203 EndIf(line MATCHES "^.*F77.*$")
204
205
206# MESSAGE("EXCLUDE: ${EXCLUDE_PART}")
207
208 If(line MATCHES "^.*MACOSX_MINOR.*$")
209 STRING(REGEX REPLACE "^.*[(](.*),[$][(]MACOSX_MINOR[)][)].*$" "\\1" _result_mac "${line}")
210 If(${_result_mac} EQUAL 5)
211 Set(EXCLUDE_PART FALSE)
212 Else(${_result_mac} EQUAL 5)
213 Set(EXCLUDE_PART TRUE)
214 EndIf(${_result_mac} EQUAL 5)
215 EndIf(line MATCHES "^.*MACOSX_MINOR.*$")
216
217# MESSAGE("EXCLUDE: ${EXCLUDE_PART}")
218
219 Else(line MATCHES "^ifeq.*$")
220
221 If(line MATCHES "^ifdef.*$")
222
223 Set(EXCLUDE_PART TRUE)
224
225 # line starts with if but not ifeq
226 STRING(REGEX REPLACE "ifdef" "" statement "${line}")
227
228 # Parse DATE dependent part of if statements
229 If(line MATCHES "^.*DATE_ROOT.*$")
230 STRING(REGEX REPLACE "^.*(DATE_ROOT).*$" "\\1" _result_date "${statement}")
231 If(${_result_date} STREQUAL DATE_ROOT)
232 If(DATE_FOUND)
233 Set(EXCLUDE_PART FALSE)
234 Else(DATE_FOUND)
235 Set(EXCLUDE_PART TRUE)
236 EndIf(DATE_FOUND)
237 EndIf(${_result_date} STREQUAL DATE_ROOT)
238 EndIf(line MATCHES "^.*DATE_ROOT.*$")
239
240# MESSAGE("EXCLUDE1: ${EXCLUDE_PART}")
241
242
243 If(line MATCHES "^.*ALIDEBUG.*$")
244 If($ENV{ALIDEBUG})
245 Set(EXCLUDE_PART FALSE)
246 Else($ENV{ALIDEBUG})
247 Set(EXCLUDE_PART TRUE)
248 EndIf($ENV{ALIDEBUG})
249 EndIf(line MATCHES "^.*ALIDEBUG.*$")
250
251# MESSAGE("EXCLUDE2: ${EXCLUDE_PART}")
252
253 If(line MATCHES "^.*ALIHLT_MLUCDIR.*$")
254 If($ENV{ALIHLT_MLUCDIR})
255 Set(EXCLUDE_PART FALSE)
256 Else(STREQUAL $ENV{ALIHLT_MLUCDIR})
257 Set(EXCLUDE_PART TRUE)
258 EndIf($ENV{ALIHLT_MLUCDIR})
259 EndIf(line MATCHES "^.*ALIHLT_MLUCDIR.*$")
260
261# MESSAGE("EXCLUDE3: ${EXCLUDE_PART}")
262
263
264 Else(line MATCHES "^ifdef.*$")
265 If(line MATCHES "^ifneq.*$")
266
267 If(line MATCHES "^.*FASTJET_ROOT.*$")
268 STRING(REGEX REPLACE "^.*[(][$][(]FASTJET_ROOT[)],(.*)[)].*$" "\\1" _result_fastjet "${line}")
269 If(NOT ${_length_fastjet})
270 Set(EXCLUDE_PART FALSE)
271 Else(NOT ${_length_fastjet})
272 Set(EXCLUDE_PART TRUE)
273 EndIf(NOT ${_length_fastjet})
274
275 Else(line MATCHES "^.*FASTJET_ROOT.*$")
276 If(line MATCHES "^.*findstring macosx,[$][(]ALICE_TARGET[)].*$")
277 STRING(REGEX REPLACE "^.*findstring[ ](,*),[$][(]ALICE_TARGET[)].*$" "\\1" _result_macox "${line}")
278 If(${_result_macox} MATCHES ".*macosx.*")
279 Set(EXCLUDE_PART FALSE)
280 Else(${_result_macox} MATCHES ".*macosx.*")
281 Set(EXCLUDE_PART FALSE)
282 EndIf(${_result_macox} MATCHES ".*macosx.*")
283
284 Else(line MATCHES "^.*findstring macosx,[$][(]ALICE_TARGET[)].*$")
285
286 MESSAGE(FATAL_ERROR "There is no rule how to handle ifneq statement in ${line}")
287
288 EndIf(line MATCHES "^.*findstring macosx,[$][(]ALICE_TARGET[)].*$")
289 EndIf(line MATCHES "^.*FASTJET_ROOT.*$")
290
291
292
293 Else(line MATCHES "^ifneq.*$")
294 Set(EXCLUDE_PART TRUE)
295 MESSAGE(FATAL_ERROR "There is no rule how to handle if statement in ${line}")
296 EndIf(line MATCHES "^ifneq.*$")
297
298 EndIf(line MATCHES "^ifdef.*$")
299 EndIf(line MATCHES "^ifeq.*$")
300 EndIf(line MATCHES "^if.*$")
301
302 # If the lines are inside an if statement which is not true exclude this
303 # part. In other words read only interesting part of of the file
304
305# MESSAGE("EXCLUDE: ${EXCLUDE_PART}, ${EXCLUDE_COMMENT}")
306
307 if(NOT EXCLUDE_PART AND NOT EXCLUDE_COMMENT)
308# MESSAGE("Hier")
309 If(line MATCHES "^ORGSRCS.*$")
310 STRING(REGEX REPLACE "^.*[$][(]wildcard[ ](.*)[*].*$" "\\1" orgsrc "${line}")
311 Set(_file_glob_dir ${_file_glob_dir} ${orgsrc})
312 EndIf(line MATCHES "^ORGSRCS.*$")
313
314 If(line MATCHES "^MODULE_SRCS.*$")
315 STRING(REGEX REPLACE "MODULE_SRCS" "" CXXSRCS "${line}")
316 # Check if list of source files should be build from
317 # list of header files. Add additional source files to
318 # the list if they are defined. The parser does not
319 If("${CXXSRCS}" MATCHES "[$][(]CLASS_HDRS:[.]h=[.]cxx[)]")
320 set(ADD_CXXSRCS TRUE)
321 Else("${CXXSRCS}" MATCHES "[$][(]CLASS_HDRS:[.]h=[.]cxx[)]")
322 if(ADD_CXXSRCS)
323 set(ADD_CXXSRCS TRUE)
324 else(ADD_CXXSRSC)
325 set(ADD_CXXSRCS FALSE)
326 endif(ADD_CXXSRCS)
327 EndIf("${CXXSRCS}" MATCHES "[$][(]CLASS_HDRS:[.]h=[.]cxx[)]")
328
329
330 STRING(REGEX REPLACE "[$][(]CLASS_HDRS:[.]h=[.]cxx[)]" "" CXXSRCS "${CXXSRCS}")
331 STRING(REGEX REPLACE ":=" "" CXXSRCS "${CXXSRCS}")
332 STRING(REGEX REPLACE "[+]=" "" CXXSRCS "${CXXSRCS}")
333 STRING(REGEX REPLACE "=" "" CXXSRCS "${CXXSRCS}")
334 STRING(REGEX REPLACE "[ ]+" ";" CXXSRCS "${CXXSRCS}")
335 STRING(REGEX REPLACE "^;" "" CXXSRCS "${CXXSRCS}")
336 SET(CXXSRCS_PACKAGE ${CXXSRCS_PACKAGE} ${CXXSRCS})
337 EndIf(line MATCHES "^MODULE_SRCS.*$")
338
339 If(line MATCHES "^SRCS.*$")
340 If(line MATCHES patsubst)
341 STRING(REGEX REPLACE "^.*[%][,](.*)[/][%][,].*$" "\\1" PACKAGE_DIR "${line}")
342 Else(line MATCHES patsubst)
343 STRING(REGEX REPLACE "SRCS" "" SRCS "${line}")
344 STRING(REGEX REPLACE ":=" "" SRCS "${SRCS}")
345 STRING(REGEX REPLACE "[+]=" "" SRCS "${SRCS}")
346 STRING(REGEX REPLACE "=" "" SRCS "${SRCS}")
347 STRING(REGEX REPLACE "[ ]+" ";" SRCS "${SRCS}")
348 STRING(REGEX REPLACE "^;" "" SRCS "${SRCS}")
349 SET(SRCS_PACKAGE ${SRCS_PACKAGE} ${SRCS})
350 EndIf(line MATCHES patsubst)
351 EndIf(line MATCHES "^SRCS.*$")
352
353 If(line MATCHES "^CSRCS.*$")
354 STRING(REGEX REPLACE "CSRCS" "" CSRCS "${line}")
355 STRING(REGEX REPLACE ":=" "" CSRCS "${CSRCS}")
356 STRING(REGEX REPLACE "[+]=" "" CSRCS "${CSRCS}")
357 STRING(REGEX REPLACE "=" "" CSRCS "${CSRCS}")
358 STRING(REGEX REPLACE "[ ]+" ";" CSRCS "${CSRCS}")
359 STRING(REGEX REPLACE "^;" "" CSRCS "${CSRCS}")
360 SET(CSRCS_PACKAGE ${CSRCS_PACKAGE} ${CSRCS})
361 EndIf(line MATCHES "^CSRCS.*$")
362
363 If(line MATCHES "^FSRCS.*$")
364 STRING(REGEX REPLACE "FSRCS" "" FSRCS "${line}")
365 STRING(REGEX REPLACE ":=" "" FSRCS "${FSRCS}")
366 STRING(REGEX REPLACE "[+]=" "" FSRCS "${FSRCS}")
367 STRING(REGEX REPLACE "=" "" FSRCS "${FSRCS}")
368 STRING(REGEX REPLACE "[ ]+" ";" FSRCS "${FSRCS}")
369 STRING(REGEX REPLACE "^;" "" FSRCS "${FSRCS}")
370 SET(FSRCS_PACKAGE ${FSRCS_PACKAGE} ${FSRCS})
371 EndIf(line MATCHES "^FSRCS.*$")
372
373 If(line MATCHES "^EINCLUDE.*$")
374# MESSAGE("BLA: ${line}")
375 STRING(REGEX REPLACE "EINCLUDE" "" EINCLUDE "${line}")
376 STRING(REGEX REPLACE ":=" "" EINCLUDE "${EINCLUDE}")
377 STRING(REGEX REPLACE "[+]=" "" EINCLUDE "${EINCLUDE}")
378 STRING(REGEX REPLACE "=" "" EINCLUDE "${EINCLUDE}")
379 STRING(REGEX REPLACE "[ ]+" ";" EINCLUDE "${EINCLUDE}")
380 STRING(REGEX REPLACE "^;" "" EINCLUDE "${EINCLUDE}")
381 SET(EINCLUDE_PACKAGE ${EINCLUDE_PACKAGE} ${EINCLUDE})
382# MESSAGE("EINCLUDE_PACKAGE: ${EINCLUDE_PACKAGE}")
383 EndIf(line MATCHES "^EINCLUDE.*$")
384
385 If(line MATCHES "^MODULE_DHDR.*$")
386 STRING(REGEX REPLACE "MODULE_DHDR" "" DHDR "${line}")
387 STRING(REGEX REPLACE "\t" "" DHDR "${DHDR}")
388 STRING(STRIP ${DHDR} DHDR)
389 STRING(REGEX REPLACE ":=" "" DHDR "${DHDR}")
390 STRING(REGEX REPLACE "[+]=" "" DHDR "${DHDR}")
391 STRING(REGEX REPLACE "=" "" DHDR "${DHDR}")
392 STRING(REGEX REPLACE "[ ]+" ";" DHDR "${DHDR}")
393 STRING(REGEX REPLACE "^;" "" DHDR "${DHDR}")
394 SET(DHDR_PACKAGE ${DHDR_PACKAGE} ${DHDR})
395# MESSAGE("DHDR_PACKAGE: ${DHDR_PACKAGE}")
396 EndIf(line MATCHES "^MODULE_DHDR.*$")
397
398 If(line MATCHES "^LIBHLT.*$")
399 STRING(REGEX REPLACE "^.*LIBHLT(.*)[_]VERSION.*$" "\\1" _result_library "${line}")
400 STRING(REGEX REPLACE "^.*LIBHLT.*VERSION" "" LIBHLT "${line}")
401 STRING(REGEX REPLACE ":=" "" LIBHLT "${LIBHLT}")
402 STRING(STRIP ${LIBHLT} LIBHLT)
403 set(LIBHLT_LIB_VERSION ${LIBHLT})
404 EndIf(line MATCHES "^LIBHLT.*$")
405
406 If(line MATCHES "^PACKCXXFLAGS.*$")
407 STRING(REGEX REPLACE "PACKCXXFLAGS" "" PACKCXXFLAGS "${line}")
408 STRING(REGEX REPLACE ":=" "" PACKCXXFLAGS "${PACKCXXFLAGS}")
409 STRING(REGEX REPLACE "[+]=" "" PACKCXXFLAGS "${PACKCXXFLAGS}")
410 STRING(REGEX REPLACE "^[ ]+[=]" "" PACKCXXFLAGS "${PACKCXXFLAGS}")
411 STRING(REGEX REPLACE "[ ]+" ";" PACKCXXFLAGS "${PACKCXXFLAGS}")
412 STRING(REGEX REPLACE "^;" "" PACKCXXFLAGS "${PACKCXXFLAGS}")
413 foreach(elem ${PACKCXXFLAGS})
414 STRING(REGEX MATCH "^[-]D.*$" _match_result ${elem})
415 if(${elem} STREQUAL "${_match_result}")
416# STRING(REGEX REPLACE "\"" "\\\\\"" PACKCXXFLAGS "${PACKCXXFLAGS}")
417 If(${elem} MATCHES LIBHLT)
418# STRING(REGEX REPLACE "[$][(].*[)]" "\\\\\"${LIBHLT_LIB_VERSION}\\\\\"" elem "${elem}")
419 STRING(REGEX REPLACE "[$][(].*[)]" "${LIBHLT_LIB_VERSION}" elem "${elem}")
420 EndIf(${elem} MATCHES LIBHLT)
421 SET(PACKCXXFLAGS_PACKAGE ${PACKCXXFLAGS_PACKAGE} ${elem})
422 endif(${elem} STREQUAL "${_match_result}")
423 endforeach(elem ${PACKCXXFLAGS})
424 # MESSAGE("DEFINITIONS: ${PACKCXXFLAGS_PACKAGE}")
425 EndIf(line MATCHES "^PACKCXXFLAGS.*$")
426
427 If(line MATCHES "^HLTDEFS.*$")
428 STRING(REGEX REPLACE "HLTDEFS" "" HLTDEFS "${line}")
429 STRING(REGEX REPLACE ":=" "" HLTDEFS "${HLTDEFS}")
430 STRING(REGEX REPLACE "[+]=" "" HLTDEFS "${HLTDEFS}")
431 STRING(REGEX REPLACE "=" "" HLTDEFS "${HLTDEFS}")
432 STRING(REGEX REPLACE "[ ]+" ";" HLTDEFS "${HLTDEFS}")
433 STRING(REGEX REPLACE "^;" "" HLTDEFS "${HLTDEFS}")
434 foreach(elem ${HLTDEFS})
435 STRING(REGEX MATCH "^[-]D.*$" _match_result ${elem})
436 If(${elem} STREQUAL "${_match_result}")
437 STRING(REGEX REPLACE "VERSION" "VERSION=" elem "${elem}")
438 If(${elem} MATCHES LIBHLT)
439 STRING(REGEX REPLACE "[$][(].*[)]" "${LIBHLT_LIB_VERSION}" elem "${elem}")
440 EndIf(${elem} MATCHES LIBHLT)
441 SET(PACKCXXFLAGS_PACKAGE ${PACKCXXFLAGS_PACKAGE} ${elem})
442 endif(${elem} STREQUAL "${_match_result}")
443 endforeach(elem ${HLTDEFS})
444# MESSAGE("DEFINITIONS: ${PACKCXXFLAGS_PACKAGE}")
445 EndIf(line MATCHES "^HLTDEFS.*$")
446
447 If(line MATCHES "^PACKFFLAGS.*$")
448 STRING(REGEX REPLACE "PACKFFLAGS" "" PACKFFLAGS "${line}")
449 STRING(REGEX REPLACE ":=" "" PACKFFLAGS "${PACKFFLAGS}")
450 STRING(REGEX REPLACE "[+]=" "" PACKFFLAGS "${PACKFFLAGS}")
451 STRING(REGEX REPLACE "^[ ]+[=]" "" PACKFFLAGS "${PACKFFLAGS}")
452 STRING(REGEX REPLACE "[ ]+" ";" PACKFFLAGS "${PACKFFLAGS}")
453 STRING(REGEX REPLACE "^;" "" PACKFFLAGS "${PACKFFLAGS}")
454 foreach(elem ${PACKFFLAGS})
455 STRING(REGEX MATCH "[-]O[%]" _match_result ${elem})
456 if("${_match_result}" STREQUAL "-O%")
457 set(elem "bla bla")
458 endif("${_match_result}" STREQUAL "-O%")
459 STRING(REGEX MATCH "^[-].*$" _match_result ${elem})
460 if(${elem} STREQUAL "${_match_result}")
461 SET(PACKFFLAGS_PACKAGE ${PACKFFLAGS_PACKAGE} ${elem})
462 endif(${elem} STREQUAL "${_match_result}")
463 endforeach(elem ${PACKFFLAGS})
464 # MESSAGE("FDEFINITIONS: ${PACKFFLAGS_PACKAGE}")
465 EndIf(line MATCHES "^PACKFFLAGS.*$")
466
467 If(line MATCHES "^ELIBS.*$")
468 If(NOT line MATCHES "^ELIBSCPP.*$")
469 If(NOT line MATCHES "^ELIBSDIR.*$")
470 STRING(REGEX REPLACE "ELIBS" "" ELIBS "${line}")
471 STRING(REGEX REPLACE ":=" "" ELIBS "${ELIBS}")
472 STRING(REGEX REPLACE "[+]=" "" ELIBS "${ELIBS}")
473 STRING(REGEX REPLACE "=" "" ELIBS "${ELIBS}")
474 STRING(REGEX REPLACE "[ ]+" ";" ELIBS "${ELIBS}")
475 STRING(REGEX REPLACE "^;" "" ELIBS "${ELIBS}")
476 SET(ELIBS_PACKAGE ${ELIBS_PACKAGE} ${ELIBS})
477 EndIf(NOT line MATCHES "^ELIBSDIR.*$")
478 EndIf(NOT line MATCHES "^ELIBSCPP.*$")
479 EndIf(line MATCHES "^ELIBS.*$")
480
481 If(line MATCHES "^CLASS_HDRS.*$")
482# MESSAGE("HIER")
483 If(NOT line MATCHES "^CLASS_HDRS_FJ.*$")
484# MESSAGE("Auch HIER")
485 STRING(REGEX REPLACE "CLASS_HDRS" "" HDRS "${line}")
486 STRING(REGEX REPLACE "\t" "" HDRS "${HDRS}")
487 STRING(REGEX REPLACE ":=" "" HDRS "${HDRS}")
488 STRING(REGEX REPLACE "[+]=" "" HDRS "${HDRS}")
489 STRING(REGEX REPLACE "=" "" HDRS "${HDRS}")
490 STRING(REGEX REPLACE "[ ]+" ";" HDRS "${HDRS}")
491 STRING(REGEX REPLACE "^;" "" HDRS "${HDRS}")
492 SET(HDRS_PACKAGE ${HDRS_PACKAGE} ${HDRS})
493 EndIf(NOT line MATCHES "^CLASS_HDRS_FJ.*$")
494 EndIf(line MATCHES "^CLASS_HDRS.*$")
495
496# MESSAGE("Parsed: ${line}")
497 Else(NOT EXCLUDE_PART AND NOT EXCLUDE_COMMENT)
498# MESSAGE("Not parsed: ${line}")
499 EndIf(NOT EXCLUDE_PART AND NOT EXCLUDE_COMMENT)
500
501 EndForeach(line ${contents})
502EndMacro(ParseHLTPackageFile Package)
503
504Macro(CreateHLTMainCMakeFile path)
505 set(FileName ${path}/CMakeLists.txt)
506 file(WRITE ${FileName} "# -*- mode: cmake -*-\n")
507 file(APPEND ${FileName} "# Create a library called \"lib<name>\" which includes the source files given in\n")
508 file(APPEND ${FileName} "# the array .\n")
509 file(APPEND ${FileName} "# The extension is already found. Any number of sources could be listed here.\n\n")
510 file(APPEND ${FileName} "set(INCLUDE_DIRECTORIES\n")
511 foreach(file ${EINCLUDE_SUBDIR})
512 If(file MATCHES "^.*[$].*$")
513 STRING(REGEX REPLACE "[(]" "ENV{" file "${file}")
514 STRING(REGEX REPLACE "[)]" "}" file "${file}")
515 file(APPEND ${FileName} "${file}\n")
516 Else(file MATCHES "^.*[$].*$")
517 file(APPEND ${FileName} "\${CMAKE_SOURCE_DIR}/${file}\n")
518 EndIf(file MATCHES "^.*[$].*$")
519 endforeach(file ${EINCLUDE_SUBDIR})
cf9b1bb5 520
96c0c856 521
522 if(${_dir} STREQUAL STEER OR ${_dir} STREQUAL TPC OR ${_dir} STREQUAL ALIROOT)
523 file(APPEND ${FileName} "\${CMAKE_BINARY_DIR}/STEER\n")
524 endif(${_dir} STREQUAL STEER OR ${_dir} STREQUAL TPC OR ${_dir} STREQUAL ALIROOT)
525 if(${_dir} STREQUAL RAW)
526 file(APPEND ${FileName} "\${CMAKE_SOURCE_DIR}\n")
527 endif(${_dir} STREQUAL RAW)
528
529
530 file(APPEND ${FileName} ")\n\n")
531 file(APPEND ${FileName} "include_directories(\${INCLUDE_DIRECTORIES})\n\n")
cf9b1bb5 532 file(APPEND ${FileName} "include_directories(SYSTEM \${ROOT_INCLUDE_DIR})\n\n")
96c0c856 533 file(APPEND ${FileName} "set(LINK_DIRECTORIES\n")
534 file(APPEND ${FileName} "\${ROOT_LIBRARY_DIR}\n")
535 file(APPEND ${FileName} ")\n\n")
536 file(APPEND ${FileName} "link_directories(\${LINK_DIRECTORIES})\n\n")
537
538 list(LENGTH PACKCXXFLAGS_SUBDIR definition_length)
539 if(${definition_length} GREATER 0)
540 list(REMOVE_DUPLICATES PACKCXXFLAGS_SUBDIR)
541 file(APPEND ${FileName} "Add_Definitions(\n")
542 foreach(file ${PACKCXXFLAGS_SUBDIR})
543# If(${file} MATCHES LIBHLT)
544# STRING(REGEX REPLACE "[(]" "{" file "${file}")
545# STRING(REGEX REPLACE "[)]" "}" file "${file}")
546# MESSAGE("BLA: ${file}")
547# file(APPEND ${FileName} "${${file}}\n")
548#
549# Else(${file} MATCHES LIBHLT)
550
551
552 file(APPEND ${FileName} "${file}\n")
553# EndIf(${file} MATCHES LIBHLT)
554 endforeach(file ${CXXSRCS_SUBDIR})
555 file(APPEND ${FileName} ")\n\n")
556 endif(${definition_length} GREATER 0)
557
558 file(APPEND ${FileName} "SetModule()\n\n")
559 foreach(file ${PACKAGES})
560 file(APPEND ${FileName} "include (CMake_${file}.txt)\n\n")
561 endforeach(file ${PACKAGES})
562EndMacro(CreateHLTMainCMakeFile path)
563
564Macro(CreateHLTLibPackageFile path lib)
565
566 set(FileName ${path}/CMake_${lib}.txt)
567 set(AddCSource FALSE)
568 set(AddFortranSource FALSE)
569
570 STRING(REGEX REPLACE "^lib(.*)" "\\1" _lib "${lib}")
571
572 file(WRITE ${FileName} "# -*- mode: cmake -*-\n\n")
573
574 file(APPEND ${FileName} "set(SRCS)\n\n")
575
576 list(LENGTH HDRS_PACKAGE hdrs_length)
577 if(${hdrs_length} GREATER 0)
578 file(APPEND ${FileName} "set(HDRS\n")
579 foreach(file ${HDRS_PACKAGE})
580 String(STRIP ${file} file)
581 file(APPEND ${FileName} "${PACKAGE_DIR}/${file}\n")
582 endforeach(file ${HDRS_PACKAGE})
583 file(APPEND ${FileName} ")\n\n")
584 endif(${hdrs_length} GREATER 0)
585
586
587# list(LENGTH CSRCS_PACKAGE c_length)
588# if(${c_length} GREATER 0)
589# set(AddCSource TRUE)
590# file(APPEND ${FileName} "set(CSRCS\n")
591# foreach(file ${CSRCS_PACKAGE})
592# file(APPEND ${FileName} "${file}\n")
593# endforeach(file ${CSRCS_PACKAGE})
594# file(APPEND ${FileName} ")\n\n")
595# endif(${c_length} GREATER 0)
596#
597# list(LENGTH FSRCS_PACKAGE f_length)
598# if(${f_length} GREATER 0)
599# set(AddFortranSource TRUE)
600# file(APPEND ${FileName} "set(FSRCS\n")
601# foreach(file ${FSRCS_PACKAGE})
602# file(APPEND ${FileName} "${file}\n")
603# endforeach(file ${FSRCS_PACKAGE})
604# file(APPEND ${FileName} ")\n\n")
605# endif(${f_length} GREATER 0)
606
607
608 if(ADD_CXXSRCS)
609 file(APPEND ${FileName} "# fill list of header files from list of source files\n")
610 file(APPEND ${FileName} "# by exchanging the file extension\n")
611
612 file(APPEND ${FileName} "String(REPLACE \".h\" \".cxx\" SRCS \"\${HDRS}\")\n\n")
613 list(LENGTH CXXSRCS_PACKAGE _length)
614 if(${_length} GREATER 0)
615 file(APPEND ${FileName} "set(SRCS \${SRCS}\n")
616 foreach(file ${CXXSRCS_PACKAGE})
617 String(STRIP ${file} file)
618 file(APPEND ${FileName} "${PACKAGE_DIR}/${file}\n")
619 endforeach(file ${CXXSRCS_PACKAGE})
620 file(APPEND ${FileName} ")\n\n")
621 endif(${_length} GREATER 0)
622 else(ADD_CXXSRCS)
623 list(LENGTH CXXSRCS_PACKAGE _length)
624 if(${_length} GREATER 0)
625 file(APPEND ${FileName} "set(SRCS\n")
626 foreach(file ${CXXSRCS_PACKAGE})
627 String(STRIP ${file} file)
628 file(APPEND ${FileName} "${PACKAGE_DIR}/${file}\n")
629 endforeach(file ${CXXSRCS_PACKAGE})
630 file(APPEND ${FileName} ")\n\n")
631 endif(${_length} GREATER 0)
632 endif(ADD_CXXSRCS)
633
634# If(AddCSource)
635# file(APPEND ${FileName} "Set(SRCS \${SRCS} \${CSRCS})\n\n")
636# EndIf(AddCSource)
637# If(AddFortranSource)
638# file(APPEND ${FileName} "Set(SRCS \${SRCS} \${FSRCS})\n\n")
639# EndIf(AddFortranSource)
640#
641# list(LENGTH PACKFFLAGS_PACKAGE packf_length)
642# if(${packf_length} GREATER 0)
643# file(APPEND ${FileName} "SET_SOURCE_FILES_PROPERTIES(\n")
644# file(APPEND ${FileName} "${FSRCS} PROPERTIES COMPILE_FLAGS\n")
645# file(APPEND ${FileName} "${PACKFFLAGS_PACKAGE}\n")
646# file(APPEND ${FileName} ")\n\n")
647# endif(${packf_length} GREATER 0)
648
649
650# file(APPEND ${FileName} "AddHLTLibrary(${_lib} \"\${SRCS}\" \"\${HDRS}\" \"\${DHDR_PACKAGE}\")\n")
651 file(APPEND ${FileName} "AddHLTLibrary(${_lib} \"\${SRCS}\" \"\${HDRS}\")\n")
652
653# Message("DHDR: ${_lib}, ${DHDR_PACKAGE}")
654 list(LENGTH DHDR_PACKAGE _length)
655 If(${_length} EQUAL 0)
656# STRING(REGEX REPLACE "^lib(.*)" "\\1" _lib "${lib}")
657 set(LinkDefFileName ${CMAKE_CURRENT_BINARY_DIR}/${path}/${_lib}LinkDef.h)
658# MESSAGE("LINKDEF: ${LinkDefFileName}")
659 GenerateLinkDefFile(${LinkDefFileName} "${HDRS}")
660 EndIf(${_length} EQUAL 0)
661
662EndMacro(CreateHLTLibPackageFile path lib)
663
664Macro(CreateHLTBinPackageFile path bin)
665
666 set(FileName ${path}/CMake_${bin}.txt)
667 STRING(REGEX REPLACE "^bin(.*)" "\\1" _bin "${bin}")
668
669 file(WRITE ${FileName} "# -*- mode: cmake -*-\n\n")
670
671 file(APPEND ${FileName} "set(SRCS)\n\n")
672
673 list(LENGTH SRCS_PACKAGE _length)
674 if(${_length} GREATER 0)
675 file(APPEND ${FileName} "set(SRCS\n")
676 foreach(file ${SRCS_PACKAGE})
677 file(APPEND ${FileName} "${file}\n")
678 endforeach(file ${SRCS_PACKAGE})
679 file(APPEND ${FileName} ")\n\n")
680 endif(${_length} GREATER 0)
681
682 list(LENGTH ELIBS_PACKAGE _length)
683 if(${_length} GREATER 0)
684 file(APPEND ${FileName} "set(LIBS\n")
685 foreach(file ${ELIBS_PACKAGE})
686 file(APPEND ${FileName} "${file}\n")
687 endforeach(file ${ELIBS_PACKAGE})
688 file(APPEND ${FileName} ")\n\n")
689 endif(${_length} GREATER 0)
690
691 file(APPEND ${FileName} "AddExecutable(${_bin}exe \"\${SRCS}\" \"\${LIBS}\")\n")
692EndMacro(CreateHLTBinPackageFile path bin)
693
694Macro(SpecialHLTSettingsMadeByHand lib)
695 If(${lib} STREQUAL libAliengui)
696 list(REMOVE_ITEM CXXSRCS_PACKAGE Aliengui/AliAnalysisGUIdummy.cxx)
697 EndIf(${lib} STREQUAL libAliengui)
698# If(${lib} STREQUAL libTPCmon)
699# list(REMOVE_ITEM CXXSRCS_PACKAGE AliTPCMonitorDateMonitor.cxx)
700# list(REMOVE_ITEM HDRS_PACKAGE AliTPCMonitorDateMonitor.h)
701# EndIf(${lib} STREQUAL libTPCmon)
702 If(${lib} STREQUAL libRAWDatabase)
703 list(APPEND HDRS_PACKAGE \${ROOT_INCLUDE_DIR}/TH1F.h)
704 list(APPEND H_PACKAGE \${ROOT_INCLUDE_DIR}/TH1F.h)
705 EndIf(${lib} STREQUAL libRAWDatabase)
706 If(${lib} STREQUAL liblhapdf)
707# STRING(REGEX REPLACE "[=]" "\\\\=" PACKCXXFLAGS "${PACKCXXFLAGS}")
708# STRING(REGEX REPLACE "[$][(]ALICE_ROOT[)]" "\$ENV{ALICE_ROOT}" PACKCXXFLAGS "${PACKCXXFLAGS}")
709 EndIf(${lib} STREQUAL liblhapdf)
710EndMacro(SpecialHLTSettingsMadeByHand lib)
711
712Macro(GenerateLinkDefFile FileName HDRS)
713 file(WRITE ${FileName} "//automatically generated ROOT DICT definition\n")
714 file(APPEND ${FileName} "//!!! DO NOT EDIT THIS FILE !!!\n")
715 file(APPEND ${FileName} "#ifdef __CINT__\n")
716 file(APPEND ${FileName} "#pragma link off all globals;\n")
717 file(APPEND ${FileName} "#pragma link off all classes;\n")
718 file(APPEND ${FileName} "#pragma link off all functions;\n")
719 ForEach(file ${HDRS})
720 String(STRIP ${file} file)
721# MESSAGE("${file}")
722 get_filename_component(_file ${file} NAME_WE)
723 file(APPEND ${FileName} "#pragma link C++ class ${_file}+;\n")
724 EndForEach(file ${HDRS})
725 file(APPEND ${FileName} "#endif\n")
726EndMacro(GenerateLinkDefFile FileName HDRS)
727Macro(CreateHLTSubCMakeFiles)
728
729 set(_dir HLT)
730
731 # Check if ROOT was compile with xml and alien support
732 # This is needed later to set properly the definitions during
733 # compilation
734 Execute_process(
735 COMMAND root-config --has-xml
736 OUTPUT_VARIABLE ROOT_HAS_XML
737 OUTPUT_STRIP_TRAILING_WHITESPACE)
738
739 Execute_process(
740 COMMAND root-config --has-alien
741 OUTPUT_VARIABLE ROOT_HAS_ALIEN
742 OUTPUT_STRIP_TRAILING_WHITESPACE)
743
744 # Loop over the subdirectories, extract the package files and
745 # call for each of the package files a macro which creates the
746 # corresponding CMake input files in the subdirectory
747
748 file(GLOB Package RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/${_dir}/*.pkg)
749 get_filename_component(__path ${_dir} NAME)
750 set(EINCLUDE_SUBDIR ${__path} STEER)
751 set(PACKCXXFLAGS_SUBDIR)
752 set(PACKAGES)
753
754 ParseHLTPackageFile(HLT/hlt.conf)
755 set(PACKCXXFLAGS_SUBDIR ${PACKCXXFLAGS_SUBDIR} ${PACKCXXFLAGS_PACKAGE})
756# MESSAGE("${Package}")
757
758# set(Package HLT/libHLTrec.pkg)
759 Foreach(_pack ${Package})
760 GenerateHLTInputFiles(${_pack})
761 set(EINCLUDE_SUBDIR ${EINCLUDE_SUBDIR} ${EINCLUDE_PACKAGE})
762 set(PACKCXXFLAGS_SUBDIR ${PACKCXXFLAGS_SUBDIR} ${PACKCXXFLAGS_PACKAGE})
763 EndForeach(_pack ${Package})
764 list(REMOVE_DUPLICATES EINCLUDE_SUBDIR)
765 CreateHLTMainCMakeFile(${__path})
766
767EndMacro(CreateHLTSubCMakeFiles)
768
769Macro(GenerateHLTInputFiles Package)
770
771 get_filename_component(_path ${Package} PATH)
772 get_filename_component(_name ${Package} NAME)
773
774 STRING(REGEX REPLACE "^(lib.*).pkg$" "\\1" _lib "${_name}")
775 STRING(REGEX REPLACE "^(bin.*).pkg$" "\\1" _bin "${_name}")
776
777 ParseHLTPackageFile(${Package})
778
779 If(_name MATCHES "^lib.*$")
780 Set(PACKAGES ${PACKAGES} ${_lib})
781# SpecialHLTSettingsMadeByHand(${_lib}) # Correct the Parser
782 CreateHLTLibPackageFile(${_path} ${_lib})
783# Message("Would create ${_lib}")
784 Else(_name MATCHES "^lib.*$")
785 Set(PACKAGES ${PACKAGES} ${_bin})
786 CreateHLTBinPackageFile(${_path} ${_bin})
787# Message("Would create ${_bin}")
788 EndIf(_name MATCHES "^lib.*$")
789
790EndMacro(GenerateHLTInputFiles Package)
791
792Macro(ParseHLTPackageFile Package)
793
794 Set(CXXSRCS_PACKAGE)
795 Set(CSRCS_PACKAGE)
796 Set(FSRCS_PACKAGE)
797 Set(EINCLUDE_PACKAGE)
798 Set(DHDR_PACKAGE)
799 Set(ELIBS_PACKAGE)
800 Set(HDRS_PACKAGE)
801 Set(PACKCXXFLAGS_PACKAGE)
802 Set(PACKFFLAGS_PACKAGE)
803 Set(ADD_HEADERS)
804 Set(EXCLUDE_PART FALSE)
805 Set(MATCHED FALSE)
806 Set(_file_glob FALSE)
807 Set(_file_glob_dir)
808 Set(SRCS_PACKAGE)
809
810 # Read the complete text file into variable contents
811
812 FILE(READ "${Package}" contents)
813
814 # Convert file contents into a CMake list (where each element in the list
815 # is one line of the file)
816 # Replace as first step ";" to "\". One "\" in a regex must be "\\\\"
817 # After that replace line breaks by a semicolon, which is in cmake the
818 # separator between list elements. The nice feature is that if there is a
819 # follow up line this is indicated with an "\" at the end of the line
820 # directly before the line break. In the generated string this two letters
821 # together becomes "\;" which is not the separator between two list elements
822 # but a single ";" in a liste element. With this trick one gets all
823 # follow up lines in one list element which can be parsed
824
825 STRING(REGEX REPLACE ";" "\\\\;" contents "${contents}")
826 STRING(REGEX REPLACE "\n" ";" contents "${contents}")
827
828 # Iterate over the lines of the input file
829 Foreach(line ${contents})
830
831
832 # Simple technique to handle if statements in the package files
833 # If you hit an endif or an else at the begining of a line read
834 # again lines below this point. In case of else check if it is a
835 # nested "if else if else endif endif" structure. If the correct
836 # case is already found don't read the following lines
837
838 STRING(REGEX REPLACE "\t" "" line "${line}")
839
840 If(line MATCHES "^[#].*$")
841 Set(EXCLUDE_COMMENT TRUE)
842# MESSAGE("This is a comment")
843 Else(line MATCHES "^[#].*$")
844 Set(EXCLUDE_COMMENT FALSE)
845# MESSAGE("This is not a comment")
846 EndIf(line MATCHES "^[#].*$")
847
848 If(line MATCHES "^endif.*$")
849 Set(EXCLUDE_PART FALSE)
850 EndIf(line MATCHES "^endif.*$")
851
852 If(line MATCHES "^else.*$")
853 If(NOT MATCHED)
854 Set(EXCLUDE_PART FALSE)
855 Else(NOT MATCHED)
856 Set(EXCLUDE_PART TRUE)
857 EndIf(NOT MATCHED)
858 EndIf(line MATCHES "^else.*$")
859
860 # Special handling in case ther is a if statement
861
862 If(line MATCHES "^if.*$")
863
864 # Special handling in case ther is a ifeq statement
865
866 If(line MATCHES "^ifeq.*$")
867
868 Set(EXCLUDE_PART TRUE)
869
870 # Remove ifeq from text. The rest is the interesting part of
871 # the statement
872
873 STRING(REGEX REPLACE "ifeq" "" statement "${line}")
874
875 # check if "ifeq" compares for ALICE_TARGET. If required target is
876 # equal to ALICE_TARGET, then read the following lines until endif
877 # or else is found
878 # Since only one target is possible mark that a target was already
879 # found. A short summary of regular expressions can be found at the
880 # end of this file.
881
882 If(line MATCHES "^.*ALICE_TARGET.*$")
883 STRING(REGEX REPLACE "^.*[(](.*),[$][(]ALICE_TARGET[)][)].*$" "\\1" _result "${line}")
884 If(_result STREQUAL ${ALICE_TARGET})
885 Set(MATCHED TRUE)
886 Set(EXCLUDE_PART FALSE)
887 Else(_result STREQUAL ${ALICE_TARGET})
888 Set(EXCLUDE_PART TRUE)
889 EndIf(_result STREQUAL ${ALICE_TARGET})
890 EndIf(line MATCHES "^.*ALICE_TARGET.*$")
891
892
893 # check if "if" statement checks for Alien or XML installation.
894 # If ROOT is installed with Alien or XML switch on the compile
895 # flags
896
897 If(line MATCHES "^.*CHECK.*$")
898 STRING(REGEX REPLACE "^.*[(](.*),[$][(]CHECKXML[)][)].*$" "\\1" _result_xml "${line}")
899 STRING(REGEX REPLACE "^.*[(](.*),[$][(]CHECKALIEN[)][)].*$" "\\1" _result_alien "${line}")
900 If(${_result_xml} STREQUAL ${ROOT_HAS_XML} OR ${_result_alien} STREQUAL ${ROOT_HAS_ALIEN})
901 Set(EXCLUDE_PART FALSE)
902 Else(${_result_xml} STREQUAL ${ROOT_HAS_XML} OR ${_result_alien} STREQUAL ${ROOT_HAS_ALIEN})
903 Set(EXCLUDE_PART TRUE)
904 EndIf(${_result_xml} STREQUAL ${ROOT_HAS_XML} OR ${_result_alien} STREQUAL ${ROOT_HAS_ALIEN})
905# MESSAGE("HIER")
906 EndIf(line MATCHES "^.*CHECK.*$")
907
908# MESSAGE("EXCLUDE: ${EXCLUDE_PART}")
909
910 If(line MATCHES "^.*CCM.*$")
911 STRING(REGEX REPLACE "^.*[(][$][(]CCMAJORV[)],(.*)[)].*$" "\\1" _result_maj "${line}")
912 STRING(REGEX REPLACE "^.*[(][$][(]CCMINORV[)],(.*)[)].*$" "\\1" _result_min "${line}")
913 If(${_result_maj} EQUAL 4 OR ${_result_min} EQUAL 3)
914 Set(EXCLUDE_PART FALSE)
915 Else(${_result_maj} EQUAL 4 OR ${_result_min} EQUAL 3)
916 Set(EXCLUDE_PART TRUE)
917 EndIf(${_result_maj} EQUAL 4 OR ${_result_min} EQUAL 3)
918 EndIf(line MATCHES "^.*CCM.*$")
919
920# MESSAGE("EXCLUDE: ${EXCLUDE_PART}")
921
922 If(line MATCHES "^.*F77.*$")
923 STRING(REGEX REPLACE "^.*[(](.*),[$][(]F77[)][)].*$" "\\1" _result_f77 "${line}")
924 If(${_result_f77} STREQUAL g95)
925 Set(EXCLUDE_PART FALSE)
926 Else(${_result_f77} STREQUAL g95)
927 Set(EXCLUDE_PART TRUE)
928 EndIf(${_result_f77} STREQUAL g95)
929 EndIf(line MATCHES "^.*F77.*$")
930
931
932# MESSAGE("EXCLUDE: ${EXCLUDE_PART}")
933
934 If(line MATCHES "^.*MACOSX_MINOR.*$")
935 STRING(REGEX REPLACE "^.*[(](.*),[$][(]MACOSX_MINOR[)][)].*$" "\\1" _result_mac "${line}")
936 If(${_result_mac} EQUAL 5)
937 Set(EXCLUDE_PART FALSE)
938 Else(${_result_mac} EQUAL 5)
939 Set(EXCLUDE_PART TRUE)
940 EndIf(${_result_mac} EQUAL 5)
941 EndIf(line MATCHES "^.*MACOSX_MINOR.*$")
942
943# MESSAGE("EXCLUDE: ${EXCLUDE_PART}")
944
945 Else(line MATCHES "^ifeq.*$")
946
947 If(line MATCHES "^ifdef.*$")
948
949 Set(EXCLUDE_PART TRUE)
950
951 # line starts with if but not ifeq
952 STRING(REGEX REPLACE "ifdef" "" statement "${line}")
953
954 # Parse DATE dependent part of if statements
955 If(line MATCHES "^.*DATE_ROOT.*$")
956 STRING(REGEX REPLACE "^.*(DATE_ROOT).*$" "\\1" _result_date "${statement}")
957 If(${_result_date} STREQUAL DATE_ROOT)
958 If(DATE_FOUND)
959 Set(EXCLUDE_PART FALSE)
960 Else(DATE_FOUND)
961 Set(EXCLUDE_PART TRUE)
962 EndIf(DATE_FOUND)
963 EndIf(${_result_date} STREQUAL DATE_ROOT)
964 EndIf(line MATCHES "^.*DATE_ROOT.*$")
965
966# MESSAGE("EXCLUDE1: ${EXCLUDE_PART}")
967
968
969 If(line MATCHES "^.*ALIDEBUG.*$")
970 If($ENV{ALIDEBUG})
971 Set(EXCLUDE_PART FALSE)
972 Else($ENV{ALIDEBUG})
973 Set(EXCLUDE_PART TRUE)
974 EndIf($ENV{ALIDEBUG})
975 EndIf(line MATCHES "^.*ALIDEBUG.*$")
976
977# MESSAGE("EXCLUDE2: ${EXCLUDE_PART}")
978
979 If(line MATCHES "^.*ALIHLT_MLUCDIR.*$")
980 If($ENV{ALIHLT_MLUCDIR})
981 Set(EXCLUDE_PART FALSE)
982 Else(STREQUAL $ENV{ALIHLT_MLUCDIR})
983 Set(EXCLUDE_PART TRUE)
984 EndIf($ENV{ALIHLT_MLUCDIR})
985 EndIf(line MATCHES "^.*ALIHLT_MLUCDIR.*$")
986
987# MESSAGE("EXCLUDE3: ${EXCLUDE_PART}")
988
989
990 Else(line MATCHES "^ifdef.*$")
991 If(line MATCHES "^ifneq.*$")
992
993 If(line MATCHES "^.*FASTJET_ROOT.*$")
994 STRING(REGEX REPLACE "^.*[(][$][(]FASTJET_ROOT[)],(.*)[)].*$" "\\1" _result_fastjet "${line}")
995 If(NOT ${_length_fastjet})
996 Set(EXCLUDE_PART FALSE)
997 Else(NOT ${_length_fastjet})
998 Set(EXCLUDE_PART TRUE)
999 EndIf(NOT ${_length_fastjet})
1000
1001 Else(line MATCHES "^.*FASTJET_ROOT.*$")
1002 If(line MATCHES "^.*findstring macosx,[$][(]ALICE_TARGET[)].*$")
1003 STRING(REGEX REPLACE "^.*findstring[ ](,*),[$][(]ALICE_TARGET[)].*$" "\\1" _result_macox "${line}")
1004 If(${_result_macox} MATCHES ".*macosx.*")
1005 Set(EXCLUDE_PART FALSE)
1006 Else(${_result_macox} MATCHES ".*macosx.*")
1007 Set(EXCLUDE_PART FALSE)
1008 EndIf(${_result_macox} MATCHES ".*macosx.*")
1009
1010 Else(line MATCHES "^.*findstring macosx,[$][(]ALICE_TARGET[)].*$")
1011
1012 MESSAGE(FATAL_ERROR "There is no rule how to handle ifneq statement in ${line}")
1013
1014 EndIf(line MATCHES "^.*findstring macosx,[$][(]ALICE_TARGET[)].*$")
1015 EndIf(line MATCHES "^.*FASTJET_ROOT.*$")
1016
1017
1018
1019 Else(line MATCHES "^ifneq.*$")
1020 Set(EXCLUDE_PART TRUE)
1021 MESSAGE(FATAL_ERROR "There is no rule how to handle if statement in ${line}")
1022 EndIf(line MATCHES "^ifneq.*$")
1023
1024 EndIf(line MATCHES "^ifdef.*$")
1025 EndIf(line MATCHES "^ifeq.*$")
1026 EndIf(line MATCHES "^if.*$")
1027
1028 # If the lines are inside an if statement which is not true exclude this
1029 # part. In other words read only interesting part of of the file
1030
1031# MESSAGE("EXCLUDE: ${EXCLUDE_PART}, ${EXCLUDE_COMMENT}")
1032
1033 if(NOT EXCLUDE_PART AND NOT EXCLUDE_COMMENT)
1034# MESSAGE("Hier")
1035 If(line MATCHES "^ORGSRCS.*$")
1036 STRING(REGEX REPLACE "^.*[$][(]wildcard[ ](.*)[*].*$" "\\1" orgsrc "${line}")
1037 Set(_file_glob_dir ${_file_glob_dir} ${orgsrc})
1038 EndIf(line MATCHES "^ORGSRCS.*$")
1039
1040 If(line MATCHES "^MODULE_SRCS.*$")
1041 STRING(REGEX REPLACE "MODULE_SRCS" "" CXXSRCS "${line}")
1042 # Check if list of source files should be build from
1043 # list of header files. Add additional source files to
1044 # the list if they are defined. The parser does not
1045 If("${CXXSRCS}" MATCHES "[$][(]CLASS_HDRS:[.]h=[.]cxx[)]")
1046 set(ADD_CXXSRCS TRUE)
1047 Else("${CXXSRCS}" MATCHES "[$][(]CLASS_HDRS:[.]h=[.]cxx[)]")
1048 if(ADD_CXXSRCS)
1049 set(ADD_CXXSRCS TRUE)
1050 else(ADD_CXXSRSC)
1051 set(ADD_CXXSRCS FALSE)
1052 endif(ADD_CXXSRCS)
1053 EndIf("${CXXSRCS}" MATCHES "[$][(]CLASS_HDRS:[.]h=[.]cxx[)]")
1054
1055
1056 STRING(REGEX REPLACE "[$][(]CLASS_HDRS:[.]h=[.]cxx[)]" "" CXXSRCS "${CXXSRCS}")
1057 STRING(REGEX REPLACE ":=" "" CXXSRCS "${CXXSRCS}")
1058 STRING(REGEX REPLACE "[+]=" "" CXXSRCS "${CXXSRCS}")
1059 STRING(REGEX REPLACE "=" "" CXXSRCS "${CXXSRCS}")
1060 STRING(REGEX REPLACE "[ ]+" ";" CXXSRCS "${CXXSRCS}")
1061 STRING(REGEX REPLACE "^;" "" CXXSRCS "${CXXSRCS}")
1062 SET(CXXSRCS_PACKAGE ${CXXSRCS_PACKAGE} ${CXXSRCS})
1063 EndIf(line MATCHES "^MODULE_SRCS.*$")
1064
1065 If(line MATCHES "^SRCS.*$")
1066 If(line MATCHES patsubst)
1067 STRING(REGEX REPLACE "^.*[%][,](.*)[/][%][,].*$" "\\1" PACKAGE_DIR "${line}")
1068 Else(line MATCHES patsubst)
1069 STRING(REGEX REPLACE "SRCS" "" SRCS "${line}")
1070 STRING(REGEX REPLACE ":=" "" SRCS "${SRCS}")
1071 STRING(REGEX REPLACE "[+]=" "" SRCS "${SRCS}")
1072 STRING(REGEX REPLACE "=" "" SRCS "${SRCS}")
1073 STRING(REGEX REPLACE "[ ]+" ";" SRCS "${SRCS}")
1074 STRING(REGEX REPLACE "^;" "" SRCS "${SRCS}")
1075 SET(SRCS_PACKAGE ${SRCS_PACKAGE} ${SRCS})
1076 EndIf(line MATCHES patsubst)
1077 EndIf(line MATCHES "^SRCS.*$")
1078
1079 If(line MATCHES "^CSRCS.*$")
1080 STRING(REGEX REPLACE "CSRCS" "" CSRCS "${line}")
1081 STRING(REGEX REPLACE ":=" "" CSRCS "${CSRCS}")
1082 STRING(REGEX REPLACE "[+]=" "" CSRCS "${CSRCS}")
1083 STRING(REGEX REPLACE "=" "" CSRCS "${CSRCS}")
1084 STRING(REGEX REPLACE "[ ]+" ";" CSRCS "${CSRCS}")
1085 STRING(REGEX REPLACE "^;" "" CSRCS "${CSRCS}")
1086 SET(CSRCS_PACKAGE ${CSRCS_PACKAGE} ${CSRCS})
1087 EndIf(line MATCHES "^CSRCS.*$")
1088
1089 If(line MATCHES "^FSRCS.*$")
1090 STRING(REGEX REPLACE "FSRCS" "" FSRCS "${line}")
1091 STRING(REGEX REPLACE ":=" "" FSRCS "${FSRCS}")
1092 STRING(REGEX REPLACE "[+]=" "" FSRCS "${FSRCS}")
1093 STRING(REGEX REPLACE "=" "" FSRCS "${FSRCS}")
1094 STRING(REGEX REPLACE "[ ]+" ";" FSRCS "${FSRCS}")
1095 STRING(REGEX REPLACE "^;" "" FSRCS "${FSRCS}")
1096 SET(FSRCS_PACKAGE ${FSRCS_PACKAGE} ${FSRCS})
1097 EndIf(line MATCHES "^FSRCS.*$")
1098
1099 If(line MATCHES "^EINCLUDE.*$")
1100# MESSAGE("BLA: ${line}")
1101 STRING(REGEX REPLACE "EINCLUDE" "" EINCLUDE "${line}")
1102 STRING(REGEX REPLACE ":=" "" EINCLUDE "${EINCLUDE}")
1103 STRING(REGEX REPLACE "[+]=" "" EINCLUDE "${EINCLUDE}")
1104 STRING(REGEX REPLACE "=" "" EINCLUDE "${EINCLUDE}")
1105 STRING(REGEX REPLACE "[ ]+" ";" EINCLUDE "${EINCLUDE}")
1106 STRING(REGEX REPLACE "^;" "" EINCLUDE "${EINCLUDE}")
1107 SET(EINCLUDE_PACKAGE ${EINCLUDE_PACKAGE} ${EINCLUDE})
1108# MESSAGE("EINCLUDE_PACKAGE: ${EINCLUDE_PACKAGE}")
1109 EndIf(line MATCHES "^EINCLUDE.*$")
1110
1111 If(line MATCHES "^MODULE_DHDR.*$")
1112 STRING(REGEX REPLACE "MODULE_DHDR" "" DHDR "${line}")
1113 STRING(REGEX REPLACE "\t" "" DHDR "${DHDR}")
1114 STRING(STRIP ${DHDR} DHDR)
1115 STRING(REGEX REPLACE ":=" "" DHDR "${DHDR}")
1116 STRING(REGEX REPLACE "[+]=" "" DHDR "${DHDR}")
1117 STRING(REGEX REPLACE "=" "" DHDR "${DHDR}")
1118 STRING(REGEX REPLACE "[ ]+" ";" DHDR "${DHDR}")
1119 STRING(REGEX REPLACE "^;" "" DHDR "${DHDR}")
1120 SET(DHDR_PACKAGE ${DHDR_PACKAGE} ${DHDR})
1121# MESSAGE("DHDR_PACKAGE: ${DHDR_PACKAGE}")
1122 EndIf(line MATCHES "^MODULE_DHDR.*$")
1123
1124 If(line MATCHES "^LIBHLT.*$")
1125 STRING(REGEX REPLACE "^.*LIBHLT(.*)[_]VERSION.*$" "\\1" _result_library "${line}")
1126 STRING(REGEX REPLACE "^.*LIBHLT.*VERSION" "" LIBHLT "${line}")
1127 STRING(REGEX REPLACE ":=" "" LIBHLT "${LIBHLT}")
1128 STRING(STRIP ${LIBHLT} LIBHLT)
1129 set(LIBHLT_LIB_VERSION ${LIBHLT})
1130 EndIf(line MATCHES "^LIBHLT.*$")
1131
1132 If(line MATCHES "^PACKCXXFLAGS.*$")
1133 STRING(REGEX REPLACE "PACKCXXFLAGS" "" PACKCXXFLAGS "${line}")
1134 STRING(REGEX REPLACE ":=" "" PACKCXXFLAGS "${PACKCXXFLAGS}")
1135 STRING(REGEX REPLACE "[+]=" "" PACKCXXFLAGS "${PACKCXXFLAGS}")
1136 STRING(REGEX REPLACE "^[ ]+[=]" "" PACKCXXFLAGS "${PACKCXXFLAGS}")
1137 STRING(REGEX REPLACE "[ ]+" ";" PACKCXXFLAGS "${PACKCXXFLAGS}")
1138 STRING(REGEX REPLACE "^;" "" PACKCXXFLAGS "${PACKCXXFLAGS}")
1139 foreach(elem ${PACKCXXFLAGS})
1140 STRING(REGEX MATCH "^[-]D.*$" _match_result ${elem})
1141 if(${elem} STREQUAL "${_match_result}")
1142# STRING(REGEX REPLACE "\"" "\\\\\"" PACKCXXFLAGS "${PACKCXXFLAGS}")
1143 If(${elem} MATCHES LIBHLT)
1144# STRING(REGEX REPLACE "[$][(].*[)]" "\\\\\"${LIBHLT_LIB_VERSION}\\\\\"" elem "${elem}")
1145 STRING(REGEX REPLACE "[$][(].*[)]" "${LIBHLT_LIB_VERSION}" elem "${elem}")
1146 EndIf(${elem} MATCHES LIBHLT)
1147 SET(PACKCXXFLAGS_PACKAGE ${PACKCXXFLAGS_PACKAGE} ${elem})
1148 endif(${elem} STREQUAL "${_match_result}")
1149 endforeach(elem ${PACKCXXFLAGS})
1150 # MESSAGE("DEFINITIONS: ${PACKCXXFLAGS_PACKAGE}")
1151 EndIf(line MATCHES "^PACKCXXFLAGS.*$")
1152
1153 If(line MATCHES "^HLTDEFS.*$")
1154 STRING(REGEX REPLACE "HLTDEFS" "" HLTDEFS "${line}")
1155 STRING(REGEX REPLACE ":=" "" HLTDEFS "${HLTDEFS}")
1156 STRING(REGEX REPLACE "[+]=" "" HLTDEFS "${HLTDEFS}")
1157 STRING(REGEX REPLACE "=" "" HLTDEFS "${HLTDEFS}")
1158 STRING(REGEX REPLACE "[ ]+" ";" HLTDEFS "${HLTDEFS}")
1159 STRING(REGEX REPLACE "^;" "" HLTDEFS "${HLTDEFS}")
1160 foreach(elem ${HLTDEFS})
1161 STRING(REGEX MATCH "^[-]D.*$" _match_result ${elem})
1162 If(${elem} STREQUAL "${_match_result}")
1163 STRING(REGEX REPLACE "VERSION" "VERSION=" elem "${elem}")
1164 If(${elem} MATCHES LIBHLT)
1165 STRING(REGEX REPLACE "[$][(].*[)]" "${LIBHLT_LIB_VERSION}" elem "${elem}")
1166 EndIf(${elem} MATCHES LIBHLT)
1167 SET(PACKCXXFLAGS_PACKAGE ${PACKCXXFLAGS_PACKAGE} ${elem})
1168 endif(${elem} STREQUAL "${_match_result}")
1169 endforeach(elem ${HLTDEFS})
1170# MESSAGE("DEFINITIONS: ${PACKCXXFLAGS_PACKAGE}")
1171 EndIf(line MATCHES "^HLTDEFS.*$")
1172
1173 If(line MATCHES "^PACKFFLAGS.*$")
1174 STRING(REGEX REPLACE "PACKFFLAGS" "" PACKFFLAGS "${line}")
1175 STRING(REGEX REPLACE ":=" "" PACKFFLAGS "${PACKFFLAGS}")
1176 STRING(REGEX REPLACE "[+]=" "" PACKFFLAGS "${PACKFFLAGS}")
1177 STRING(REGEX REPLACE "^[ ]+[=]" "" PACKFFLAGS "${PACKFFLAGS}")
1178 STRING(REGEX REPLACE "[ ]+" ";" PACKFFLAGS "${PACKFFLAGS}")
1179 STRING(REGEX REPLACE "^;" "" PACKFFLAGS "${PACKFFLAGS}")
1180 foreach(elem ${PACKFFLAGS})
1181 STRING(REGEX MATCH "[-]O[%]" _match_result ${elem})
1182 if("${_match_result}" STREQUAL "-O%")
1183 set(elem "bla bla")
1184 endif("${_match_result}" STREQUAL "-O%")
1185 STRING(REGEX MATCH "^[-].*$" _match_result ${elem})
1186 if(${elem} STREQUAL "${_match_result}")
1187 SET(PACKFFLAGS_PACKAGE ${PACKFFLAGS_PACKAGE} ${elem})
1188 endif(${elem} STREQUAL "${_match_result}")
1189 endforeach(elem ${PACKFFLAGS})
1190 # MESSAGE("FDEFINITIONS: ${PACKFFLAGS_PACKAGE}")
1191 EndIf(line MATCHES "^PACKFFLAGS.*$")
1192
1193 If(line MATCHES "^ELIBS.*$")
1194 If(NOT line MATCHES "^ELIBSCPP.*$")
1195 If(NOT line MATCHES "^ELIBSDIR.*$")
1196 STRING(REGEX REPLACE "ELIBS" "" ELIBS "${line}")
1197 STRING(REGEX REPLACE ":=" "" ELIBS "${ELIBS}")
1198 STRING(REGEX REPLACE "[+]=" "" ELIBS "${ELIBS}")
1199 STRING(REGEX REPLACE "=" "" ELIBS "${ELIBS}")
1200 STRING(REGEX REPLACE "[ ]+" ";" ELIBS "${ELIBS}")
1201 STRING(REGEX REPLACE "^;" "" ELIBS "${ELIBS}")
1202 SET(ELIBS_PACKAGE ${ELIBS_PACKAGE} ${ELIBS})
1203 EndIf(NOT line MATCHES "^ELIBSDIR.*$")
1204 EndIf(NOT line MATCHES "^ELIBSCPP.*$")
1205 EndIf(line MATCHES "^ELIBS.*$")
1206
1207 If(line MATCHES "^CLASS_HDRS.*$")
1208# MESSAGE("HIER")
1209 If(NOT line MATCHES "^CLASS_HDRS_FJ.*$")
1210# MESSAGE("Auch HIER")
1211 STRING(REGEX REPLACE "CLASS_HDRS" "" HDRS "${line}")
1212 STRING(REGEX REPLACE "\t" "" HDRS "${HDRS}")
1213 STRING(REGEX REPLACE ":=" "" HDRS "${HDRS}")
1214 STRING(REGEX REPLACE "[+]=" "" HDRS "${HDRS}")
1215 STRING(REGEX REPLACE "=" "" HDRS "${HDRS}")
1216 STRING(REGEX REPLACE "[ ]+" ";" HDRS "${HDRS}")
1217 STRING(REGEX REPLACE "^;" "" HDRS "${HDRS}")
1218 SET(HDRS_PACKAGE ${HDRS_PACKAGE} ${HDRS})
1219 EndIf(NOT line MATCHES "^CLASS_HDRS_FJ.*$")
1220 EndIf(line MATCHES "^CLASS_HDRS.*$")
1221
1222# MESSAGE("Parsed: ${line}")
1223 Else(NOT EXCLUDE_PART AND NOT EXCLUDE_COMMENT)
1224# MESSAGE("Not parsed: ${line}")
1225 EndIf(NOT EXCLUDE_PART AND NOT EXCLUDE_COMMENT)
1226
1227 EndForeach(line ${contents})
1228EndMacro(ParseHLTPackageFile Package)
1229
1230Macro(CreateHLTMainCMakeFile path)
1231 set(FileName ${path}/CMakeLists.txt)
1232 file(WRITE ${FileName} "# -*- mode: cmake -*-\n")
1233 file(APPEND ${FileName} "# Create a library called \"lib<name>\" which includes the source files given in\n")
1234 file(APPEND ${FileName} "# the array .\n")
1235 file(APPEND ${FileName} "# The extension is already found. Any number of sources could be listed here.\n\n")
1236 file(APPEND ${FileName} "set(INCLUDE_DIRECTORIES\n")
1237 foreach(file ${EINCLUDE_SUBDIR})
1238 If(file MATCHES "^.*[$].*$")
1239 STRING(REGEX REPLACE "[(]" "ENV{" file "${file}")
1240 STRING(REGEX REPLACE "[)]" "}" file "${file}")
1241 file(APPEND ${FileName} "${file}\n")
1242 Else(file MATCHES "^.*[$].*$")
1243 file(APPEND ${FileName} "\${CMAKE_SOURCE_DIR}/${file}\n")
1244 EndIf(file MATCHES "^.*[$].*$")
1245 endforeach(file ${EINCLUDE_SUBDIR})
96c0c856 1246 if(${_dir} STREQUAL STEER OR ${_dir} STREQUAL TPC OR ${_dir} STREQUAL ALIROOT)
1247 file(APPEND ${FileName} "\${CMAKE_BINARY_DIR}/STEER\n")
1248 endif(${_dir} STREQUAL STEER OR ${_dir} STREQUAL TPC OR ${_dir} STREQUAL ALIROOT)
1249 if(${_dir} STREQUAL RAW)
1250 file(APPEND ${FileName} "\${CMAKE_SOURCE_DIR}\n")
1251 endif(${_dir} STREQUAL RAW)
1252
1253
1254 file(APPEND ${FileName} ")\n\n")
1255 file(APPEND ${FileName} "include_directories(\${INCLUDE_DIRECTORIES})\n\n")
cf9b1bb5 1256 file(APPEND ${FileName} "include_directories(SYSTEM \${ROOT_INCLUDE_DIR})\n\n")
96c0c856 1257 file(APPEND ${FileName} "set(LINK_DIRECTORIES\n")
1258 file(APPEND ${FileName} "\${ROOT_LIBRARY_DIR}\n")
1259 file(APPEND ${FileName} ")\n\n")
1260 file(APPEND ${FileName} "link_directories(\${LINK_DIRECTORIES})\n\n")
1261
1262 list(LENGTH PACKCXXFLAGS_SUBDIR definition_length)
1263 if(${definition_length} GREATER 0)
1264 list(REMOVE_DUPLICATES PACKCXXFLAGS_SUBDIR)
1265 file(APPEND ${FileName} "Add_Definitions(\n")
1266 foreach(file ${PACKCXXFLAGS_SUBDIR})
1267# If(${file} MATCHES LIBHLT)
1268# STRING(REGEX REPLACE "[(]" "{" file "${file}")
1269# STRING(REGEX REPLACE "[)]" "}" file "${file}")
1270# MESSAGE("BLA: ${file}")
1271# file(APPEND ${FileName} "${${file}}\n")
1272#
1273# Else(${file} MATCHES LIBHLT)
1274
1275
1276 file(APPEND ${FileName} "${file}\n")
1277# EndIf(${file} MATCHES LIBHLT)
1278 endforeach(file ${CXXSRCS_SUBDIR})
1279 file(APPEND ${FileName} ")\n\n")
1280 endif(${definition_length} GREATER 0)
1281
1282 file(APPEND ${FileName} "SetModule()\n\n")
1283 foreach(file ${PACKAGES})
1284 file(APPEND ${FileName} "include (CMake_${file}.txt)\n\n")
1285 endforeach(file ${PACKAGES})
1286EndMacro(CreateHLTMainCMakeFile path)
1287
1288Macro(CreateHLTLibPackageFile path lib)
1289
1290 set(FileName ${path}/CMake_${lib}.txt)
1291 set(AddCSource FALSE)
1292 set(AddFortranSource FALSE)
1293
1294 STRING(REGEX REPLACE "^lib(.*)" "\\1" _lib "${lib}")
1295
1296 file(WRITE ${FileName} "# -*- mode: cmake -*-\n\n")
1297
1298 file(APPEND ${FileName} "set(SRCS)\n\n")
1299
1300 list(LENGTH HDRS_PACKAGE hdrs_length)
1301 if(${hdrs_length} GREATER 0)
1302 file(APPEND ${FileName} "set(HDRS\n")
1303 foreach(file ${HDRS_PACKAGE})
1304 String(STRIP ${file} file)
1305 file(APPEND ${FileName} "${PACKAGE_DIR}/${file}\n")
1306 endforeach(file ${HDRS_PACKAGE})
1307 file(APPEND ${FileName} ")\n\n")
1308 endif(${hdrs_length} GREATER 0)
1309
1310
1311# list(LENGTH CSRCS_PACKAGE c_length)
1312# if(${c_length} GREATER 0)
1313# set(AddCSource TRUE)
1314# file(APPEND ${FileName} "set(CSRCS\n")
1315# foreach(file ${CSRCS_PACKAGE})
1316# file(APPEND ${FileName} "${file}\n")
1317# endforeach(file ${CSRCS_PACKAGE})
1318# file(APPEND ${FileName} ")\n\n")
1319# endif(${c_length} GREATER 0)
1320#
1321# list(LENGTH FSRCS_PACKAGE f_length)
1322# if(${f_length} GREATER 0)
1323# set(AddFortranSource TRUE)
1324# file(APPEND ${FileName} "set(FSRCS\n")
1325# foreach(file ${FSRCS_PACKAGE})
1326# file(APPEND ${FileName} "${file}\n")
1327# endforeach(file ${FSRCS_PACKAGE})
1328# file(APPEND ${FileName} ")\n\n")
1329# endif(${f_length} GREATER 0)
1330
1331
1332 if(ADD_CXXSRCS)
1333 file(APPEND ${FileName} "# fill list of header files from list of source files\n")
1334 file(APPEND ${FileName} "# by exchanging the file extension\n")
1335
1336 file(APPEND ${FileName} "String(REPLACE \".h\" \".cxx\" SRCS \"\${HDRS}\")\n\n")
1337 list(LENGTH CXXSRCS_PACKAGE _length)
1338 if(${_length} GREATER 0)
1339 file(APPEND ${FileName} "set(SRCS \${SRCS}\n")
1340 foreach(file ${CXXSRCS_PACKAGE})
1341 String(STRIP ${file} file)
1342 file(APPEND ${FileName} "${PACKAGE_DIR}/${file}\n")
1343 endforeach(file ${CXXSRCS_PACKAGE})
1344 file(APPEND ${FileName} ")\n\n")
1345 endif(${_length} GREATER 0)
1346 else(ADD_CXXSRCS)
1347 list(LENGTH CXXSRCS_PACKAGE _length)
1348 if(${_length} GREATER 0)
1349 file(APPEND ${FileName} "set(SRCS\n")
1350 foreach(file ${CXXSRCS_PACKAGE})
1351 String(STRIP ${file} file)
1352 file(APPEND ${FileName} "${PACKAGE_DIR}/${file}\n")
1353 endforeach(file ${CXXSRCS_PACKAGE})
1354 file(APPEND ${FileName} ")\n\n")
1355 endif(${_length} GREATER 0)
1356 endif(ADD_CXXSRCS)
1357
1358# If(AddCSource)
1359# file(APPEND ${FileName} "Set(SRCS \${SRCS} \${CSRCS})\n\n")
1360# EndIf(AddCSource)
1361# If(AddFortranSource)
1362# file(APPEND ${FileName} "Set(SRCS \${SRCS} \${FSRCS})\n\n")
1363# EndIf(AddFortranSource)
1364#
1365# list(LENGTH PACKFFLAGS_PACKAGE packf_length)
1366# if(${packf_length} GREATER 0)
1367# file(APPEND ${FileName} "SET_SOURCE_FILES_PROPERTIES(\n")
1368# file(APPEND ${FileName} "${FSRCS} PROPERTIES COMPILE_FLAGS\n")
1369# file(APPEND ${FileName} "${PACKFFLAGS_PACKAGE}\n")
1370# file(APPEND ${FileName} ")\n\n")
1371# endif(${packf_length} GREATER 0)
1372
1373
1374# file(APPEND ${FileName} "AddHLTLibrary(${_lib} \"\${SRCS}\" \"\${HDRS}\" \"\${DHDR_PACKAGE}\")\n")
1375 file(APPEND ${FileName} "AddHLTLibrary(${_lib} \"\${SRCS}\" \"\${HDRS}\")\n")
1376
1377# Message("DHDR: ${_lib}, ${DHDR_PACKAGE}")
1378 list(LENGTH DHDR_PACKAGE _length)
1379 If(${_length} EQUAL 0)
1380# STRING(REGEX REPLACE "^lib(.*)" "\\1" _lib "${lib}")
1381 set(LinkDefFileName ${CMAKE_CURRENT_BINARY_DIR}/${path}/${_lib}LinkDef.h)
1382# MESSAGE("LINKDEF: ${LinkDefFileName}")
1383 GenerateLinkDefFile(${LinkDefFileName} "${HDRS}")
1384 EndIf(${_length} EQUAL 0)
1385
1386EndMacro(CreateHLTLibPackageFile path lib)
1387
1388Macro(CreateHLTBinPackageFile path bin)
1389
1390 set(FileName ${path}/CMake_${bin}.txt)
1391 STRING(REGEX REPLACE "^bin(.*)" "\\1" _bin "${bin}")
1392
1393 file(WRITE ${FileName} "# -*- mode: cmake -*-\n\n")
1394
1395 file(APPEND ${FileName} "set(SRCS)\n\n")
1396
1397 list(LENGTH SRCS_PACKAGE _length)
1398 if(${_length} GREATER 0)
1399 file(APPEND ${FileName} "set(SRCS\n")
1400 foreach(file ${SRCS_PACKAGE})
1401 file(APPEND ${FileName} "${file}\n")
1402 endforeach(file ${SRCS_PACKAGE})
1403 file(APPEND ${FileName} ")\n\n")
1404 endif(${_length} GREATER 0)
1405
1406 list(LENGTH ELIBS_PACKAGE _length)
1407 if(${_length} GREATER 0)
1408 file(APPEND ${FileName} "set(LIBS\n")
1409 foreach(file ${ELIBS_PACKAGE})
1410 file(APPEND ${FileName} "${file}\n")
1411 endforeach(file ${ELIBS_PACKAGE})
1412 file(APPEND ${FileName} ")\n\n")
1413 endif(${_length} GREATER 0)
1414
1415 file(APPEND ${FileName} "AddExecutable(${_bin}exe \"\${SRCS}\" \"\${LIBS}\")\n")
1416EndMacro(CreateHLTBinPackageFile path bin)
1417
1418Macro(SpecialHLTSettingsMadeByHand lib)
1419 If(${lib} STREQUAL libAliengui)
1420 list(REMOVE_ITEM CXXSRCS_PACKAGE Aliengui/AliAnalysisGUIdummy.cxx)
1421 EndIf(${lib} STREQUAL libAliengui)
1422# If(${lib} STREQUAL libTPCmon)
1423# list(REMOVE_ITEM CXXSRCS_PACKAGE AliTPCMonitorDateMonitor.cxx)
1424# list(REMOVE_ITEM HDRS_PACKAGE AliTPCMonitorDateMonitor.h)
1425# EndIf(${lib} STREQUAL libTPCmon)
1426 If(${lib} STREQUAL libRAWDatabase)
1427 list(APPEND HDRS_PACKAGE \${ROOT_INCLUDE_DIR}/TH1F.h)
1428 list(APPEND H_PACKAGE \${ROOT_INCLUDE_DIR}/TH1F.h)
1429 EndIf(${lib} STREQUAL libRAWDatabase)
1430 If(${lib} STREQUAL liblhapdf)
1431# STRING(REGEX REPLACE "[=]" "\\\\=" PACKCXXFLAGS "${PACKCXXFLAGS}")
1432# STRING(REGEX REPLACE "[$][(]ALICE_ROOT[)]" "\$ENV{ALICE_ROOT}" PACKCXXFLAGS "${PACKCXXFLAGS}")
1433 EndIf(${lib} STREQUAL liblhapdf)
1434EndMacro(SpecialHLTSettingsMadeByHand lib)
1435
1436Macro(GenerateLinkDefFile FileName HDRS)
1437 file(WRITE ${FileName} "//automatically generated ROOT DICT definition\n")
1438 file(APPEND ${FileName} "//!!! DO NOT EDIT THIS FILE !!!\n")
1439 file(APPEND ${FileName} "#ifdef __CINT__\n")
1440 file(APPEND ${FileName} "#pragma link off all globals;\n")
1441 file(APPEND ${FileName} "#pragma link off all classes;\n")
1442 file(APPEND ${FileName} "#pragma link off all functions;\n")
1443 ForEach(file ${HDRS})
1444 String(STRIP ${file} file)
1445# MESSAGE("${file}")
1446 get_filename_component(_file ${file} NAME_WE)
1447 file(APPEND ${FileName} "#pragma link C++ class ${_file}+;\n")
1448 EndForEach(file ${HDRS})
1449 file(APPEND ${FileName} "#endif\n")
1450EndMacro(GenerateLinkDefFile FileName HDRS)