1 # **************************************************************************
2 # * Copyright(c) 1998-2015, ALICE Experiment at CERN, All rights reserved. *
4 # * Author: The ALICE Off-line Project. *
5 # * Contributors are mentioned in the code where appropriate. *
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 # **************************************************************************
16 ############################################################################
18 ############################################################################
20 # CMake configuration is controlled through CMakeLists files.
21 # - Normally a single CMakeLists files should contain a single target/library.
22 # - The file below tries to offer a standard format for generating libraries
23 # but full access to cmake functions and utilities is possible.
24 # - For any customization please use instructions provided by the minum cmake
26 # http://www.cmake.org/cmake/help/v2.8.11/cmake.html
29 # Module name translates into library name
30 # Ex: set(MODULE ANALYSIS)
31 set(MODULE ModuleNameExample)
33 # Module include folder
34 # - Add here all include folders containing headers that belong
36 # - Do not add dependencies here
37 # - If you are not sure how to proceed please contact aliroot-git-admins@cern.ch
38 # For more information about include_directories please read
39 # documentation for minimum required version:
40 # http://www.cmake.org/cmake/help/v2.8.11/cmake.html#command:include_directories
41 # Ex: include_directories(${AliRoot_SOURCE_DIR}/ANALYS/${MODULE})
44 # Additional include folders in alphabetical order except ROOT
45 # - ROOT include folders are added by the FindROOT macro
46 # - To remove compilation warnings related to dependencies headers
47 # please add them as SYSTEM headers.
48 # - If you are not sure how to proceed please contact aliroot-git-admins@cern.ch
49 # For more information about include_directories please read
50 # documentation for minimum required version:
51 # http://www.cmake.org/cmake/help/v2.8.11/cmake.html#command:include_directories
52 # Ex: include_directories(${AliRoot_SOURCE_DIR}/STEER/STEERBase
57 # Library sources in alphabetical order
58 # - Only these sources will be added to the library
59 # - If you are not sure how to proceed please contact aliroot-git-admins@cern.ch
62 # AliAnalysisDataContainer.cxx
63 # AliAnalysisDataSlot.cxx
68 # Headers generated from sources list
69 # - This list is used mainly during dictionary generating and installation step,
70 # all source headers will be installed into $CMAKE_INSTALL_PREFIX/include
71 # - Note that it is possible to create your own custom list of headers, to add
72 # to the existing one or to delete from it. Change this variable as it suits
73 # the purpose of the library, but be sure you do not affect the dictionary
75 # - If you are not sure how to proceed please contact aliroot-git-admins@cern.ch
76 string(REPLACE ".cxx" ".h" HDRS "${SRCS}")
78 # Generating the dictionary
79 # - The name of the LinkDef has to be "${MODULE}LinkDef.h"
80 # - Using custom LinkDef names is for advanced users! If you are not sure
81 # how to generate the dictionary please contact aliroot-git-admins@cern.ch
82 # - If you are not sure how to proceed please contact aliroot-git-admins@cern.ch
83 get_directory_property(incdirs INCLUDE_DIRECTORIES)
84 generate_dictionary("${MODULE}" "${MODULE}LinkDef.h" "${HDRS}" "${incdirs}")
85 # End Generation the dictionary
87 # Seting ROOT and AliRoot dependecies
88 # - Any ROOT symbols used in the current sources has to be added to the list of
90 # - The mapping between ROOT symbols and libraries can be found inside the ROOT
91 # map files. If you are not sure which library contains a certain symbol grep
92 # the rootmap files for the symbol:
95 # $ grep TSelectorCint *.rootmap
96 # libTree.rootmap:Library.TSelectorCint: libTree.so libNet.so libRIO.so libThread.so
97 # TSelectorCint symbol belongs to Tree library and we add it to ROOT_DEPENDENCIES
98 # Ex: set(ROOT_DEPENDENCIES Core Gpad Hist Net RIO Tree XMLParser)
99 # Ex: set(ALIROOT_DEPENDENCIES STEERBase ANALYSIS)
100 # - If you are not sure how to proceed please contact aliroot-git-admins@cern.ch
101 set(ROOT_DEPENDENCIES)
102 set(ALIROOT_DEPENDENCIES)
104 # Generating the ROOT map
105 # - If you are not sure how to proceed please contact aliroot-git-admins@cern.ch
106 set(LIBDEPS ${ROOT_DEPENDENCIES} ${ALIROOT_DEPENDENCIES})
107 generate_rootmap("${MODULE}" "${LIBDEPS}" "${CMAKE_CURRENT_SOURCE_DIR}/${MODULE}LinkDef.h")
108 # End Generating the ROOT map
110 ############################################################################
111 # END GENERAL SETTINGS #
112 ############################################################################
115 ############################################################################
116 # COMPILATION AND LINKING CUSTOM FLAGS #
117 ############################################################################
119 # Setting custom compilation and linking flags
120 # Ex system dependent: Modify the way the library is build
121 # if(${CMAKE_SYSTEM} MATCHES Darwin)
122 # set(MODULE_LINK_FLAGS "-undefined dynamic_lookup")
123 # endif(${CMAKE_SYSTEM} MATCHES Darwin)
124 # - MODULE_COMPILE_FLAGS and MODULE_LINK_FLAGS will be used later for library
126 # - If you are not sure how to proceed please contact aliroot-git-admins@cern.ch
127 set(MODULE_COMPILE_FLAGS )
128 set(MODULE_LINK_FLAGS )
130 ############################################################################
131 # END COMPILATION AND LINKING CUSTOM FLAGS #
132 ############################################################################
135 ############################################################################
137 ############################################################################
139 # Two options are availabe when creating the libraries:
140 # - dynamic only libraries
141 # - dinamic and static libraries
142 # Static libraries are by used the DAs. If you are sure the library will
143 # be used by the DAs it is mandatory to create the static version.
144 # - Use only one of the options at a time, DO NOT FORGET to delete the content
147 ############################################################################
148 ## 1. DYNAMIC LIBRARY CREATION - NO STATIC LIBRARY NEEDED #
149 ############################################################################
151 # Create the dynamic library
152 # - DELETE if static libraries are neded and follow Dynamic/Static libraries
154 # - DELETE the dynamic/static block if only dynamic libraries are needed
155 # - If you are not sure how to proceed please contact aliroot-git-admins@cern.ch
156 add_library(${MODULE} SHARED ${SRCS} G__${MODULE}.cxx)
158 # Additional compilation flags
159 set_target_properties(${MODULE} PROPERTIES COMPILE_FLAGS ${MODULE_COMPILE_FLAGS})
161 # Additional linking flags
162 set_target_properties(${MODULE} PROPERTIES LINK_FLAGS ${MODULE_LINK_FLAGS})
164 # Link library to dependecies
165 target_link_libraries(${MODULE} ${LIBDEPS})
167 ############################################################################
168 ## END DYNAMIC LIBRARY CREATION - NO STATIC LIBRARY NEEDED #
169 ############################################################################
172 ############################################################################
173 ## 2. DYNAMIC/STATIC LIBRARY CREATION #
174 ############################################################################
176 # - If you are not sure how to proceed please contact aliroot-git-admins@cern.ch
177 # - DELETE if no static libraries are needed
178 # - Create an object to be reused in case of static libraries
179 # otherwise the sources will be compiled twice
180 add_library(${MODULE}-object OBJECT ${SRCS} G__${MODULE}.cxx)
182 # - Add a library to the project using the object
183 add_library(${MODULE} SHARED $<TARGET_OBJECTS:${MODULE}-object>)
185 # Setting the correct headers for the object as gathered from the dependencies
186 target_include_directories(${MODULE}-object PUBLIC $<TARGET_PROPERTY:${MODULE},INCLUDE_DIRECTORIES>)
187 set_target_properties(${MODULE}-object PROPERTIES COMPILE_DEFINITIONS $<TARGET_PROPERTY:${MODULE},COMPILE_DEFINITIONS>)
189 # Additional compilation flags
190 set_target_properties(${MODULE}-object PROPERTIES COMPILE_FLAGS "")
192 # Additional linking flags
193 set_target_properties(${MODULE} PROPERTIES LINK_FLAGS ${MODULE_LINK_FLAGS})
195 # Link library to dependecies
196 target_link_libraries(${MODULE} ${LIBDEPS})
198 # Create the static library only if ALIROOT_STATIC variable is set
199 # ALIROOT_STATIC is automatically set by the DA flag
201 add_library(${MODULE}-static STATIC $<TARGET_OBJECTS:${MODULE}-object>)
202 set_target_properties(${MODULE}-static PROPERTIES OUTPUT_NAME ${MODULE})
204 # list of shared dependencies / the name of the variable containing the list of static ones
205 generate_static_dependencies("${ALIROOT_DEPENDENCIES}" "STATIC_ALIROOT_DEPENDENCIES")
206 target_link_libraries(${MODULE}-static ${STATIC_ALIROOT_DEPENDENCIES} Root RootExtra)
208 # Public include folders that will be propagated to the dependecies
209 target_include_directories(${MODULE}-static PUBLIC ${incdirs})
211 set_target_properties(${MODULE}-static PROPERTIES LINK_FLAGS "-Wl,--whole-archive")
214 install(TARGETS ${MODULE}-static
215 ARCHIVE DESTINATION lib
216 LIBRARY DESTINATION lib)
217 endif(ALIROOT_STATIC)
219 ############################################################################
220 ## END DYNAMIC/STATIC LIBRARY CREATION #
221 ############################################################################
223 ############################################################################
224 # END LIBRARY CREATION #
225 ############################################################################
227 ############################################################################
229 ############################################################################
231 # The installation step is copying files needed at runtime into CMAKE_INSTALL_PREFIX
232 # DO NOT forget to install all macros needed to run Grid jobs or any files that are
234 # - If you are not sure how to proceed please contact aliroot-git-admins@cern.ch
236 # Library installation into $CMAKE_INSTALL_PREFIX/lib
237 install(TARGETS ${MODULE}
238 ARCHIVE DESTINATION lib
239 LIBRARY DESTINATION lib)
241 # Header installation into $CMAKE_INSTALL_PREFIX/include
242 install(FILES ${HDRS} DESTINATION include)
244 # Macros installation
245 install(DIRECTORY macros DESTINATION ${MODULE})