VZERO DAs + 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
d1d7d34a 61# Public include folders that will be propagated to the dependecies
62target_include_directories(${MODULE} PUBLIC ${incdirs})
63
ca331a9c 64# Compile and link flags
65set(MODULE_COMPILE_FLAGS)
66set(MODULE_LINK_FLAGS)
67
68if(DATE_FOUND)
69 set(MODULE_COMPILE_FLAGS "${DATE_CFLAGS}")
70 set(MODULE_LINK_FLAGS "${DATE_LDFLAGS} ${DATE_LIBS}")
71endif(DATE_FOUND)
72
73# Additional compilation and linking flags
d1d7d34a 74set(MODULE_COMPILE_FLAGS "-O -g ${MODULE_COMPILE_FLAGS}")
0224bae4 75
76# System dependent: Modify the way the library is build
77if(${CMAKE_SYSTEM} MATCHES Darwin)
ca331a9c 78 set(MODULE_LINK_FLAGS "-undefined dynamic_lookup ${MODULE_LINK_FLAGS}")
0224bae4 79endif(${CMAKE_SYSTEM} MATCHES Darwin)
80
ca331a9c 81# Setting target compile and linking flags
46e377fb 82set_target_properties(${MODULE}-object PROPERTIES COMPILE_FLAGS "${MODULE_COMPILE_FLAGS}")
ca331a9c 83set_target_properties(${MODULE} PROPERTIES LINK_FLAGS "${MODULE_LINK_FLAGS}")
84
0224bae4 85# Installation
86install(TARGETS ${MODULE}
87 ARCHIVE DESTINATION lib
88 LIBRARY DESTINATION lib)
89
46e377fb 90install(FILES ${HDRS} DESTINATION include)
91
92# Static version if DA enabled
93if(ALIROOT_STATIC)
94 add_library(${MODULE}-static STATIC $<TARGET_OBJECTS:RAWDatarecOnline-object>)
95 set_target_properties(${MODULE}-static PROPERTIES OUTPUT_NAME ${MODULE})
96
97 # list of shared dependencies / the name of the variable containing the list of static ones
98 generate_static_dependencies("${ALIROOT_DEPENDENCIES}" "STATIC_ALIROOT_DEPENDENCIES")
99 target_link_libraries(${MODULE}-static ${STATIC_ALIROOT_DEPENDENCIES} Root)
d1d7d34a 100
101 # Public include folders that will be propagated to the dependecies
102 target_include_directories(${MODULE}-static PUBLIC ${incdirs})
103
46e377fb 104 set_target_properties(${MODULE}-static PROPERTIES LINK_FLAGS "-Wl,--whole-archive")
105
106 # Installation
107 install(TARGETS ${MODULE}-static
108 ARCHIVE DESTINATION lib
109 LIBRARY DESTINATION lib)
110endif(ALIROOT_STATIC)