Fixed errors in cmake build system
[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})
520 file(APPEND ${FileName} "\${ROOT_INCLUDE_DIR}\n")
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")
532 file(APPEND ${FileName} "set(LINK_DIRECTORIES\n")
533 file(APPEND ${FileName} "\${ROOT_LIBRARY_DIR}\n")
534 file(APPEND ${FileName} ")\n\n")
535 file(APPEND ${FileName} "link_directories(\${LINK_DIRECTORIES})\n\n")
536
537 list(LENGTH PACKCXXFLAGS_SUBDIR definition_length)
538 if(${definition_length} GREATER 0)
539 list(REMOVE_DUPLICATES PACKCXXFLAGS_SUBDIR)
540 file(APPEND ${FileName} "Add_Definitions(\n")
541 foreach(file ${PACKCXXFLAGS_SUBDIR})
542# If(${file} MATCHES LIBHLT)
543# STRING(REGEX REPLACE "[(]" "{" file "${file}")
544# STRING(REGEX REPLACE "[)]" "}" file "${file}")
545# MESSAGE("BLA: ${file}")
546# file(APPEND ${FileName} "${${file}}\n")
547#
548# Else(${file} MATCHES LIBHLT)
549
550
551 file(APPEND ${FileName} "${file}\n")
552# EndIf(${file} MATCHES LIBHLT)
553 endforeach(file ${CXXSRCS_SUBDIR})
554 file(APPEND ${FileName} ")\n\n")
555 endif(${definition_length} GREATER 0)
556
557 file(APPEND ${FileName} "SetModule()\n\n")
558 foreach(file ${PACKAGES})
559 file(APPEND ${FileName} "include (CMake_${file}.txt)\n\n")
560 endforeach(file ${PACKAGES})
561EndMacro(CreateHLTMainCMakeFile path)
562
563Macro(CreateHLTLibPackageFile path lib)
564
565 set(FileName ${path}/CMake_${lib}.txt)
566 set(AddCSource FALSE)
567 set(AddFortranSource FALSE)
568
569 STRING(REGEX REPLACE "^lib(.*)" "\\1" _lib "${lib}")
570
571 file(WRITE ${FileName} "# -*- mode: cmake -*-\n\n")
572
573 file(APPEND ${FileName} "set(SRCS)\n\n")
574
575 list(LENGTH HDRS_PACKAGE hdrs_length)
576 if(${hdrs_length} GREATER 0)
577 file(APPEND ${FileName} "set(HDRS\n")
578 foreach(file ${HDRS_PACKAGE})
579 String(STRIP ${file} file)
580 file(APPEND ${FileName} "${PACKAGE_DIR}/${file}\n")
581 endforeach(file ${HDRS_PACKAGE})
582 file(APPEND ${FileName} ")\n\n")
583 endif(${hdrs_length} GREATER 0)
584
585
586# list(LENGTH CSRCS_PACKAGE c_length)
587# if(${c_length} GREATER 0)
588# set(AddCSource TRUE)
589# file(APPEND ${FileName} "set(CSRCS\n")
590# foreach(file ${CSRCS_PACKAGE})
591# file(APPEND ${FileName} "${file}\n")
592# endforeach(file ${CSRCS_PACKAGE})
593# file(APPEND ${FileName} ")\n\n")
594# endif(${c_length} GREATER 0)
595#
596# list(LENGTH FSRCS_PACKAGE f_length)
597# if(${f_length} GREATER 0)
598# set(AddFortranSource TRUE)
599# file(APPEND ${FileName} "set(FSRCS\n")
600# foreach(file ${FSRCS_PACKAGE})
601# file(APPEND ${FileName} "${file}\n")
602# endforeach(file ${FSRCS_PACKAGE})
603# file(APPEND ${FileName} ")\n\n")
604# endif(${f_length} GREATER 0)
605
606
607 if(ADD_CXXSRCS)
608 file(APPEND ${FileName} "# fill list of header files from list of source files\n")
609 file(APPEND ${FileName} "# by exchanging the file extension\n")
610
611 file(APPEND ${FileName} "String(REPLACE \".h\" \".cxx\" SRCS \"\${HDRS}\")\n\n")
612 list(LENGTH CXXSRCS_PACKAGE _length)
613 if(${_length} GREATER 0)
614 file(APPEND ${FileName} "set(SRCS \${SRCS}\n")
615 foreach(file ${CXXSRCS_PACKAGE})
616 String(STRIP ${file} file)
617 file(APPEND ${FileName} "${PACKAGE_DIR}/${file}\n")
618 endforeach(file ${CXXSRCS_PACKAGE})
619 file(APPEND ${FileName} ")\n\n")
620 endif(${_length} GREATER 0)
621 else(ADD_CXXSRCS)
622 list(LENGTH CXXSRCS_PACKAGE _length)
623 if(${_length} GREATER 0)
624 file(APPEND ${FileName} "set(SRCS\n")
625 foreach(file ${CXXSRCS_PACKAGE})
626 String(STRIP ${file} file)
627 file(APPEND ${FileName} "${PACKAGE_DIR}/${file}\n")
628 endforeach(file ${CXXSRCS_PACKAGE})
629 file(APPEND ${FileName} ")\n\n")
630 endif(${_length} GREATER 0)
631 endif(ADD_CXXSRCS)
632
633# If(AddCSource)
634# file(APPEND ${FileName} "Set(SRCS \${SRCS} \${CSRCS})\n\n")
635# EndIf(AddCSource)
636# If(AddFortranSource)
637# file(APPEND ${FileName} "Set(SRCS \${SRCS} \${FSRCS})\n\n")
638# EndIf(AddFortranSource)
639#
640# list(LENGTH PACKFFLAGS_PACKAGE packf_length)
641# if(${packf_length} GREATER 0)
642# file(APPEND ${FileName} "SET_SOURCE_FILES_PROPERTIES(\n")
643# file(APPEND ${FileName} "${FSRCS} PROPERTIES COMPILE_FLAGS\n")
644# file(APPEND ${FileName} "${PACKFFLAGS_PACKAGE}\n")
645# file(APPEND ${FileName} ")\n\n")
646# endif(${packf_length} GREATER 0)
647
648
649# file(APPEND ${FileName} "AddHLTLibrary(${_lib} \"\${SRCS}\" \"\${HDRS}\" \"\${DHDR_PACKAGE}\")\n")
650 file(APPEND ${FileName} "AddHLTLibrary(${_lib} \"\${SRCS}\" \"\${HDRS}\")\n")
651
652# Message("DHDR: ${_lib}, ${DHDR_PACKAGE}")
653 list(LENGTH DHDR_PACKAGE _length)
654 If(${_length} EQUAL 0)
655# STRING(REGEX REPLACE "^lib(.*)" "\\1" _lib "${lib}")
656 set(LinkDefFileName ${CMAKE_CURRENT_BINARY_DIR}/${path}/${_lib}LinkDef.h)
657# MESSAGE("LINKDEF: ${LinkDefFileName}")
658 GenerateLinkDefFile(${LinkDefFileName} "${HDRS}")
659 EndIf(${_length} EQUAL 0)
660
661EndMacro(CreateHLTLibPackageFile path lib)
662
663Macro(CreateHLTBinPackageFile path bin)
664
665 set(FileName ${path}/CMake_${bin}.txt)
666 STRING(REGEX REPLACE "^bin(.*)" "\\1" _bin "${bin}")
667
668 file(WRITE ${FileName} "# -*- mode: cmake -*-\n\n")
669
670 file(APPEND ${FileName} "set(SRCS)\n\n")
671
672 list(LENGTH SRCS_PACKAGE _length)
673 if(${_length} GREATER 0)
674 file(APPEND ${FileName} "set(SRCS\n")
675 foreach(file ${SRCS_PACKAGE})
676 file(APPEND ${FileName} "${file}\n")
677 endforeach(file ${SRCS_PACKAGE})
678 file(APPEND ${FileName} ")\n\n")
679 endif(${_length} GREATER 0)
680
681 list(LENGTH ELIBS_PACKAGE _length)
682 if(${_length} GREATER 0)
683 file(APPEND ${FileName} "set(LIBS\n")
684 foreach(file ${ELIBS_PACKAGE})
685 file(APPEND ${FileName} "${file}\n")
686 endforeach(file ${ELIBS_PACKAGE})
687 file(APPEND ${FileName} ")\n\n")
688 endif(${_length} GREATER 0)
689
690 file(APPEND ${FileName} "AddExecutable(${_bin}exe \"\${SRCS}\" \"\${LIBS}\")\n")
691EndMacro(CreateHLTBinPackageFile path bin)
692
693Macro(SpecialHLTSettingsMadeByHand lib)
694 If(${lib} STREQUAL libAliengui)
695 list(REMOVE_ITEM CXXSRCS_PACKAGE Aliengui/AliAnalysisGUIdummy.cxx)
696 EndIf(${lib} STREQUAL libAliengui)
697# If(${lib} STREQUAL libTPCmon)
698# list(REMOVE_ITEM CXXSRCS_PACKAGE AliTPCMonitorDateMonitor.cxx)
699# list(REMOVE_ITEM HDRS_PACKAGE AliTPCMonitorDateMonitor.h)
700# EndIf(${lib} STREQUAL libTPCmon)
701 If(${lib} STREQUAL libRAWDatabase)
702 list(APPEND HDRS_PACKAGE \${ROOT_INCLUDE_DIR}/TH1F.h)
703 list(APPEND H_PACKAGE \${ROOT_INCLUDE_DIR}/TH1F.h)
704 EndIf(${lib} STREQUAL libRAWDatabase)
705 If(${lib} STREQUAL liblhapdf)
706# STRING(REGEX REPLACE "[=]" "\\\\=" PACKCXXFLAGS "${PACKCXXFLAGS}")
707# STRING(REGEX REPLACE "[$][(]ALICE_ROOT[)]" "\$ENV{ALICE_ROOT}" PACKCXXFLAGS "${PACKCXXFLAGS}")
708 EndIf(${lib} STREQUAL liblhapdf)
709EndMacro(SpecialHLTSettingsMadeByHand lib)
710
711Macro(GenerateLinkDefFile FileName HDRS)
712 file(WRITE ${FileName} "//automatically generated ROOT DICT definition\n")
713 file(APPEND ${FileName} "//!!! DO NOT EDIT THIS FILE !!!\n")
714 file(APPEND ${FileName} "#ifdef __CINT__\n")
715 file(APPEND ${FileName} "#pragma link off all globals;\n")
716 file(APPEND ${FileName} "#pragma link off all classes;\n")
717 file(APPEND ${FileName} "#pragma link off all functions;\n")
718 ForEach(file ${HDRS})
719 String(STRIP ${file} file)
720# MESSAGE("${file}")
721 get_filename_component(_file ${file} NAME_WE)
722 file(APPEND ${FileName} "#pragma link C++ class ${_file}+;\n")
723 EndForEach(file ${HDRS})
724 file(APPEND ${FileName} "#endif\n")
725EndMacro(GenerateLinkDefFile FileName HDRS)
726Macro(CreateHLTSubCMakeFiles)
727
728 set(_dir HLT)
729
730 # Check if ROOT was compile with xml and alien support
731 # This is needed later to set properly the definitions during
732 # compilation
733 Execute_process(
734 COMMAND root-config --has-xml
735 OUTPUT_VARIABLE ROOT_HAS_XML
736 OUTPUT_STRIP_TRAILING_WHITESPACE)
737
738 Execute_process(
739 COMMAND root-config --has-alien
740 OUTPUT_VARIABLE ROOT_HAS_ALIEN
741 OUTPUT_STRIP_TRAILING_WHITESPACE)
742
743 # Loop over the subdirectories, extract the package files and
744 # call for each of the package files a macro which creates the
745 # corresponding CMake input files in the subdirectory
746
747 file(GLOB Package RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/${_dir}/*.pkg)
748 get_filename_component(__path ${_dir} NAME)
749 set(EINCLUDE_SUBDIR ${__path} STEER)
750 set(PACKCXXFLAGS_SUBDIR)
751 set(PACKAGES)
752
753 ParseHLTPackageFile(HLT/hlt.conf)
754 set(PACKCXXFLAGS_SUBDIR ${PACKCXXFLAGS_SUBDIR} ${PACKCXXFLAGS_PACKAGE})
755# MESSAGE("${Package}")
756
757# set(Package HLT/libHLTrec.pkg)
758 Foreach(_pack ${Package})
759 GenerateHLTInputFiles(${_pack})
760 set(EINCLUDE_SUBDIR ${EINCLUDE_SUBDIR} ${EINCLUDE_PACKAGE})
761 set(PACKCXXFLAGS_SUBDIR ${PACKCXXFLAGS_SUBDIR} ${PACKCXXFLAGS_PACKAGE})
762 EndForeach(_pack ${Package})
763 list(REMOVE_DUPLICATES EINCLUDE_SUBDIR)
764 CreateHLTMainCMakeFile(${__path})
765
766EndMacro(CreateHLTSubCMakeFiles)
767
768Macro(GenerateHLTInputFiles Package)
769
770 get_filename_component(_path ${Package} PATH)
771 get_filename_component(_name ${Package} NAME)
772
773 STRING(REGEX REPLACE "^(lib.*).pkg$" "\\1" _lib "${_name}")
774 STRING(REGEX REPLACE "^(bin.*).pkg$" "\\1" _bin "${_name}")
775
776 ParseHLTPackageFile(${Package})
777
778 If(_name MATCHES "^lib.*$")
779 Set(PACKAGES ${PACKAGES} ${_lib})
780# SpecialHLTSettingsMadeByHand(${_lib}) # Correct the Parser
781 CreateHLTLibPackageFile(${_path} ${_lib})
782# Message("Would create ${_lib}")
783 Else(_name MATCHES "^lib.*$")
784 Set(PACKAGES ${PACKAGES} ${_bin})
785 CreateHLTBinPackageFile(${_path} ${_bin})
786# Message("Would create ${_bin}")
787 EndIf(_name MATCHES "^lib.*$")
788
789EndMacro(GenerateHLTInputFiles Package)
790
791Macro(ParseHLTPackageFile Package)
792
793 Set(CXXSRCS_PACKAGE)
794 Set(CSRCS_PACKAGE)
795 Set(FSRCS_PACKAGE)
796 Set(EINCLUDE_PACKAGE)
797 Set(DHDR_PACKAGE)
798 Set(ELIBS_PACKAGE)
799 Set(HDRS_PACKAGE)
800 Set(PACKCXXFLAGS_PACKAGE)
801 Set(PACKFFLAGS_PACKAGE)
802 Set(ADD_HEADERS)
803 Set(EXCLUDE_PART FALSE)
804 Set(MATCHED FALSE)
805 Set(_file_glob FALSE)
806 Set(_file_glob_dir)
807 Set(SRCS_PACKAGE)
808
809 # Read the complete text file into variable contents
810
811 FILE(READ "${Package}" contents)
812
813 # Convert file contents into a CMake list (where each element in the list
814 # is one line of the file)
815 # Replace as first step ";" to "\". One "\" in a regex must be "\\\\"
816 # After that replace line breaks by a semicolon, which is in cmake the
817 # separator between list elements. The nice feature is that if there is a
818 # follow up line this is indicated with an "\" at the end of the line
819 # directly before the line break. In the generated string this two letters
820 # together becomes "\;" which is not the separator between two list elements
821 # but a single ";" in a liste element. With this trick one gets all
822 # follow up lines in one list element which can be parsed
823
824 STRING(REGEX REPLACE ";" "\\\\;" contents "${contents}")
825 STRING(REGEX REPLACE "\n" ";" contents "${contents}")
826
827 # Iterate over the lines of the input file
828 Foreach(line ${contents})
829
830
831 # Simple technique to handle if statements in the package files
832 # If you hit an endif or an else at the begining of a line read
833 # again lines below this point. In case of else check if it is a
834 # nested "if else if else endif endif" structure. If the correct
835 # case is already found don't read the following lines
836
837 STRING(REGEX REPLACE "\t" "" line "${line}")
838
839 If(line MATCHES "^[#].*$")
840 Set(EXCLUDE_COMMENT TRUE)
841# MESSAGE("This is a comment")
842 Else(line MATCHES "^[#].*$")
843 Set(EXCLUDE_COMMENT FALSE)
844# MESSAGE("This is not a comment")
845 EndIf(line MATCHES "^[#].*$")
846
847 If(line MATCHES "^endif.*$")
848 Set(EXCLUDE_PART FALSE)
849 EndIf(line MATCHES "^endif.*$")
850
851 If(line MATCHES "^else.*$")
852 If(NOT MATCHED)
853 Set(EXCLUDE_PART FALSE)
854 Else(NOT MATCHED)
855 Set(EXCLUDE_PART TRUE)
856 EndIf(NOT MATCHED)
857 EndIf(line MATCHES "^else.*$")
858
859 # Special handling in case ther is a if statement
860
861 If(line MATCHES "^if.*$")
862
863 # Special handling in case ther is a ifeq statement
864
865 If(line MATCHES "^ifeq.*$")
866
867 Set(EXCLUDE_PART TRUE)
868
869 # Remove ifeq from text. The rest is the interesting part of
870 # the statement
871
872 STRING(REGEX REPLACE "ifeq" "" statement "${line}")
873
874 # check if "ifeq" compares for ALICE_TARGET. If required target is
875 # equal to ALICE_TARGET, then read the following lines until endif
876 # or else is found
877 # Since only one target is possible mark that a target was already
878 # found. A short summary of regular expressions can be found at the
879 # end of this file.
880
881 If(line MATCHES "^.*ALICE_TARGET.*$")
882 STRING(REGEX REPLACE "^.*[(](.*),[$][(]ALICE_TARGET[)][)].*$" "\\1" _result "${line}")
883 If(_result STREQUAL ${ALICE_TARGET})
884 Set(MATCHED TRUE)
885 Set(EXCLUDE_PART FALSE)
886 Else(_result STREQUAL ${ALICE_TARGET})
887 Set(EXCLUDE_PART TRUE)
888 EndIf(_result STREQUAL ${ALICE_TARGET})
889 EndIf(line MATCHES "^.*ALICE_TARGET.*$")
890
891
892 # check if "if" statement checks for Alien or XML installation.
893 # If ROOT is installed with Alien or XML switch on the compile
894 # flags
895
896 If(line MATCHES "^.*CHECK.*$")
897 STRING(REGEX REPLACE "^.*[(](.*),[$][(]CHECKXML[)][)].*$" "\\1" _result_xml "${line}")
898 STRING(REGEX REPLACE "^.*[(](.*),[$][(]CHECKALIEN[)][)].*$" "\\1" _result_alien "${line}")
899 If(${_result_xml} STREQUAL ${ROOT_HAS_XML} OR ${_result_alien} STREQUAL ${ROOT_HAS_ALIEN})
900 Set(EXCLUDE_PART FALSE)
901 Else(${_result_xml} STREQUAL ${ROOT_HAS_XML} OR ${_result_alien} STREQUAL ${ROOT_HAS_ALIEN})
902 Set(EXCLUDE_PART TRUE)
903 EndIf(${_result_xml} STREQUAL ${ROOT_HAS_XML} OR ${_result_alien} STREQUAL ${ROOT_HAS_ALIEN})
904# MESSAGE("HIER")
905 EndIf(line MATCHES "^.*CHECK.*$")
906
907# MESSAGE("EXCLUDE: ${EXCLUDE_PART}")
908
909 If(line MATCHES "^.*CCM.*$")
910 STRING(REGEX REPLACE "^.*[(][$][(]CCMAJORV[)],(.*)[)].*$" "\\1" _result_maj "${line}")
911 STRING(REGEX REPLACE "^.*[(][$][(]CCMINORV[)],(.*)[)].*$" "\\1" _result_min "${line}")
912 If(${_result_maj} EQUAL 4 OR ${_result_min} EQUAL 3)
913 Set(EXCLUDE_PART FALSE)
914 Else(${_result_maj} EQUAL 4 OR ${_result_min} EQUAL 3)
915 Set(EXCLUDE_PART TRUE)
916 EndIf(${_result_maj} EQUAL 4 OR ${_result_min} EQUAL 3)
917 EndIf(line MATCHES "^.*CCM.*$")
918
919# MESSAGE("EXCLUDE: ${EXCLUDE_PART}")
920
921 If(line MATCHES "^.*F77.*$")
922 STRING(REGEX REPLACE "^.*[(](.*),[$][(]F77[)][)].*$" "\\1" _result_f77 "${line}")
923 If(${_result_f77} STREQUAL g95)
924 Set(EXCLUDE_PART FALSE)
925 Else(${_result_f77} STREQUAL g95)
926 Set(EXCLUDE_PART TRUE)
927 EndIf(${_result_f77} STREQUAL g95)
928 EndIf(line MATCHES "^.*F77.*$")
929
930
931# MESSAGE("EXCLUDE: ${EXCLUDE_PART}")
932
933 If(line MATCHES "^.*MACOSX_MINOR.*$")
934 STRING(REGEX REPLACE "^.*[(](.*),[$][(]MACOSX_MINOR[)][)].*$" "\\1" _result_mac "${line}")
935 If(${_result_mac} EQUAL 5)
936 Set(EXCLUDE_PART FALSE)
937 Else(${_result_mac} EQUAL 5)
938 Set(EXCLUDE_PART TRUE)
939 EndIf(${_result_mac} EQUAL 5)
940 EndIf(line MATCHES "^.*MACOSX_MINOR.*$")
941
942# MESSAGE("EXCLUDE: ${EXCLUDE_PART}")
943
944 Else(line MATCHES "^ifeq.*$")
945
946 If(line MATCHES "^ifdef.*$")
947
948 Set(EXCLUDE_PART TRUE)
949
950 # line starts with if but not ifeq
951 STRING(REGEX REPLACE "ifdef" "" statement "${line}")
952
953 # Parse DATE dependent part of if statements
954 If(line MATCHES "^.*DATE_ROOT.*$")
955 STRING(REGEX REPLACE "^.*(DATE_ROOT).*$" "\\1" _result_date "${statement}")
956 If(${_result_date} STREQUAL DATE_ROOT)
957 If(DATE_FOUND)
958 Set(EXCLUDE_PART FALSE)
959 Else(DATE_FOUND)
960 Set(EXCLUDE_PART TRUE)
961 EndIf(DATE_FOUND)
962 EndIf(${_result_date} STREQUAL DATE_ROOT)
963 EndIf(line MATCHES "^.*DATE_ROOT.*$")
964
965# MESSAGE("EXCLUDE1: ${EXCLUDE_PART}")
966
967
968 If(line MATCHES "^.*ALIDEBUG.*$")
969 If($ENV{ALIDEBUG})
970 Set(EXCLUDE_PART FALSE)
971 Else($ENV{ALIDEBUG})
972 Set(EXCLUDE_PART TRUE)
973 EndIf($ENV{ALIDEBUG})
974 EndIf(line MATCHES "^.*ALIDEBUG.*$")
975
976# MESSAGE("EXCLUDE2: ${EXCLUDE_PART}")
977
978 If(line MATCHES "^.*ALIHLT_MLUCDIR.*$")
979 If($ENV{ALIHLT_MLUCDIR})
980 Set(EXCLUDE_PART FALSE)
981 Else(STREQUAL $ENV{ALIHLT_MLUCDIR})
982 Set(EXCLUDE_PART TRUE)
983 EndIf($ENV{ALIHLT_MLUCDIR})
984 EndIf(line MATCHES "^.*ALIHLT_MLUCDIR.*$")
985
986# MESSAGE("EXCLUDE3: ${EXCLUDE_PART}")
987
988
989 Else(line MATCHES "^ifdef.*$")
990 If(line MATCHES "^ifneq.*$")
991
992 If(line MATCHES "^.*FASTJET_ROOT.*$")
993 STRING(REGEX REPLACE "^.*[(][$][(]FASTJET_ROOT[)],(.*)[)].*$" "\\1" _result_fastjet "${line}")
994 If(NOT ${_length_fastjet})
995 Set(EXCLUDE_PART FALSE)
996 Else(NOT ${_length_fastjet})
997 Set(EXCLUDE_PART TRUE)
998 EndIf(NOT ${_length_fastjet})
999
1000 Else(line MATCHES "^.*FASTJET_ROOT.*$")
1001 If(line MATCHES "^.*findstring macosx,[$][(]ALICE_TARGET[)].*$")
1002 STRING(REGEX REPLACE "^.*findstring[ ](,*),[$][(]ALICE_TARGET[)].*$" "\\1" _result_macox "${line}")
1003 If(${_result_macox} MATCHES ".*macosx.*")
1004 Set(EXCLUDE_PART FALSE)
1005 Else(${_result_macox} MATCHES ".*macosx.*")
1006 Set(EXCLUDE_PART FALSE)
1007 EndIf(${_result_macox} MATCHES ".*macosx.*")
1008
1009 Else(line MATCHES "^.*findstring macosx,[$][(]ALICE_TARGET[)].*$")
1010
1011 MESSAGE(FATAL_ERROR "There is no rule how to handle ifneq statement in ${line}")
1012
1013 EndIf(line MATCHES "^.*findstring macosx,[$][(]ALICE_TARGET[)].*$")
1014 EndIf(line MATCHES "^.*FASTJET_ROOT.*$")
1015
1016
1017
1018 Else(line MATCHES "^ifneq.*$")
1019 Set(EXCLUDE_PART TRUE)
1020 MESSAGE(FATAL_ERROR "There is no rule how to handle if statement in ${line}")
1021 EndIf(line MATCHES "^ifneq.*$")
1022
1023 EndIf(line MATCHES "^ifdef.*$")
1024 EndIf(line MATCHES "^ifeq.*$")
1025 EndIf(line MATCHES "^if.*$")
1026
1027 # If the lines are inside an if statement which is not true exclude this
1028 # part. In other words read only interesting part of of the file
1029
1030# MESSAGE("EXCLUDE: ${EXCLUDE_PART}, ${EXCLUDE_COMMENT}")
1031
1032 if(NOT EXCLUDE_PART AND NOT EXCLUDE_COMMENT)
1033# MESSAGE("Hier")
1034 If(line MATCHES "^ORGSRCS.*$")
1035 STRING(REGEX REPLACE "^.*[$][(]wildcard[ ](.*)[*].*$" "\\1" orgsrc "${line}")
1036 Set(_file_glob_dir ${_file_glob_dir} ${orgsrc})
1037 EndIf(line MATCHES "^ORGSRCS.*$")
1038
1039 If(line MATCHES "^MODULE_SRCS.*$")
1040 STRING(REGEX REPLACE "MODULE_SRCS" "" CXXSRCS "${line}")
1041 # Check if list of source files should be build from
1042 # list of header files. Add additional source files to
1043 # the list if they are defined. The parser does not
1044 If("${CXXSRCS}" MATCHES "[$][(]CLASS_HDRS:[.]h=[.]cxx[)]")
1045 set(ADD_CXXSRCS TRUE)
1046 Else("${CXXSRCS}" MATCHES "[$][(]CLASS_HDRS:[.]h=[.]cxx[)]")
1047 if(ADD_CXXSRCS)
1048 set(ADD_CXXSRCS TRUE)
1049 else(ADD_CXXSRSC)
1050 set(ADD_CXXSRCS FALSE)
1051 endif(ADD_CXXSRCS)
1052 EndIf("${CXXSRCS}" MATCHES "[$][(]CLASS_HDRS:[.]h=[.]cxx[)]")
1053
1054
1055 STRING(REGEX REPLACE "[$][(]CLASS_HDRS:[.]h=[.]cxx[)]" "" CXXSRCS "${CXXSRCS}")
1056 STRING(REGEX REPLACE ":=" "" 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 SET(CXXSRCS_PACKAGE ${CXXSRCS_PACKAGE} ${CXXSRCS})
1062 EndIf(line MATCHES "^MODULE_SRCS.*$")
1063
1064 If(line MATCHES "^SRCS.*$")
1065 If(line MATCHES patsubst)
1066 STRING(REGEX REPLACE "^.*[%][,](.*)[/][%][,].*$" "\\1" PACKAGE_DIR "${line}")
1067 Else(line MATCHES patsubst)
1068 STRING(REGEX REPLACE "SRCS" "" SRCS "${line}")
1069 STRING(REGEX REPLACE ":=" "" SRCS "${SRCS}")
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 SET(SRCS_PACKAGE ${SRCS_PACKAGE} ${SRCS})
1075 EndIf(line MATCHES patsubst)
1076 EndIf(line MATCHES "^SRCS.*$")
1077
1078 If(line MATCHES "^CSRCS.*$")
1079 STRING(REGEX REPLACE "CSRCS" "" CSRCS "${line}")
1080 STRING(REGEX REPLACE ":=" "" CSRCS "${CSRCS}")
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 SET(CSRCS_PACKAGE ${CSRCS_PACKAGE} ${CSRCS})
1086 EndIf(line MATCHES "^CSRCS.*$")
1087
1088 If(line MATCHES "^FSRCS.*$")
1089 STRING(REGEX REPLACE "FSRCS" "" FSRCS "${line}")
1090 STRING(REGEX REPLACE ":=" "" FSRCS "${FSRCS}")
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 SET(FSRCS_PACKAGE ${FSRCS_PACKAGE} ${FSRCS})
1096 EndIf(line MATCHES "^FSRCS.*$")
1097
1098 If(line MATCHES "^EINCLUDE.*$")
1099# MESSAGE("BLA: ${line}")
1100 STRING(REGEX REPLACE "EINCLUDE" "" EINCLUDE "${line}")
1101 STRING(REGEX REPLACE ":=" "" EINCLUDE "${EINCLUDE}")
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 SET(EINCLUDE_PACKAGE ${EINCLUDE_PACKAGE} ${EINCLUDE})
1107# MESSAGE("EINCLUDE_PACKAGE: ${EINCLUDE_PACKAGE}")
1108 EndIf(line MATCHES "^EINCLUDE.*$")
1109
1110 If(line MATCHES "^MODULE_DHDR.*$")
1111 STRING(REGEX REPLACE "MODULE_DHDR" "" DHDR "${line}")
1112 STRING(REGEX REPLACE "\t" "" DHDR "${DHDR}")
1113 STRING(STRIP ${DHDR} DHDR)
1114 STRING(REGEX REPLACE ":=" "" 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 SET(DHDR_PACKAGE ${DHDR_PACKAGE} ${DHDR})
1120# MESSAGE("DHDR_PACKAGE: ${DHDR_PACKAGE}")
1121 EndIf(line MATCHES "^MODULE_DHDR.*$")
1122
1123 If(line MATCHES "^LIBHLT.*$")
1124 STRING(REGEX REPLACE "^.*LIBHLT(.*)[_]VERSION.*$" "\\1" _result_library "${line}")
1125 STRING(REGEX REPLACE "^.*LIBHLT.*VERSION" "" LIBHLT "${line}")
1126 STRING(REGEX REPLACE ":=" "" LIBHLT "${LIBHLT}")
1127 STRING(STRIP ${LIBHLT} LIBHLT)
1128 set(LIBHLT_LIB_VERSION ${LIBHLT})
1129 EndIf(line MATCHES "^LIBHLT.*$")
1130
1131 If(line MATCHES "^PACKCXXFLAGS.*$")
1132 STRING(REGEX REPLACE "PACKCXXFLAGS" "" PACKCXXFLAGS "${line}")
1133 STRING(REGEX REPLACE ":=" "" PACKCXXFLAGS "${PACKCXXFLAGS}")
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 foreach(elem ${PACKCXXFLAGS})
1139 STRING(REGEX MATCH "^[-]D.*$" _match_result ${elem})
1140 if(${elem} STREQUAL "${_match_result}")
1141# STRING(REGEX REPLACE "\"" "\\\\\"" PACKCXXFLAGS "${PACKCXXFLAGS}")
1142 If(${elem} MATCHES LIBHLT)
1143# STRING(REGEX REPLACE "[$][(].*[)]" "\\\\\"${LIBHLT_LIB_VERSION}\\\\\"" elem "${elem}")
1144 STRING(REGEX REPLACE "[$][(].*[)]" "${LIBHLT_LIB_VERSION}" elem "${elem}")
1145 EndIf(${elem} MATCHES LIBHLT)
1146 SET(PACKCXXFLAGS_PACKAGE ${PACKCXXFLAGS_PACKAGE} ${elem})
1147 endif(${elem} STREQUAL "${_match_result}")
1148 endforeach(elem ${PACKCXXFLAGS})
1149 # MESSAGE("DEFINITIONS: ${PACKCXXFLAGS_PACKAGE}")
1150 EndIf(line MATCHES "^PACKCXXFLAGS.*$")
1151
1152 If(line MATCHES "^HLTDEFS.*$")
1153 STRING(REGEX REPLACE "HLTDEFS" "" HLTDEFS "${line}")
1154 STRING(REGEX REPLACE ":=" "" HLTDEFS "${HLTDEFS}")
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 foreach(elem ${HLTDEFS})
1160 STRING(REGEX MATCH "^[-]D.*$" _match_result ${elem})
1161 If(${elem} STREQUAL "${_match_result}")
1162 STRING(REGEX REPLACE "VERSION" "VERSION=" elem "${elem}")
1163 If(${elem} MATCHES LIBHLT)
1164 STRING(REGEX REPLACE "[$][(].*[)]" "${LIBHLT_LIB_VERSION}" elem "${elem}")
1165 EndIf(${elem} MATCHES LIBHLT)
1166 SET(PACKCXXFLAGS_PACKAGE ${PACKCXXFLAGS_PACKAGE} ${elem})
1167 endif(${elem} STREQUAL "${_match_result}")
1168 endforeach(elem ${HLTDEFS})
1169# MESSAGE("DEFINITIONS: ${PACKCXXFLAGS_PACKAGE}")
1170 EndIf(line MATCHES "^HLTDEFS.*$")
1171
1172 If(line MATCHES "^PACKFFLAGS.*$")
1173 STRING(REGEX REPLACE "PACKFFLAGS" "" PACKFFLAGS "${line}")
1174 STRING(REGEX REPLACE ":=" "" PACKFFLAGS "${PACKFFLAGS}")
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 foreach(elem ${PACKFFLAGS})
1180 STRING(REGEX MATCH "[-]O[%]" _match_result ${elem})
1181 if("${_match_result}" STREQUAL "-O%")
1182 set(elem "bla bla")
1183 endif("${_match_result}" STREQUAL "-O%")
1184 STRING(REGEX MATCH "^[-].*$" _match_result ${elem})
1185 if(${elem} STREQUAL "${_match_result}")
1186 SET(PACKFFLAGS_PACKAGE ${PACKFFLAGS_PACKAGE} ${elem})
1187 endif(${elem} STREQUAL "${_match_result}")
1188 endforeach(elem ${PACKFFLAGS})
1189 # MESSAGE("FDEFINITIONS: ${PACKFFLAGS_PACKAGE}")
1190 EndIf(line MATCHES "^PACKFFLAGS.*$")
1191
1192 If(line MATCHES "^ELIBS.*$")
1193 If(NOT line MATCHES "^ELIBSCPP.*$")
1194 If(NOT line MATCHES "^ELIBSDIR.*$")
1195 STRING(REGEX REPLACE "ELIBS" "" ELIBS "${line}")
1196 STRING(REGEX REPLACE ":=" "" ELIBS "${ELIBS}")
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 SET(ELIBS_PACKAGE ${ELIBS_PACKAGE} ${ELIBS})
1202 EndIf(NOT line MATCHES "^ELIBSDIR.*$")
1203 EndIf(NOT line MATCHES "^ELIBSCPP.*$")
1204 EndIf(line MATCHES "^ELIBS.*$")
1205
1206 If(line MATCHES "^CLASS_HDRS.*$")
1207# MESSAGE("HIER")
1208 If(NOT line MATCHES "^CLASS_HDRS_FJ.*$")
1209# MESSAGE("Auch HIER")
1210 STRING(REGEX REPLACE "CLASS_HDRS" "" HDRS "${line}")
1211 STRING(REGEX REPLACE "\t" "" HDRS "${HDRS}")
1212 STRING(REGEX REPLACE ":=" "" 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 SET(HDRS_PACKAGE ${HDRS_PACKAGE} ${HDRS})
1218 EndIf(NOT line MATCHES "^CLASS_HDRS_FJ.*$")
1219 EndIf(line MATCHES "^CLASS_HDRS.*$")
1220
1221# MESSAGE("Parsed: ${line}")
1222 Else(NOT EXCLUDE_PART AND NOT EXCLUDE_COMMENT)
1223# MESSAGE("Not parsed: ${line}")
1224 EndIf(NOT EXCLUDE_PART AND NOT EXCLUDE_COMMENT)
1225
1226 EndForeach(line ${contents})
1227EndMacro(ParseHLTPackageFile Package)
1228
1229Macro(CreateHLTMainCMakeFile path)
1230 set(FileName ${path}/CMakeLists.txt)
1231 file(WRITE ${FileName} "# -*- mode: cmake -*-\n")
1232 file(APPEND ${FileName} "# Create a library called \"lib<name>\" which includes the source files given in\n")
1233 file(APPEND ${FileName} "# the array .\n")
1234 file(APPEND ${FileName} "# The extension is already found. Any number of sources could be listed here.\n\n")
1235 file(APPEND ${FileName} "set(INCLUDE_DIRECTORIES\n")
1236 foreach(file ${EINCLUDE_SUBDIR})
1237 If(file MATCHES "^.*[$].*$")
1238 STRING(REGEX REPLACE "[(]" "ENV{" file "${file}")
1239 STRING(REGEX REPLACE "[)]" "}" file "${file}")
1240 file(APPEND ${FileName} "${file}\n")
1241 Else(file MATCHES "^.*[$].*$")
1242 file(APPEND ${FileName} "\${CMAKE_SOURCE_DIR}/${file}\n")
1243 EndIf(file MATCHES "^.*[$].*$")
1244 endforeach(file ${EINCLUDE_SUBDIR})
1245 file(APPEND ${FileName} "\${ROOT_INCLUDE_DIR}\n")
1246
1247 if(${_dir} STREQUAL STEER OR ${_dir} STREQUAL TPC OR ${_dir} STREQUAL ALIROOT)
1248 file(APPEND ${FileName} "\${CMAKE_BINARY_DIR}/STEER\n")
1249 endif(${_dir} STREQUAL STEER OR ${_dir} STREQUAL TPC OR ${_dir} STREQUAL ALIROOT)
1250 if(${_dir} STREQUAL RAW)
1251 file(APPEND ${FileName} "\${CMAKE_SOURCE_DIR}\n")
1252 endif(${_dir} STREQUAL RAW)
1253
1254
1255 file(APPEND ${FileName} ")\n\n")
1256 file(APPEND ${FileName} "include_directories(\${INCLUDE_DIRECTORIES})\n\n")
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)