VZERO DAs + Object target dependencies
[u/mrichter/AliRoot.git] / MUON / MUONsim / CMakeLists.txt
CommitLineData
b22a7396 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 MUONsim)
18
19# Module include folder
427d561c 20include_directories(${AliRoot_SOURCE_DIR}/MUON/${MODULE})
b22a7396 21
22# Additional include folders in alphabetical order except ROOT
23include_directories(${ROOT_INCLUDE_DIRS}
427d561c 24 ${AliRoot_SOURCE_DIR}/MUON/MUONbase
25 ${AliRoot_SOURCE_DIR}/MUON/MUONcalib
26 ${AliRoot_SOURCE_DIR}/MUON/MUONcore
27 ${AliRoot_SOURCE_DIR}/MUON/MUONgeometry
28 ${AliRoot_SOURCE_DIR}/MUON/MUONmapping
29 ${AliRoot_SOURCE_DIR}/MUON/MUONraw
30 ${AliRoot_SOURCE_DIR}/MUON/MUONtrigger
31 ${AliRoot_SOURCE_DIR}/RAW/RAWDatabase
32 ${AliRoot_SOURCE_DIR}/STEER/CDB
33 ${AliRoot_SOURCE_DIR}/STEER/ESD
34 ${AliRoot_SOURCE_DIR}/STEER/STEER
35 ${AliRoot_SOURCE_DIR}/STEER/STEERBase
b22a7396 36 )
37
38# Sources in alphabetical order
39set(SRCS
40 AliMUONChamber.cxx
41 AliMUONChamberTrigger.cxx
42 AliMUONCommonGeometryBuilder.cxx
43 AliMUON.cxx
44 AliMUONDigitizerV3.cxx
45 AliMUONGainEventGenerator.cxx
46 AliMUONHit.cxx
47 AliMUONHitStoreV1.cxx
48 AliMUONMCDataInterface.cxx
49 AliMUONPedestalEventGenerator.cxx
50 AliMUONQADataMakerSim.cxx
51 AliMUONResponse.cxx
52 AliMUONResponseFactory.cxx
53 AliMUONResponseTrigger.cxx
54 AliMUONResponseTriggerV1.cxx
55 AliMUONResponseV0.cxx
56 AliMUONSDigitizerV2.cxx
57 AliMUONSlatGeometryBuilder.cxx
58 AliMUONSt1GeometryBuilder.cxx
59 AliMUONSt1GeometryBuilderV2.cxx
60 AliMUONSt1SpecialMotif.cxx
61 AliMUONSt2GeometryBuilder.cxx
62 AliMUONSt2GeometryBuilderV2.cxx
63 AliMUONTrigger.cxx
64 AliMUONTriggerGeometryBuilder.cxx
65 AliMUONv1.cxx
66 AliMUONVHitStore.cxx
67 )
68
69# Headers from sources
70string(REPLACE ".cxx" ".h" HDRS "${SRCS}")
71
72# Generate the dictionary
73# It will create G_ARG1.cxx and G_ARG1.h / ARG1 = function first argument
74get_directory_property(incdirs INCLUDE_DIRECTORIES)
75generate_dictionary("${MODULE}" "${MODULE}LinkDef.h" "${HDRS}" "${incdirs}")
76
c55bd1a6 77# Dependencies
78set(ROOT_DEPENDENCIES Core EG Geom Hist MathCore Physics RIO Tree VMC)
79set(ALIROOT_DEPENDENCIES STEERBase STEER CDB ESD RAWDatabase MUONcore MUONbase MUONcalib MUONraw MUONgeometry MUONmapping MUONtrigger)
80
b22a7396 81# Generate the ROOT map
82# Dependecies
c55bd1a6 83set(LIBDEPS ${ALIROOT_DEPENDENCIES} ${ROOT_DEPENDENCIES})
b22a7396 84generate_rootmap("${MODULE}" "${LIBDEPS}" "${CMAKE_CURRENT_SOURCE_DIR}/${MODULE}LinkDef.h")
85
c55bd1a6 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)
139cbc46 89# Follow headers dependencies
90add_dependencies(${MODULE}-object ${ALIROOT_DEPENDENCIES})
c55bd1a6 91# Add a library to the project using the object
92add_library(${MODULE} SHARED $<TARGET_OBJECTS:MUONsim-object>)
b22a7396 93
c55bd1a6 94# linking
95target_link_libraries(${MODULE} ${ALIROOT_DEPENDENCIES} ${ROOT_DEPENDENCIES})
b22a7396 96
97# Additional compilation flags
98set(TARGETFLAGS "-g")
99
100# Optimize
101if(CMAKE_COMPILER_IS_GNUCXX)
102 if(GCC_MAJOR STREQUAL "4")
103 if(GCC_MINOR STREQUAL "3")
104 set(TARGETFLAGS "${TARGETFLAGS} -O0")
105 else()
106 set(TARGETFLAGS "${TARGETFLAGS} -O")
107 endif()
108 endif()
109endif()
110
c55bd1a6 111set_target_properties(${MODULE}-object PROPERTIES COMPILE_FLAGS "-fPIC ${TARGETFLAGS}")
b22a7396 112
113# System dependent: Modify the way the library is build
114if(${CMAKE_SYSTEM} MATCHES Darwin)
115 set_target_properties(${MODULE} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
116endif(${CMAKE_SYSTEM} MATCHES Darwin)
117
118# Installation
119install(TARGETS ${MODULE}
120 ARCHIVE DESTINATION lib
121 LIBRARY DESTINATION lib)
122
c55bd1a6 123install(FILES ${HDRS} DESTINATION include)
124
125# Static version if DA enabled
126if(ALIROOT_STATIC)
127 add_library(${MODULE}-static STATIC $<TARGET_OBJECTS:MUONsim-object>)
128 set_target_properties(${MODULE}-static PROPERTIES OUTPUT_NAME ${MODULE})
129
130 # list of shared dependencies / the name of the variable containing the list of static ones
131 generate_static_dependencies("${ALIROOT_DEPENDENCIES}" "STATIC_ALIROOT_DEPENDENCIES")
132 target_link_libraries(${MODULE}-static ${STATIC_ALIROOT_DEPENDENCIES} Root)
133 set_target_properties(${MODULE}-static PROPERTIES LINK_FLAGS "-Wl,--whole-archive")
134
135 # Installation
136 install(TARGETS ${MODULE}-static
137 ARCHIVE DESTINATION lib
138 LIBRARY DESTINATION lib)
139endif(ALIROOT_STATIC)