Introduce smell generator plus some small fixes
[u/mrichter/AliRoot.git] / cmake / ALICE_CMake.cmake
CommitLineData
62e74968 1# -*- mode: cmake -*-
2
6db31708 3# AliRoot Build System Utility Macro and Function definitions
4#
5# Author: Johny Jose (johny.jose@cern.ch)
6# Port of previous Makefile build to cmake
7
8cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
9
10macro(ALICE_DevFlagsOutput)
11
12 if(ALICEDEV STREQUAL "YES")
13 message(STATUS "FFLAGS : ${FFLAGS}")
14 message(STATUS "CXXFLAGS : ${CXXFLAGS}")
15 message(STATUS "CFLAGS : ${CFLAGS}")
16 message(STATUS "SOFLAGS : ${SOFLAGS}")
17 message(STATUS "LDFLAGS : ${LDFLAGS}")
18 message(STATUS "SHLIB : ${SHLIB}")
19 message(STATUS "SYSLIBS : ${SYSLIBS}")
20 message(STATUS "CINTFLAGS : ${CINTFLAGS}")
21 endif(ALICEDEV STREQUAL "YES")
22
23endmacro(ALICE_DevFlagsOutput)
24
25function(ALICE_CleanOutput _output input)
26
60154b69 27 string(REGEX REPLACE "\n" " " clean "${input}")
6db31708 28 set(${_output} ${clean} PARENT_SCOPE)
29
30endfunction(ALICE_CleanOutput)
31
32function(ALICE_CorrectPaths _output value )
33
34 set(corrected)
35 foreach(path ${value})
36 set(external)
60154b69 37 string(REGEX MATCH "^/" external "${path}")
6db31708 38 if(NOT external)
39 list(APPEND corrected "${CMAKE_SOURCE_DIR}/${path}" )
40 else()
60154b69 41 list(APPEND corrected "${path}")
6db31708 42 endif(NOT external)
43 endforeach(path)
44 set(${_output} ${corrected} PARENT_SCOPE)
45
46endfunction(ALICE_CorrectPaths)
47
48function(ALICE_Format _output prefix suffix input)
49
50# DevNotes - input should be put in quotes or the complete list does not get passed to the function
51 set(format)
52 foreach(arg ${input})
53 set(item ${arg})
54 if(prefix)
60154b69 55 string(REGEX MATCH "^${prefix}" pre "${arg}")
6db31708 56 endif(prefix)
57 if(suffix)
60154b69 58 string(REGEX MATCH "${suffix}$" suf "${arg}")
6db31708 59 endif(suffix)
60 if(NOT pre)
61 set(item "${prefix}${item}")
62 endif(NOT pre)
63 if(NOT suf)
64 set(item "${item}${suffix}")
65 endif(NOT suf)
66 list(APPEND format ${item})
67 endforeach(arg)
68 set(${_output} ${format} PARENT_SCOPE)
69
70endfunction(ALICE_Format)
71
72function(ALICE_CheckLibraries _output input)
73
74 set(format)
75 foreach(arg ${input})
76 set(item ${arg})
60154b69 77 string(REGEX MATCH "^(/|-)" preformatted "${item}")
6db31708 78 if(NOT preformatted)
79 set(item "-l${item}")
80 endif(NOT preformatted)
81 list(APPEND format ${item})
82 endforeach(arg)
83 set(${_output} ${format} PARENT_SCOPE)
84
85endfunction(ALICE_CheckLibraries)
86
87function(ALICE_RootConfig _output parameters)
88
89 if(ROOT_CONFIG)
90 execute_process(COMMAND ${ROOT_CONFIG} ${parameters} OUTPUT_VARIABLE result ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE )
91 if(error)
92 message(FATAL_ERROR "root-config ERROR : ${error}")
93 endif(error)
94 ALICE_CleanOutput(result "${result}")
95 set(${_output} "${result}" PARENT_SCOPE)
96 else()
97 message(FATAL_ERROR "root-config not found")
98 endif(ROOT_CONFIG)
99
100endfunction(ALICE_RootConfig)
101
102macro(ALICE_CheckOutOfSourceBuild)
103
104 #Check if previous in-source build failed
105 if(EXISTS ${CMAKE_SOURCE_DIR}/CMakeCache.txt OR EXISTS ${CMAKE_SOURCE_DIR}/CMakeFiles)
106 message(FATAL_ERROR "CMakeCache.txt or CMakeFiles exists in source directory! Please remove them before running cmake $ALICE_ROOT")
107 endif(EXISTS ${CMAKE_SOURCE_DIR}/CMakeCache.txt OR EXISTS ${CMAKE_SOURCE_DIR}/CMakeFiles)
108
109 #Get Real Paths of the source and binary directories
110 get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH)
111 get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH)
112
113 #Check for in-source builds
114 if(${srcdir} STREQUAL ${bindir})
115 message(FATAL_ERROR "AliRoot cannot be built in-source! Please run cmake $ALICE_ROOT outside the source directory")
116 endif(${srcdir} STREQUAL ${bindir})
117
118endmacro(ALICE_CheckOutOfSourceBuild)
119
120macro(ALICE_ConfigureCompiler)
121
122 if(ALIDEBUG STREQUAL "YES")
123 set(ALICE_TARGET ${ALICE_TARGET}DEBUG)
124 message("Befor ${CXXFLAGS}")
60154b69 125 string(REGEX MATCHALL "-O[^ ]*" FFLAGS "${FFLAGS}")
126 string(REGEX MATCHALL "-O[^ ]*" CXXFLAGS "${CXXFLAGS}")
6db31708 127 message("After ${CXXFLAGS}")
60154b69 128 string(REGEX MATCHALL "-O[^ ]*" CFLAGS "${CFLAGS}")
129 string(REGEX MATCHALL "-O[^ ]*" SOFLAGS "${SOFLAGS}")
130 string(REGEX MATCHALL "-O[^ ]*" LDFLAGS "${LDFLAGS}")
6db31708 131 set(FFLAGS "-g ${FFLAGS}")
132 set(CXXFLAGS "-g ${CXXFLAGS}")
133 set(CFLAGS "-g ${CFLAGS}")
134 set(SOFLAGS "-g ${SOFLAGS}")
135 set(LDFLAGS "-g ${LDFLAGS}")
136 endif(ALIDEBUG STREQUAL "YES")
137
138 if(ALIPROFILE STREQUAL "YES")
139 set(ALICE_TARGET ${ALICE_TARGET}PROF)
140 set(FFLAGS "-pg ${FFLAGS}")
141 set(CXXFLAGS "-pg ${CXXFLAGS}")
142 set(CFLAGS "-pg ${CFLAGS}")
143 set(SOFLAGS "-pg ${SOFLAGS}")
144 set(LDFLAGS "-pg ${LDFLAGS}")
145 endif(ALIPROFILE STREQUAL "YES")
146
147 ALICE_RootConfig(RCFLAGS --auxcflags)
148 ALICE_RootConfig(RLFLAGS --ldflags)
149
150 set(CXXFLAGS "${CXXFLAGS} ${RCFLAGS}")
151 set(CFLAGS "${CFLAGS} ${RCFLAGS}")
152 set(SOFLAGS "${SOFLAGS} ${RLFLAGS}")
153 set(LDFLAGS "${LDFLAGS} ${RLFLAGS}")
154
155 if(NOT ALICXXWARN STREQUAL "NO")
156 set(CXXFLAGS "${CXXFLAGS} ${CXXWARN}")
157 endif(NOT ALICXXWARN STREQUAL "NO")
158
159 set(CXXFLAGS "${DATEFLAGS} ${CXXFLAGS}")
160 set(CFLAGS "${DATEFLAGS} ${CFLAGS}")
161 set(CINTFLAGS "${DATEFLAGS}")
162
163endmacro(ALICE_ConfigureCompiler)
164
165macro(ALICE_ConfigurePlatform)
166
167 ALICE_GetTarget()
168 include("CMake${ALICE_TARGET}")
169
170endmacro(ALICE_ConfigurePlatform)
171
172macro(ALICE_GetTarget)
173
174 #Set ALICE_TARGET if it has not been set yet
175 if(NOT ALICE_TARGET)
176 set(ALICE_TARGET $ENV{ALICE_TARGET})
177 #If ALICE_TARGET is not defined assign default values
178 if(NOT ALICE_TARGET)
179 message(WARNING "Environment variable ALICE_TARGET is not set ! Setting to default value.")
180 ALICE_RootConfig(ALICE_TARGET --arch)
181 message("ALICE_TARGET set to ${ALICE_TARGET}")
182 endif(NOT ALICE_TARGET)
183 endif(NOT ALICE_TARGET)
184
185endmacro(ALICE_GetTarget)
186
187macro(ALICE_ResetPackage)
188
189 set(MODDIR ${MODULE})
190 set(MODDIRI ${PROJECT_SOURCE_DIR}/${MODULE})
191
192 set(SRCS)
193 set(HDRS)
194 set(FSRCS)
195 set(DHDR)
196 set(CSRCS)
197 set(CHDRS)
198 set(EINCLUDE)
199 set(EDEFINE)
200 set(ELIBS)
201 set(ELIBSDIR)
202 set(PACKFFLAGS)
203 set(PACKCXXFLAGS)
204 set(PACKCFLAGS)
205 set(PACKDYFLAGS)
206 set(PACKSOFLAGS)
207 set(PACKLDFLAGS)
208 set(PACKBLIBS)
209 set(EXPORT)
210 set(EHDRS)
211 set(CINTHDRS)
212 set(CINTAUTOLINK)
213 set(ARLIBS)
214 set(SHLIBS)
215
216 #HLT Variables
217 set(MODULE_HDRS)
218 set(MODULE_SRCS)
219 set(MODULE_DHDR)
220 set(CLASS_HDRS)
221 set(LIBRARY_DEP)
222 set(HLTDEFS)
223 set(HLTSOFLAGS)
224
225
226 set(PSRCS)
227 set(PHDRS)
228 set(PFSRCS)
229 set(PDHDR)
230 set(PCSRCS)
231 set(PCHDRS)
232 set(PEINCLUDE)
233 set(PEDEFINE)
234 set(PELIBS)
235 set(PELIBSDIR)
236 set(PPACKFFLAGS)
237 set(PPACKCXXFLAGS)
238 set(PPACKCFLAGS)
239 set(PPACKDYFLAGS)
240 set(PPACKSOFLAGS)
241 set(PPACKLDFLAGS)
242 set(PPACKBLIBS)
243 set(PEXPORT)
244 set(PEHDRS)
245 set(PCINTHDRS)
246 set(PCINTAUTOLINK)
247 set(PARLIBS)
248 set(PSHLIBS)
249 set(PDS)
250
251endmacro(ALICE_ResetPackage)
252
253function(ALICE_SetPackageVariable _var ext setvalue unsetvalue )
254
255#DevNotes - setvalue and unsetcalue should both be put in quotes or cmake throws an error if they have undefined values
256 if(setvalue)
257 set(${_var} ${setvalue} PARENT_SCOPE)
258 set(${PACKAGE}${ext} ${setvalue} PARENT_SCOPE)
259 else()
260 set(${_var} ${unsetvalue} PARENT_SCOPE)
261 set(${PACKAGE}${ext} ${unsetvalue} PARENT_SCOPE)
262 endif(setvalue)
263
264endfunction(ALICE_SetPackageVariable)
265
266macro(ALICE_BuildPackage)
267
268 list(APPEND EINCLUDE STEER)
269
270 ALICE_SetPackageVariable(PFFLAGS "FFLAGS" "${PACKFFLAGS}" "${FFLAGS}")
271 ALICE_SetPackageVariable(PCFLAGS "CFLAGS" "${PACKCFLAGS}" "${CFLAGS}")
272 ALICE_SetPackageVariable(PCXXFLAGS "CXXFLAGS" "${PACKCXXFLAGS}" "${CXXFLAGS}")
273 ALICE_SetPackageVariable(PSOFLAGS "SOFLAGS" "${PACKSOFLAGS}" "${SOFLAGS}")
274 ALICE_SetPackageVariable(PLDFLAGS "LDFLAGS" "${PACKLDFLAGS}" "${LDFLAGS}")
275 ALICE_SetPackageVariable(PDCXXFLAGS "DCXXFLAGS" "${PACKDCXXFLAGS}" "${CXXFLAGSNO}")
276 ALICE_SetPackageVariable(PBLIBS "BLIBS" "${PACKBLIBS}" "${LIBS}")
277
278 set(WITHDICT)
279 if(DHDR OR CINTAUTOLINK)
280 set(WITHDICT TRUE)
281 endif(DHDR OR CINTAUTOLINK)
282
283 ALICE_SetPackageVariable(PEDEFINE "EDEFINE" "${EDEFINE}" "${EDEFINE}")
284 ALICE_SetPackageVariable(PEXPORT "EXPORT" "${EXPORT}" "${EXPORT}")
285 ALICE_SetPackageVariable(PEXPORTDEST "EXPORTDEST" "${CMAKE_INCLUDE_EXPORT_DIRECTORY}" "${CMAKE_INCLUDE_EXPORT_DIRECTORY}")
286 ALICE_SetPackageVariable(PINC "INC" "${EINCLUDE};${MODULE}" "${EINCLUDE};${MODULE}")
287 ALICE_SetPackageVariable(PELIBS "ELIBS" "${ELIBS}" "${ELIBS}")
288 ALICE_SetPackageVariable(PELIBSDIR "ELIBSDIR" "${ELIBSDIR}" "${ELIBSDIR}")
289
290 ALICE_SetPackageVariable(PCS "CS" "${CSRCS}" "${CSRCS}")
291 ALICE_SetPackageVariable(PCH "CH" "${CHDRS}" "${CHDRS}")
292
293 ALICE_SetPackageVariable(PFS "FS" "${FSRCS}" "${FSRCS}")
294
295 ALICE_SetPackageVariable(PS "S" "${SRCS}" "${SRCS}")
296 ALICE_SetPackageVariable(PH "H" "${HDRS} ${EHDRS}" "${HDRS} ${EHDRS}")
297 ALICE_SetPackageVariable(PCINTHDRS "CINTHDRS" "${CINTHDRS}" "${PH}")
298
299 string( REPLACE ".h" "" PCINTCLASSES "${PCINTHDRS}")
300 set ( ${PACKAGE}CINTCLASSES ${PCINTCLASSES})
301
302 ALICE_SetPackageVariable(PDH "DH" "${DHDR}" "")
303
304 if(CINTAUTOLINK)
305 ALICE_SetPackageVariable(PDAL "DAL" "${CMAKE_CURRENT_BINARY_DIR}/G__${PACKAGE}AutoLinkDef.h" "${CMAKE_CURRENT_BINARY_DIR}/G__${PACKAGE}AutoLinkDef.h")
306 ALICE_SetPackageVariable(PDH "DH" "${PDAL}" "${PDAL}")
307 ALICE_GenerateLinkDef()
308 endif(CINTAUTOLINK)
309
310 if(lib)
45526b5e 311 list(APPEND PMLIBS ${PACKAGE})
6db31708 312 list(APPEND ALLLIBS ${PACKAGE})
529f129e 313 list(APPEND PMALIBS ${PACKAGE}-static)
314 list(APPEND ALLALIBS ${PACKAGE}-static)
6db31708 315 list(APPEND BINLIBS ${PACKAGE})
316 else()
317 list(APPEND ALLEXECS ${PACKAGE})
318 endif(lib)
45526b5e 319 set(${MODULE}ALIBS "${PMALIBS}" PARENT_SCOPE)
320 set(${MODULE}LIBS "${PMLIBS}" PARENT_SCOPE)
321 set(${MODULE}INC "${EINCLUDE}" PARENT_SCOPE)
6db31708 322 list(APPEND INCLUDEFILES ${PEXPORTDEST})
6db31708 323 if(WITHDICT)
324 ALICE_SetPackageVariable(PDS "DS" "G__${PACKAGE}.cxx" "G__${PACKAGE}.cxx")
325 ALICE_GenerateDictionary()
326 else()
327 if(lib)
328 message(STATUS "No dictionary generated for ${PACKAGE}")
329 endif(lib)
330 endif(WITHDICT)
6db31708 331 if(PS OR PCS OR PFS)
332 if(lib)
333 ALICE_BuildLibrary()
334 elseif(bin)
335 ALICE_BuildExecutable()
336 endif(lib)
337 endif(PS OR PCS OR PFS)
e93f6949 338 ALICE_CopyHeaders()
6a9e2760 339 ALICE_BuildPAR()
6db31708 340
341endmacro(ALICE_BuildPackage)
342
343
344macro(ALICE_BuildModule)
345
346 add_definitions(-D_MODULE="${MODULE}")
347 foreach(PACKAGEFILE ${PACKAGES})
348 set(lib)
349 set(bin)
60154b69 350 string(REGEX MATCH "CMakelib" lib "${PACKAGEFILE}")
351 string(REGEX MATCH "CMakebin" bin "${PACKAGEFILE}")
6db31708 352 get_filename_component(PACKAGE ${PACKAGEFILE} NAME)
60154b69 353 string(REGEX REPLACE "^CMake(lib|bin)(.*)\\.pkg" "\\2" PACKAGE "${PACKAGE}")
6db31708 354 if(ALICEDEV)
355 message("Adding package ${PACKAGE} in ${MODULE}")
356 endif(ALICEDEV)
357 ALICE_ResetPackage()
358 include(${PACKAGEFILE})
359 ALICE_BuildPackage()
360
361 get_property(EXCLUDEPACKAGE TARGET ${PACKAGE} PROPERTY EXCLUDE_FROM_ALL)
362 if(NOT EXCLUDEPACKAGE)
363 install(TARGETS ${PACKAGE}
24b052aa 364 RUNTIME DESTINATION bin/tgt_${ALICE_TARGET}
365 LIBRARY DESTINATION lib/tgt_${ALICE_TARGET}
366 ARCHIVE DESTINATION bin/tgt_${ALICE_TARGET})
6db31708 367 endif(NOT EXCLUDEPACKAGE)
368 endforeach(PACKAGEFILE)
e93f6949 369 ALICE_CheckModule()
6db31708 370endmacro(ALICE_BuildModule)
371
372macro(ALICE_GenerateDictionary)
373
374 if(ALICEDEV STREQUAL "YES")
375 message("Generating Dictionary rule for ${PACKAGE}")
376 message("${ROOTCINT} -f ${PDS} -c ${PEDEFINE} ${CINTFLAGS} ${PINC} ${PCINTHDRS} ${PDH}")
377 endif(ALICEDEV STREQUAL "YES")
378
379 # Split up all arguments
380
381 set(DEDEFINE ${PEDEFINE})
382 set(DCINTFLAGS ${CINTFLAGS})
383 set(DINC ${PINC})
384 set(DCINTHDRS ${PCINTHDRS})
385 set(DDH ${PDH})
386 separate_arguments(DEDEFINE)
387 separate_arguments(DCINTFLAGS)
388 separate_arguments(DINC)
389 separate_arguments(DCINTHDRS)
390 separate_arguments(DDH)
391 # Format neccesary arguments
392 ALICE_Format(DINC "-I" "" "${DINC};${CMAKE_INCLUDE_EXPORT_DIRECTORY}")
393 set_source_files_properties(${PDS} PROPERTIES GENERATED TRUE)
be33cb74 394 set_source_files_properties(${PDS} PROPERTIES COMPILE_FLAGS "-w")
6db31708 395 add_custom_command(OUTPUT ${PDS}
396 COMMAND cd ${PROJECT_SOURCE_DIR} && ${ROOTCINT} -f ${CMAKE_CURRENT_BINARY_DIR}/${PDS} -c -D_MODULE=\\\"${MODULE}\\\" ${DEDEFINE} ${DCINTFLAGS} ${DINC} ${DCINTHDRS} ${DDH}
397 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
398 DEPENDS ${DCINTHDRS} ${DDH}
399 )
400 add_custom_target(G${PACKAGE})
401 add_dependencies(G${PACKAGE} ${PDS})
402
403endmacro(ALICE_GenerateDictionary)
404
405macro(ALICE_BuildLibrary)
406
407 ALICE_DevFlagsOutput()
408 set(CMAKE_CXX_FLAGS "${PEDEFINE} ${PCXXFLAGS}")
409 set(CMAKE_C_FLAGS "${PEDEFINE} ${PCFLAGS}")
410 set(CMAKE_Fortran_FLAGS ${PEDEFINE} ${PFFLAGS})
411 set(CMAKE_SHARED_LINKER_FLAGS ${PSOFLAGS})
412 set(CMAKE_MODULE_LINKER_FLAGS ${PLDFLAGS})
413
414
415 separate_arguments(PINC)
416 separate_arguments(EINCLUDE)
417 separate_arguments(PELIBSDIR)
418 separate_arguments(PBLIBS)
419 separate_arguments(PELIBS)
420 separate_arguments(SHLIB)
421
422 ALICE_Format(PELIBSDIR "-L" "" "${PELIBSDIR}")
423 ALICE_CheckLibraries(PBLIBS "${PBLIBS}")
f2d583fa 424 ALICE_CheckLibraries(PELIBS "${PELIBS}")
6db31708 425
426 ALICE_CorrectPaths(EINCLUDE "${EINCLUDE}")
427 ALICE_CorrectPaths(PINC "${PINC}")
428
429 include_directories(SYSTEM ${ROOTINCDIR})
430 include_directories(${PINC})
431 include_directories(${EINCLUDE})
432 include_directories(${CMAKE_INCLUDE_EXPORT_DIRECTORY})
433
434 add_library(${PACKAGE} SHARED ${PCS} ${PFS} ${PS} ${PDS})
13f96c00 435 set_target_properties(${PACKAGE} PROPERTIES SUFFIX .so)
6db31708 436
437
438 if(PELIBS OR SHLIB)
439 target_link_libraries(${PACKAGE} ${PELIBSDIR} ${PELIBS} ${SHLIB})
440 endif(PELIBS OR SHLIB)
441
442 add_dependencies(${MODULE}-all ${PACKAGE})
443
529f129e 444 add_library(${PACKAGE}-static STATIC EXCLUDE_FROM_ALL ${PCS} ${PFS} ${PS} ${PDS})
445 set_target_properties(${PACKAGE}-static PROPERTIES OUTPUT_NAME ${PACKAGE})
6db31708 446 if(PELIBS OR ALLIB)
529f129e 447 target_link_libraries(${PACKAGE}-static ${PELIBSDIR} ${PELIBS} ${ALLIB})
6db31708 448 endif(PELIBS OR ALLIB)
449
529f129e 450 add_dependencies(${MODULE}-all-static ${PACKAGE}-static)
6db31708 451 if(ALIPROFILE STREQUAL "YES")
452 add_dependencies(${MODULE}-all ${MODULE}-static)
453 endif(ALIPROFILE STREQUAL "YES")
454
455 list(FIND EXCLUDEMODULES ${MODULE} RESULT)
456 if(NOT RESULT STREQUAL "-1")
457 message(STATUS "${MODULE} will not be built by default. Type make ${MODULE}-all to build.")
458 set_property(TARGET ${PACKAGE} PROPERTY EXCLUDE_FROM_ALL TRUE)
459 endif(NOT RESULT STREQUAL "-1")
460
e93f6949 461 set_target_properties(${PACKAGE} PROPERTIES INSTALL_NAME_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
462
6db31708 463endmacro(ALICE_BuildLibrary)
464
465macro(ALICE_BuildExecutable)
466
467 ALICE_DevFlagsOutput()
468 set(CMAKE_CXX_FLAGS "${PEDEFINE} ${PCXXFLAGS} ${EXEFLAGS}")
469 set(CMAKE_C_FLAGS "${PEDEFINE} ${PCFLAGS} ${EXEFLAGS}")
470 set(CMAKE_Fortran_FLAGS "${PEDEFINE} ${PFFLAGS} ${EXEFLAGS}")
471 set(CMAKE_SHARED_LINKER_FLAGS ${PSOFLAGS})
472 set(CMAKE_MODULE_LINKER_FLAGS ${PLDFLAGS})
473
474 separate_arguments(PINC)
475 separate_arguments(EINCLUDE)
476 separate_arguments(PELIBSDIR)
477 separate_arguments(PBLIBS)
478 separate_arguments(PELIBS)
479 separate_arguments(SHLIB)
e93f6949 480
6db31708 481 ALICE_Format(PELIBSDIR "-L" "" "${PELIBSDIR}")
482 ALICE_CheckLibraries(PBLIBS "${PBLIBS}")
6db31708 483
484 ALICE_CorrectPaths(EINCLUDE "${EINCLUDE}")
485 ALICE_CorrectPaths(PINC "${PINC}")
486
487 include_directories(SYSTEM ${ROOTINCDIR})
488 include_directories(${PINC})
489 include_directories(${EINCLUDE})
490 include_directories(${CMAKE_INCLUDE_EXPORT_DIRECTORY})
491
492 if(ALIPROFILE STREQUAL "YES")
493 add_executable(${PACKAGE} ${PFS} ${PCS} ${PS} ${PDS})
494 if(ARLIBS OR SHLIBS OR PBLIBS OR EXEFLAGS)
495 target_link_libraries(${PACKAGE} ${ARLIBS} ${SHLIBS} ${PBLIBS} ${EXEFLAGS})
496 endif(ARLIBS OR SHLIBS OR PBLIBS OR EXEFLAGS)
497 add_dependencies(${MODULE}-all ${PACKAGE})
498 else()
499 add_executable(${PACKAGE} ${PFS} ${PCS} ${PS} ${PDS})
500 if(PELIBS OR PBLIBS OR EXEFLAGS)
501 target_link_libraries(${PACKAGE} ${BINLIBDIRS} ${PELIBSDIR} ${PELIBS} ${PBLIBS} ${EXEFLAGS})
502 endif(PELIBS OR PBLIBS OR EXEFLAGS)
503 add_dependencies(${MODULE}-all ${PACKAGE})
504 endif(ALIPROFILE STREQUAL "YES")
505
7531a2ac 506# AliMDC
507# ------------------------------
0742852a 508 if(PACKAGE STREQUAL "alimdc" AND GENERATEPACKAGES)
7531a2ac 509
0742852a 510 add_executable(${PACKAGE}-static ${PFS} ${PCS} ${PS} ${PDS})
7531a2ac 511 set_target_properties(${PACKAGE}-static PROPERTIES OUTPUT_NAME alimdca)
512 add_custom_target( libAliMDC
513 COMMAND rm -rf ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libAliMDC.a
514 COMMAND rm -rf junkmdc
515 COMMAND mkdir junkmdc && cd junkmdc && ar x ../libRAWDatabase.a && ar x ../libMDC.a && ar x ../libESD.a && ar x ../libSTEERBase.a && ar r ../libAliMDC.a *.o && cd .. && rm -rf junkmdc
7531a2ac 516 WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
dad683d0 517 add_custom_target( root-static-libs
518 COMMAND make static
519 WORKING_DIRECTORY ${ROOTSYS} )
520
7531a2ac 521 add_dependencies(libAliMDC RAWDatabase-static STEERBase-static MDC-static ESD-static)
dad683d0 522 add_dependencies(${PACKAGE}-static libAliMDC root-static-libs)
7531a2ac 523 target_link_libraries(${PACKAGE}-static ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libAliMDC.a ${ROOTLIBDIR}/libRoot.a ${ROOTLIBDIR}/libfreetype.a ${ROOTLIBDIR}/libpcre.a -pthread -ldl -lcurses)
7531a2ac 524
24b052aa 525 install(TARGETS ${PACKAGE}-static RUNTIME DESTINATION bin/tgt_${ALICE_TARGET} COMPONENT MDC)
526 install(FILES ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libAliMDC.a ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libAliMDC.a ${ROOTLIBDIR}/libRoot.a ${ROOTLIBDIR}/libfreetype.a ${ROOTLIBDIR}/libpcre.a DESTINATION lib/tgt_${ALICE_TARGET} COMPONENT MDC)
0742852a 527 install(FILES ${PROJECT_SOURCE_DIR}/RAW/mdc.h DESTINATION include COMPONENT MDC)
528 set(CPACK_RPM_PACKAGE_SUMMARY "AliMDC static libraries")
529 set(CPACK_RPM_PACKAGE_NAME "alimdc")
530 set(CPACK_RPM_PACKAGE_VERSION "${ALIMDCVERSION}")
531 set(CPACK_RPM_PACKAGE_RELEASE "${ALIMDCRELEASE}")
e66e598e 532 set(CPACK_RPM_PACKAGE_LICENSE "License: CERN ALICE Off-line Group")
0742852a 533 set(CPACK_RPM_PACKAGE_VENDOR "ALICE Core Off-line Group")
534 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "AliMDC static libraries")
535 set(CPACK_RPM_PACKAGE_GROUP "Applications/Alice")
536 set(CPACK_RPM_PACKAGE_REQUIRES "glibc")
537 set(CPACK_PACKAGE_VERSION "1.0.0")
538 set(CPACK_PACKAGE_VERSION_MAJOR "1")
539 set(CPACK_PACKAGE_VERSION_MINOR "0")
540 set(CPACK_PACKAGE_VERSION_PATCH "0")
541 set(CPACK_PACKAGE_INSTALL_DIRECTORY "/opt/")
542 add_component_package(MDC alimdc-rpm)
543
544 endif(PACKAGE STREQUAL "alimdc" AND GENERATEPACKAGES)
7531a2ac 545
6db31708 546 list(FIND EXCLUDEMODULES ${MODULE} RESULT)
547 if(NOT RESULT STREQUAL "-1")
548 set_property(TARGET ${PACKAGE} PROPERTY EXCLUDE_FROM_ALL TRUE)
549 endif(NOT RESULT STREQUAL "-1")
550
551endmacro(ALICE_BuildExecutable)
552
553macro(ALICE_CopyHeaders)
554
e93f6949 555 if(EXPORT )
6db31708 556 set(HEADERS ${EXPORT})
e93f6949 557 set(_headersdep)
558 foreach(header ${HEADERS})
559 add_custom_command(OUTPUT ${PEXPORTDEST}/${header}
ae388d3b 560 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/${MODULE}/${header} ${PEXPORTDEST}/${header}
561 DEPENDS ${CMAKE_SOURCE_DIR}/${MODULE}/${header})
e93f6949 562 list(APPEND _headersdep ${PEXPORTDEST}/${header})
6db31708 563 install(FILES ${header} DESTINATION include)
e93f6949 564 endforeach(header)
565 add_custom_target(${PACKAGE}-headers DEPENDS ${_headersdep})
566 add_dependencies(${PACKAGE} ${PACKAGE}-headers)
567 endif(EXPORT)
6db31708 568
569endmacro(ALICE_CopyHeaders)
570
571macro(ALICE_GenerateLinkDef)
572
573 file (WRITE ${PDAL} "//--------------------------------------------------------------------------------\n")
574 file (APPEND ${PDAL} "// This is an automatically generated Root Dictionary Linkdef file for ${PACKAGE}\n")
575 file (APPEND ${PDAL} "// !!! DO NOT EDIT THIS FILE !!!\n")
576 file (APPEND ${PDAL} "#ifdef __CINT__\n")
577 file (APPEND ${PDAL} "#pragma link off all globals;\n")
578 file (APPEND ${PDAL} "#pragma link off all classes;\n")
579 file (APPEND ${PDAL} "#pragma link off all functions;\n")
580 foreach (class ${PCINTCLASSES})
581 get_filename_component(classname ${class} NAME)
582 file(APPEND ${PDAL} "#pragma link C++ class ${classname}+;\n")
583 endforeach(class)
584 file (APPEND ${PDAL} "#endif\n")
585endmacro(ALICE_GenerateLinkDef)
0742852a 586
6a9e2760 587macro(ALICE_BuildPAR)
741bbd87 588
741bbd87 589 if(EXISTS ${CMAKE_SOURCE_DIR}/${MODULE}/PROOF-INF.${PACKAGE})
8948a174 590 set(PARSRCS)
3a8dbb31 591 foreach(file ${SRCS} ${HDRS} ${FSRCS} ${DHDR})
592 get_filename_component(srcdir ${file} PATH)
8948a174 593 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}/${file}-par
594 COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}/${srcdir}
595 COMMAND cp -pR ${file} ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}/${file}
3a8dbb31 596 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
8948a174 597 list(APPEND PARSRCS ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}/${file}-par)
3a8dbb31 598 endforeach(file ${SRCS} ${HDRS} ${FSRCS} ${DHDR})
8948a174 599
600 add_custom_target(${PACKAGE}.par
958d9d26 601 COMMAND sed -e 's/include .\(ROOTSYS\)\\/test\\/Makefile.arch/include Makefile.arch/\; s/PACKAGE = .*/PACKAGE = ${PACKAGE}/\; s,SRCS *=.*,SRCS = ${SRCS},\;' < Makefile | sed -e 's,HDRS *=.*,HDRS = ${HDRS},\; s,FSRCS *=.*,FSRCS = ${FSRCS},\; s,DHDR *=.*,DHDR = ${DHDR},' > ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}/Makefile
8948a174 602 COMMAND cp -pR ${ROOTSYS}/test/Makefile.arch ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}/Makefile.arch
603 COMMAND cp -pR PROOF-INF.${PACKAGE} ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}/PROOF-INF
84d4333f 604# COMMAND cp -pR lib${PACKAGE}.pkg ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}
8948a174 605 COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_CURRENT_BINARY_DIR} tar --exclude=.svn -czhf ${CMAKE_BINARY_DIR}/${PACKAGE}.par ${PACKAGE}
606 COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}
607 COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --red --bold "${PACKAGE}.par has been created in ${CMAKE_BINARY_DIR}"
608 DEPENDS ${PARSRCS}
609 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
610
3a8dbb31 611
958d9d26 612 add_dependencies(${PACKAGE}.par ${SRCS} ${FSRCS} ${HDRS} ${DHDR})
6a9e2760 613 add_dependencies(par-all ${PACKAGE}.par)
3a8dbb31 614 add_dependencies(${MODULE}-par-all ${PACKAGE}.par)
615
616 add_custom_target(test-${PACKAGE}.par
617 COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --red --bold "The file ${PACKAGE}.par is now being tested, in case of an error check in par-tmp/${PACKAGE}."
618 COMMAND ${CMAKE_COMMAND} -E make_directory par-tmp
619 COMMAND ${CMAKE_COMMAND} -E chdir par-tmp tar xfz ../${PACKAGE}.par && ${CMAKE_COMMAND} -E chdir par-tmp/${PACKAGE} PROOF-INF/BUILD.sh
620 COMMAND ${CMAKE_COMMAND} -E remove_directory par-tmp
621 COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --green --bold "${PACKAGE}.par testing succeeded"
622 WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
623
958d9d26 624 add_dependencies(test-${PACKAGE}.par ${PACKAGE}.par)
3a8dbb31 625 add_dependencies(test-par-all test-${PACKAGE}.par)
626 add_dependencies(test-${MODULE}-par-all test-${PACKAGE}.par)
627
741bbd87 628 endif(EXISTS ${CMAKE_SOURCE_DIR}/${MODULE}/PROOF-INF.${PACKAGE})
629 # endif(EXISTS ${ALICE_ROOT}/${MODULE}/PROOF-INF.${PACKAGE})
630
6a9e2760 631endmacro(ALICE_BuildPAR)
0742852a 632