]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RAW/alimdc/CMakeLists.txt
alimdc rpm
[u/mrichter/AliRoot.git] / RAW / alimdc / CMakeLists.txt
CommitLineData
a0f34e87 1# **************************************************************************
2# * Copyright(c) 1998-2014, ALICE Experiment at CERN, All rights reserved. *
3# * *
4# * Author: The ALICE Off-line Project. *
5# * Contributors are mentioned in the code where appropriate. *
6# * *
7# * Permission to use, copy, modify and distribute this software and its *
8# * documentation strictly for non-commercial purposes is hereby granted *
9# * without fee, provided that the above copyright notice appears in all *
10# * copies and that both the copyright notice and this permission notice *
11# * appear in the supporting documentation. The authors make no claims *
12# * about the suitability of this software for any purpose. It is *
13# * provided "as is" without express or implied warranty. *
14# **************************************************************************
0224bae4 15
16# Module
17set (MODULE alimdc)
427d561c 18include_directories(${AliRoot_SOURCE_DIR}/${MODULE})
0224bae4 19
a0f34e87 20# Aditional include folders in alphabetical order except ROOT
21include_directories(${ROOT_INCLUDE_DIRS}
427d561c 22 ${AliRoot_SOURCE_DIR}/RAW/MDC
23 ${AliRoot_SOURCE_DIR}/RAW/RAWDatabase
24 ${AliRoot_SOURCE_DIR}/RAW/RAWDatarec
25 ${AliRoot_SOURCE_DIR}/STEER/ESD
26 ${AliRoot_SOURCE_DIR}/STEER/STEERBase
a0f34e87 27 )
0224bae4 28
a0f34e87 29link_directories(${ROOT_LIBDIR})
30
31# ROOT libraries that are not in root-config --libs
fae85bcc 32set(ROOT_DEPENDENCIES Geom VMC Minuit)
33set(ALIROOT_DEPENDENCIES STEERBase ESD MDC RAWDatabase RAWDatarec)
0224bae4 34
fae85bcc 35# Create an object to be reused in case of static libraries
36# Otherwise the sources will be compiled twice
37add_library(${MODULE}-object OBJECT alimdc_main.cxx)
38# Add a library to the project using the object
39add_executable(${MODULE} $<TARGET_OBJECTS:${MODULE}-object>)
40target_link_libraries(${MODULE} STEERBase ESD MDC RAWDatabase RAWDatarec ${ROOT_DEPENDENCIES} ${ROOT_LIBRARIES})
0224bae4 41
ca331a9c 42# Compile and link flags
43set(MODULE_COMPILE_FLAGS)
44set(MODULE_LINK_FLAGS)
45
46if(DATE_FOUND)
47 set(MODULE_COMPILE_FLAGS "${DATE_CFLAGS}")
48 set(MODULE_LINK_FLAGS "${DATE_LDFLAGS} ${DATE_LIBS}")
49endif(DATE_FOUND)
50
51# Additional compilation and linking flags
68aeb13b 52set(MODULE_COMPILE_FLAGS " ${MODULE_COMPILE_FLAGS}")
ca331a9c 53
54# System dependent: Modify the way the library is build
55if(${CMAKE_SYSTEM} MATCHES Darwin)
56 set(MODULE_LINK_FLAGS "-undefined dynamic_lookup ${MODULE_LINK_FLAGS}")
57endif(${CMAKE_SYSTEM} MATCHES Darwin)
58
59# Setting target compile and linking flags
60set_target_properties(${MODULE} PROPERTIES COMPILE_FLAGS "${MODULE_COMPILE_FLAGS}")
61set_target_properties(${MODULE} PROPERTIES LINK_FLAGS "${MODULE_LINK_FLAGS}")
62
0224bae4 63# Installation
64install(TARGETS ${MODULE} RUNTIME DESTINATION bin)
fae85bcc 65
66# Creating the AliMDC static library and the rpm
67if(MDCRPM)
68 add_library(AliMDC STATIC $<TARGET_OBJECTS:${MODULE}-object>)
69
70 # list of shared dependencies / the name of the variable containing the list of static ones
71 generate_static_dependencies("${ALIROOT_DEPENDENCIES}" "STATIC_ALIROOT_DEPENDENCIES")
72 target_link_libraries(AliMDC ${STATIC_ALIROOT_DEPENDENCIES} Root RootExtra)
73
74 set_target_properties(AliMDC PROPERTIES LINK_FLAGS "-Wl,--whole-archive")
75
76 # Installation
77 install(TARGETS AliMDC
78 ARCHIVE DESTINATION lib
79 LIBRARY DESTINATION lib)
80
81 configure_file("alimdc.spec.in" "alimdc.spec" @ONLY)
82
83 add_custom_command(TARGET alimdc POST_BUILD
84 COMMAND mkdir ARGS -p alimdc-rpm/root/opt/alimdc/lib
85 COMMAND mkdir ARGS -p alimdc-rpm/root/opt/alimdc/include
86 COMMAND cp ARGS libAliMDC.a alimdc-rpm/root/opt/alimdc/lib
87 COMMAND cp ARGS ${ROOT_LIBDIR}/libRoot.a alimdc-rpm/root/opt/alimdc/lib/
88 COMMAND cp ARGS ${CMAKE_BINARY_DIR}/libRootExtra.a alimdc-rpm/root/opt/alimdc/lib/
89 COMMAND cp ARGS ${ROOT_LIBDIR}/libpcre.a alimdc-rpm/root/opt/alimdc/lib/
90 COMMAND cp ARGS ${ROOT_LIBDIR}/liblzma.a alimdc-rpm/root/opt/alimdc/lib/
91 COMMAND cp ARGS ${ROOT_LIBDIR}/libfreetype.a alimdc-rpm/root/opt/alimdc/lib/
92 COMMAND cp ARGS ${CMAKE_BINARY_DIR}/libRootExtra.a alimdc-rpm/root/opt/alimdc/lib/
93 COMMAND cp ARGS ${AliRoot_SOURCE_DIR}/RAW/MDC/mdc.h alimdc-rpm/root/opt/alimdc/include
94 COMMAND rpmbuild ARGS --verbose --define "_topdir ${CMAKE_CURRENT_BINARY_DIR}/alimdc-rpm" --define "%buildroot ${CMAKE_CURRENT_BINARY_DIR}/alimdc-rpm/root" -bb alimdc.spec
95 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} VERBATIM
96 COMMENT "RPM creation for AliMDC"
97 )
98
99 # make clean will remove also the rpm folder
100 # Retrive the current list of file to be deleted - set_directory_property is overwriting, not adding to the list
101 get_directory_property(_clean_files ADDITIONAL_MAKE_CLEAN_FILES)
102 set(_clean_files alimdc-rpm ${_clean_files})
103 set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${_clean_files}")
104
105 # install RPM into $CMAKE_INSTALL_PREFIX/darpms
106 install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/alimdc-rpm/RPMS/ DESTINATION mdcrpm PATTERN "\\.rpm")
107
108endif(MDCRPM)