Fixes for object target dependencies
[u/mrichter/AliRoot.git] / MUON / MUONgeometry / 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 MUONgeometry)
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/MUONcore
25 ${AliRoot_SOURCE_DIR}/MUON/MUONmapping
26 ${AliRoot_SOURCE_DIR}/STEER/CDB
27 ${AliRoot_SOURCE_DIR}/STEER/STEER
28 ${AliRoot_SOURCE_DIR}/STEER/STEERBase
b22a7396 29 )
30
31# Sources in alphabetical order
32set(SRCS
33 AliMUONGeometryBuilder.cxx
34 AliMUONGeometryConstituent.cxx
35 AliMUONGeometry.cxx
36 AliMUONGeometryDetElement.cxx
37 AliMUONGeometryEnvelope.cxx
38 AliMUONGeometryEnvelopeStore.cxx
39 AliMUONGeometryMisAligner.cxx
40 AliMUONGeometryModule.cxx
41 AliMUONGeometryModuleTransformer.cxx
42 AliMUONGeometryTransformer.cxx
43 AliMUONSurveyChamber.cxx
44 AliMUONSurveyDetElem.cxx
45 AliMUONSurveyObj.cxx
46 AliMUONSurveyUtil.cxx
47 AliMUONVGeometryBuilder.cxx
48 )
49
50# Headers from sources
51string(REPLACE ".cxx" ".h" HDRS "${SRCS}")
52
53# Generate the dictionary
54# It will create G_ARG1.cxx and G_ARG1.h / ARG1 = function first argument
55get_directory_property(incdirs INCLUDE_DIRECTORIES)
56generate_dictionary("${MODULE}" "${MODULE}LinkDef.h" "${HDRS}" "${incdirs}")
57
c55bd1a6 58# Dependencies
59set(ROOT_DEPENDENCIES Core Geom Hist MathCore Matrix Minuit Physics RIO VMC)
60set(ALIROOT_DEPENDENCIES STEERBase STEER CDB MUONmapping MUONcore)
61
b22a7396 62# Generate the ROOT map
63# Dependecies
c55bd1a6 64set(LIBDEPS ${ALIROOT_DEPENDENCIES} ${ROOT_DEPENDENCIES})
b22a7396 65generate_rootmap("${MODULE}" "${LIBDEPS}" "${CMAKE_CURRENT_SOURCE_DIR}/${MODULE}LinkDef.h")
66
c55bd1a6 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)
139cbc46 70# Follow headers dependencies
71add_dependencies(${MODULE}-object ${ALIROOT_DEPENDENCIES})
c55bd1a6 72# Add a library to the project using the object
73add_library(${MODULE} SHARED $<TARGET_OBJECTS:MUONgeometry-object>)
b22a7396 74
c55bd1a6 75# linking
76target_link_libraries(${MODULE} ${ALIROOT_DEPENDENCIES} ${ROOT_DEPENDENCIES})
b22a7396 77
68aeb13b 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>)
81
b22a7396 82# Additional compilation flags
68aeb13b 83set_target_properties(${MODULE}-object PROPERTIES COMPILE_FLAGS " ")
b22a7396 84
85# System dependent: Modify the way the library is build
86if(${CMAKE_SYSTEM} MATCHES Darwin)
87 set_target_properties(${MODULE} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
88endif(${CMAKE_SYSTEM} MATCHES Darwin)
89
90# Installation
91install(TARGETS ${MODULE}
92 ARCHIVE DESTINATION lib
93 LIBRARY DESTINATION lib)
94
c55bd1a6 95install(FILES ${HDRS} DESTINATION include)
96
97# Static version if DA enabled
98if(ALIROOT_STATIC)
99 add_library(${MODULE}-static STATIC $<TARGET_OBJECTS:MUONgeometry-object>)
100 set_target_properties(${MODULE}-static PROPERTIES OUTPUT_NAME ${MODULE})
101
102 # list of shared dependencies / the name of the variable containing the list of static ones
103 generate_static_dependencies("${ALIROOT_DEPENDENCIES}" "STATIC_ALIROOT_DEPENDENCIES")
104 target_link_libraries(${MODULE}-static ${STATIC_ALIROOT_DEPENDENCIES} Root)
68aeb13b 105
106 # Public include folders that will be propagated to the dependecies
107 target_include_directories(${MODULE}-static PUBLIC ${incdirs})
108
c55bd1a6 109 set_target_properties(${MODULE}-static PROPERTIES LINK_FLAGS "-Wl,--whole-archive")
110
111 # Installation
112 install(TARGETS ${MODULE}-static
113 ARCHIVE DESTINATION lib
114 LIBRARY DESTINATION lib)
115endif(ALIROOT_STATIC)