Fixes for object target dependencies
[u/mrichter/AliRoot.git] / ITS / ITSsim / CMakeLists.txt
CommitLineData
56966a5e 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 ITSsim)
18
19# Module include folder
427d561c 20include_directories(${AliRoot_SOURCE_DIR}/ITS/${MODULE})
56966a5e 21
22# Additional include folders in alphabetical order except ROOT
e2aa5f1b 23include_directories(${ROOT_INCLUDE_DIRS}
427d561c 24 ${AliRoot_SOURCE_DIR}/ITS/ITSbase
427d561c 25 ${AliRoot_SOURCE_DIR}/RAW/RAWDatabase
26 ${AliRoot_SOURCE_DIR}/RAW/RAWDatarec
27 ${AliRoot_SOURCE_DIR}/STEER/CDB
28 ${AliRoot_SOURCE_DIR}/STEER/ESD
29 ${AliRoot_SOURCE_DIR}/STEER/STEERBase
30 ${AliRoot_SOURCE_DIR}/STEER/STEER
56966a5e 31 )
32
33# Sources in alphabetical order
34set(SRCS
35 AliITS.cxx
36 AliITSDetTypeSim.cxx
37 AliITSDigitizer.cxx
38 AliITSetfSDD.cxx
39 AliITSFOEfficiencySPDColumn.cxx
40 AliITSFOEfficiencySPD.cxx
41 AliITSFOGeneratorSPD.cxx
42 AliITSFONoiseSPD.cxx
56966a5e 43 AliITShit.cxx
44 AliITSmodule.cxx
45 AliITSQADataMakerSim.cxx
46 AliITSQASDDDataMakerSim.cxx
47 AliITSQASPDDataMakerSim.cxx
48 AliITSQASSDDataMakerSim.cxx
49 AliITSsDigitize.cxx
50 AliITSsimulation.cxx
51 AliITSsimulationFastPoints.cxx
52 AliITSsimulationSDD.cxx
53 AliITSsimulationSPD.cxx
54 AliITSsimulationSSD.cxx
55 AliITSSimuParam.cxx
56 AliITSTableSSD.cxx
57 AliITSTrigger.cxx
58 AliITSTriggerFOProcessor.cxx
59 AliITSv11.cxx
60 AliITSv11GeomCable.cxx
61 AliITSv11GeomCableFlat.cxx
62 AliITSv11GeomCableRound.cxx
63 AliITSv11Geometry.cxx
64 AliITSv11GeometrySDD.cxx
65 AliITSv11GeometrySPD.cxx
66 AliITSv11GeometrySSD.cxx
67 AliITSv11GeometrySupport.cxx
68 )
69
70# Headers from sources
71string(REPLACE ".cxx" ".h" HDRS "${SRCS}")
72
73# Generate the dictionary
74# It will create G_ARG1.cxx and G_ARG1.h / ARG1 = function first argument
75get_directory_property(incdirs INCLUDE_DIRECTORIES)
76generate_dictionary("${MODULE}" "${MODULE}LinkDef.h" "${HDRS}" "${incdirs}")
77
efc69e78 78set(ROOT_DEPENDENCIES Core EG Geom Gpad Graf Hist MathCore Matrix Physics RIO Tree VMC)
90dcc14b 79set(ALIROOT_DEPENDENCIES CDB ESD STEERBase STEER ITSbase RAWDatabase RAWDatarec)
efc69e78 80
56966a5e 81# Generate the ROOT map
82# Dependecies
efc69e78 83set(LIBDEPS ${ALIROOT_DEPENDENCIES} ${ROOT_DEPENDENCIES})
56966a5e 84generate_rootmap("${MODULE}" "${LIBDEPS}" "${CMAKE_CURRENT_SOURCE_DIR}/${MODULE}LinkDef.h")
85
90dcc14b 86# Create an object to be reused in case of static libraries
87# Otherwise the sources will be compiled twice
88add_library(${MODULE}-object OBJECT ${SRCS} G__${MODULE}.cxx)
89# Add a library to the project using the object
68aeb13b 90add_library(${MODULE} SHARED $<TARGET_OBJECTS:${MODULE}-object>)
90dcc14b 91
92# linking
efc69e78 93target_link_libraries(${MODULE} ${ALIROOT_DEPENDENCIES} ${ROOT_DEPENDENCIES})
56966a5e 94
68aeb13b 95# Setting the correct headers for the object as gathered from the dependencies
96target_include_directories(${MODULE}-object PUBLIC $<TARGET_PROPERTY:${MODULE},INCLUDE_DIRECTORIES>)
97set_target_properties(${MODULE}-object PROPERTIES COMPILE_DEFINITIONS $<TARGET_PROPERTY:${MODULE},COMPILE_DEFINITIONS>)
98
56966a5e 99# Additional compilation flags
68aeb13b 100set_target_properties(${MODULE}-object PROPERTIES COMPILE_FLAGS " ")
56966a5e 101
102# System dependent: Modify the way the library is build
103if(${CMAKE_SYSTEM} MATCHES Darwin)
104 set_target_properties(${MODULE} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
105endif(${CMAKE_SYSTEM} MATCHES Darwin)
106
107# Installation
108install(TARGETS ${MODULE}
109 ARCHIVE DESTINATION lib
110 LIBRARY DESTINATION lib)
111
90dcc14b 112install(FILES ${HDRS} DESTINATION include)
113
114# Static version if DA enabled
115if(ALIROOT_STATIC)
68aeb13b 116 add_library(${MODULE}-static STATIC $<TARGET_OBJECTS:${MODULE}-object>)
90dcc14b 117 set_target_properties(${MODULE}-static PROPERTIES OUTPUT_NAME ${MODULE})
118
119 # list of shared dependencies / the name of the variable containing the list of static ones
120 generate_static_dependencies("${ALIROOT_DEPENDENCIES}" "STATIC_ALIROOT_DEPENDENCIES")
121 target_link_libraries(${MODULE}-static ${STATIC_ALIROOT_DEPENDENCIES} Root)
68aeb13b 122
123 # Public include folders that will be propagated to the dependecies
124 target_include_directories(${MODULE}-static PUBLIC ${incdirs})
125
90dcc14b 126 set_target_properties(${MODULE}-static PROPERTIES LINK_FLAGS "-Wl,--whole-archive")
127
128 # Installation
129 install(TARGETS ${MODULE}-static
130 ARCHIVE DESTINATION lib
131 LIBRARY DESTINATION lib)
132endif(ALIROOT_STATIC)