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