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