]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ZDC/ZDCbase/CMakeLists.txt
e9759a95cfb3669245918d926fa0ea54e21192b5
[u/mrichter/AliRoot.git] / ZDC / ZDCbase / CMakeLists.txt
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
17 set(MODULE ZDCbase)
18
19 # Module include folder
20 include_directories(${AliRoot_SOURCE_DIR}/ZDC/${MODULE})
21
22 # Additional include folders in alphabetical order except ROOT
23 include_directories(${ROOT_INCLUDE_DIRS}
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
30                    )
31
32 # Sources in alphabetical order
33 set(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
52 string(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
56 get_directory_property(incdirs INCLUDE_DIRECTORIES)
57 generate_dictionary("${MODULE}" "${MODULE}LinkDef.h" "${HDRS}" "${incdirs}")
58
59 set(ROOT_DEPENDENCIES Core Gpad Graf Hist RIO)
60 set(ALIROOT_DEPENDENCIES STEERBase STEER CDB ESD RAWDatabase RAWDatarec)
61
62 # Generate the ROOT map
63 # Dependecies
64 set(LIBDEPS ${ALIROOT_DEPENDENCIES} ${ROOT_DEPENDENCIES})
65 generate_rootmap("${MODULE}" "${LIBDEPS}" "${CMAKE_CURRENT_SOURCE_DIR}/${MODULE}LinkDef.h")
66
67 # Create an object to be reused in case of static libraries 
68 # Otherwise the sources will be compiled twice
69 add_library(${MODULE}-object OBJECT ${SRCS} G__${MODULE}.cxx)
70 # Follow headers dependencies
71 add_dependencies(${MODULE}-object ${ALIROOT_DEPENDENCIES})
72 # Add a library to the project using the object
73 add_library(${MODULE} SHARED $<TARGET_OBJECTS:ZDCbase-object>)
74
75 # Linking
76 target_link_libraries(${MODULE} ${ALIROOT_DEPENDENCIES} ${ROOT_DEPENDENCIES})
77
78 # Setting the correct headers for the object as gathered from the dependencies
79 target_include_directories(${MODULE}-object PUBLIC $<TARGET_PROPERTY:${MODULE},INCLUDE_DIRECTORIES>)
80 set_target_properties(${MODULE}-object PROPERTIES COMPILE_DEFINITIONS $<TARGET_PROPERTY:${MODULE},COMPILE_DEFINITIONS>)
81
82 # Public include folders that will be propagated to the dependecies
83 target_include_directories(${MODULE} PUBLIC ${incdirs})
84
85 # Additional compilation flags
86 set_target_properties(${MODULE} PROPERTIES COMPILE_FLAGS "")
87
88 # System dependent: Modify the way the library is build
89 if(${CMAKE_SYSTEM} MATCHES Darwin)
90     set_target_properties(${MODULE} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
91 endif(${CMAKE_SYSTEM} MATCHES Darwin)
92
93 # Installation
94 install(TARGETS ${MODULE}
95         ARCHIVE DESTINATION lib
96         LIBRARY DESTINATION lib)
97
98 install(FILES ${HDRS} DESTINATION include)
99
100 # Static version if DA enabled
101 if(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)
118 endif(ALIROOT_STATIC)