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