Fixes for object target dependencies
[u/mrichter/AliRoot.git] / RAW / MDC / CMakeLists.txt
CommitLineData
0224bae4 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# **************************************************************************
15
16# Module
17set(MODULE MDC)
18
19# Module include folder
427d561c 20include_directories(${AliRoot_SOURCE_DIR}/RAW/${MODULE})
0224bae4 21
22# Additional include folders in alphabetical order except ROOT
27d54f3d 23include_directories(${AliRoot_SOURCE_DIR}/RAW/RAWDatabase
427d561c 24 ${AliRoot_SOURCE_DIR}/RAW/RAWDatarec
25 ${AliRoot_SOURCE_DIR}/STEER/ESD
26 ${AliRoot_SOURCE_DIR}/STEER/STEERBase
0224bae4 27 )
28
29# Sources in alphabetical order
30set(SRCS
31 AliMDC.cxx
32 AliRawCastorDB.cxx
33 AliRawDB.cxx
34 AliRawNullDB.cxx
35 AliRawRFIODB.cxx
36 AliRawRootdDB.cxx
37 AliTagDB.cxx
38 AliTagNullDB.cxx
39 mdc.cxx
40 )
41
42# Headers from sources
43string(REPLACE ".cxx" ".h" HDRS "${SRCS}")
44
45# Generate the dictionary
46# It will create G_ARG1.cxx and G_ARG1.h / ARG1 = function first argument
47get_directory_property(incdirs INCLUDE_DIRECTORIES)
48generate_dictionary("${MODULE}" "${MODULE}LinkDef.h" "${HDRS}" "${incdirs}")
49
d1d7d34a 50set(ROOT_DEPENDENCIES Core RIO Tree)
51set(ALIROOT_DEPENDENCIES ESD RAWDatabase RAWDatarec STEERBase)
52
a0f34e87 53# Generate the ROOT map
54# Dependecies
d1d7d34a 55set(LIBDEPS ${ALIROOT_DEPENDENCIES} ${ROOT_DEPENDENCIES})
a0f34e87 56generate_rootmap("${MODULE}" "${LIBDEPS}" "${CMAKE_CURRENT_SOURCE_DIR}/${MODULE}LinkDef.h")
57
d1d7d34a 58# Create an object to be reused in case of static libraries
59# Otherwise the sources will be compiled twice
60add_library(${MODULE}-object OBJECT ${SRCS} G__${MODULE}.cxx)
139cbc46 61# Follow headers dependencies
62add_dependencies(${MODULE}-object ${ALIROOT_DEPENDENCIES})
d1d7d34a 63# Add a library to the project using the object
64add_library(${MODULE} SHARED $<TARGET_OBJECTS:MDC-object>)
68aeb13b 65
d1d7d34a 66target_link_libraries(${MODULE} ${ROOT_DEPENDENCIES} ${ALIROOT_DEPENDENCIES})
67
68aeb13b 68# Setting the correct headers for the object as gathered from the dependencies
69target_include_directories(${MODULE}-object PUBLIC $<TARGET_PROPERTY:${MODULE},INCLUDE_DIRECTORIES>)
70set_target_properties(${MODULE}-object PROPERTIES COMPILE_DEFINITIONS $<TARGET_PROPERTY:${MODULE},COMPILE_DEFINITIONS>)
71
d1d7d34a 72# Public include folders that will be propagated to the dependecies
73target_include_directories(${MODULE} PUBLIC ${incdirs})
0224bae4 74
ca331a9c 75# Compile and link flags
76set(MODULE_COMPILE_FLAGS)
77set(MODULE_LINK_FLAGS)
78
79if(DATE_FOUND)
80 set(MODULE_COMPILE_FLAGS "${DATE_CFLAGS}")
81 set(MODULE_LINK_FLAGS "${DATE_LDFLAGS} ${DATE_LIBS}")
82endif(DATE_FOUND)
83
84# Additional compilation and linking flags
68aeb13b 85set(MODULE_COMPILE_FLAGS " ${MODULE_COMPILE_FLAGS}")
0224bae4 86
87# System dependent: Modify the way the library is build
88if(${CMAKE_SYSTEM} MATCHES Darwin)
ca331a9c 89 set(MODULE_LINK_FLAGS "-undefined dynamic_lookup ${MODULE_LINK_FLAGS}")
0224bae4 90endif(${CMAKE_SYSTEM} MATCHES Darwin)
91
ca331a9c 92# Setting target compile and linking flags
93set_target_properties(${MODULE} PROPERTIES COMPILE_FLAGS "${MODULE_COMPILE_FLAGS}")
94set_target_properties(${MODULE} PROPERTIES LINK_FLAGS "${MODULE_LINK_FLAGS}")
95
0224bae4 96# Installation
97install(TARGETS ${MODULE}
98 ARCHIVE DESTINATION lib
99 LIBRARY DESTINATION lib)
100
d1d7d34a 101install(FILES ${HDRS} DESTINATION include)
102
103# Static version if DA enabled
104if(ALIROOT_STATIC)
105 add_library(${MODULE}-static STATIC $<TARGET_OBJECTS:MDC-object>)
106
107 # list of shared dependencies / the name of the variable containing the list of static ones
108 generate_static_dependencies("${ALIROOT_DEPENDENCIES}" "STATIC_ALIROOT_DEPENDENCIES")
109 target_link_libraries(${MODULE}-static ${STATIC_ALIROOT_DEPENDENCIES} Root RootExtra)
110
111 # Public include folders that will be propagated to the dependecies
112 target_include_directories(${MODULE}-static PUBLIC ${incdirs})
113
114 set_target_properties(${MODULE}-static PROPERTIES OUTPUT_NAME ${MODULE})
115 set_target_properties(${MODULE}-static PROPERTIES LINK_FLAGS "-Wl,--whole-archive")
116
117 # Installation
118 install(TARGETS ${MODULE}-static
119 ARCHIVE DESTINATION lib
120 LIBRARY DESTINATION lib)
121endif(ALIROOT_STATIC)