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