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 # Additional headers, with no corresponding sources
79 # - Instead of adding headers to the HDRS variable with the string(REPLACE)
80 # command above, you can use a separate list
81 # - With this optional command, headers are appended to the HDRS list
82 # - Those headers will be installed in the include directory during the
83 # installation process
84 #list(APPEND HDRS "header1.h" "header2.h" "header3.h")
86 # Generating the dictionary
87 # - The name of the LinkDef has to be "${MODULE}LinkDef.h"
88 # - Using custom LinkDef names is for advanced users! If you are not sure
89 # how to generate the dictionary please contact aliroot-git-admins@cern.ch
90 # - If you are not sure how to proceed please contact aliroot-git-admins@cern.ch
91 get_directory_property(incdirs INCLUDE_DIRECTORIES)
92 generate_dictionary("${MODULE}" "${MODULE}LinkDef.h" "${HDRS}" "${incdirs}")
93 # End Generation the dictionary
95 # Seting ROOT and AliRoot dependecies
96 # - Any ROOT symbols used in the current sources has to be added to the list of
98 # - The mapping between ROOT symbols and libraries can be found inside the ROOT
99 # map files. If you are not sure which library contains a certain symbol grep
100 # the rootmap files for the symbol:
103 # $ grep TSelectorCint *.rootmap
104 # libTree.rootmap:Library.TSelectorCint: libTree.so libNet.so libRIO.so libThread.so
105 # TSelectorCint symbol belongs to Tree library and we add it to ROOT_DEPENDENCIES
106 # Ex: set(ROOT_DEPENDENCIES Core Gpad Hist Net RIO Tree XMLParser)
107 # Ex: set(ALIROOT_DEPENDENCIES STEERBase ANALYSIS)
108 # - If you are not sure how to proceed please contact aliroot-git-admins@cern.ch
109 set(ROOT_DEPENDENCIES)
110 set(ALIROOT_DEPENDENCIES)
112 # Generating the ROOT map
113 # - If you are not sure how to proceed please contact aliroot-git-admins@cern.ch
114 set(LIBDEPS ${ROOT_DEPENDENCIES} ${ALIROOT_DEPENDENCIES})
115 generate_rootmap("${MODULE}" "${LIBDEPS}" "${CMAKE_CURRENT_SOURCE_DIR}/${MODULE}LinkDef.h")
116 # End Generating the ROOT map
118 ############################################################################
119 # END GENERAL SETTINGS #
120 ############################################################################
123 ############################################################################
124 # COMPILATION AND LINKING CUSTOM FLAGS #
125 ############################################################################
127 # Setting custom compilation and linking flags
128 # Ex system dependent: Modify the way the library is build
129 # if(${CMAKE_SYSTEM} MATCHES Darwin)
130 # set(MODULE_LINK_FLAGS "-undefined dynamic_lookup")
131 # endif(${CMAKE_SYSTEM} MATCHES Darwin)
132 # - MODULE_COMPILE_FLAGS and MODULE_LINK_FLAGS will be used later for library
134 # - If you are not sure how to proceed please contact aliroot-git-admins@cern.ch
135 set(MODULE_COMPILE_FLAGS )
136 set(MODULE_LINK_FLAGS )
138 ############################################################################
139 # END COMPILATION AND LINKING CUSTOM FLAGS #
140 ############################################################################
143 ############################################################################
145 ############################################################################
147 # Two options are availabe when creating the libraries:
148 # - dynamic only libraries
149 # - dinamic and static libraries
150 # Static libraries are by used the DAs. If you are sure the library will
151 # be used by the DAs it is mandatory to create the static version.
152 # - Use only one of the options at a time, DO NOT FORGET to delete the content
155 ############################################################################
156 ## 1. DYNAMIC LIBRARY CREATION - NO STATIC LIBRARY NEEDED #
157 ############################################################################
159 # Create the dynamic library
160 # - DELETE if static libraries are neded and follow Dynamic/Static libraries
162 # - DELETE the dynamic/static block if only dynamic libraries are needed
163 # - If you are not sure how to proceed please contact aliroot-git-admins@cern.ch
164 add_library(${MODULE} SHARED ${SRCS} G__${MODULE}.cxx)
166 # Additional compilation flags
167 set_target_properties(${MODULE} PROPERTIES COMPILE_FLAGS ${MODULE_COMPILE_FLAGS})
169 # Additional linking flags
170 set_target_properties(${MODULE} PROPERTIES LINK_FLAGS ${MODULE_LINK_FLAGS})
172 # Link library to dependecies
173 target_link_libraries(${MODULE} ${LIBDEPS})
175 ############################################################################
176 ## END DYNAMIC LIBRARY CREATION - NO STATIC LIBRARY NEEDED #
177 ############################################################################
180 ############################################################################
181 ## 2. DYNAMIC/STATIC LIBRARY CREATION #
182 ############################################################################
184 # - If you are not sure how to proceed please contact aliroot-git-admins@cern.ch
185 # - DELETE if no static libraries are needed
186 # - Create an object to be reused in case of static libraries
187 # otherwise the sources will be compiled twice
188 add_library(${MODULE}-object OBJECT ${SRCS} G__${MODULE}.cxx)
190 # - Add a library to the project using the object
191 add_library(${MODULE} SHARED $<TARGET_OBJECTS:${MODULE}-object>)
193 # Setting the correct headers for the object as gathered from the dependencies
194 target_include_directories(${MODULE}-object PUBLIC $<TARGET_PROPERTY:${MODULE},INCLUDE_DIRECTORIES>)
195 set_target_properties(${MODULE}-object PROPERTIES COMPILE_DEFINITIONS $<TARGET_PROPERTY:${MODULE},COMPILE_DEFINITIONS>)
197 # Additional compilation flags
198 set_target_properties(${MODULE}-object PROPERTIES COMPILE_FLAGS "")
200 # Additional linking flags
201 set_target_properties(${MODULE} PROPERTIES LINK_FLAGS ${MODULE_LINK_FLAGS})
203 # Link library to dependecies
204 target_link_libraries(${MODULE} ${LIBDEPS})
206 # Create the static library only if ALIROOT_STATIC variable is set
207 # ALIROOT_STATIC is automatically set by the DA flag
209 add_library(${MODULE}-static STATIC $<TARGET_OBJECTS:${MODULE}-object>)
210 set_target_properties(${MODULE}-static PROPERTIES OUTPUT_NAME ${MODULE})
212 # list of shared dependencies / the name of the variable containing the list of static ones
213 generate_static_dependencies("${ALIROOT_DEPENDENCIES}" "STATIC_ALIROOT_DEPENDENCIES")
214 target_link_libraries(${MODULE}-static ${STATIC_ALIROOT_DEPENDENCIES} Root RootExtra)
216 # Public include folders that will be propagated to the dependecies
217 target_include_directories(${MODULE}-static PUBLIC ${incdirs})
219 set_target_properties(${MODULE}-static PROPERTIES LINK_FLAGS "-Wl,--whole-archive")
222 install(TARGETS ${MODULE}-static
223 ARCHIVE DESTINATION lib
224 LIBRARY DESTINATION lib)
225 endif(ALIROOT_STATIC)
227 ############################################################################
228 ## END DYNAMIC/STATIC LIBRARY CREATION #
229 ############################################################################
231 ############################################################################
232 # END LIBRARY CREATION #
233 ############################################################################
235 ############################################################################
237 ############################################################################
239 # The installation step is copying files needed at runtime into CMAKE_INSTALL_PREFIX
240 # DO NOT forget to install all macros needed to run Grid jobs or any files that are
242 # - If you are not sure how to proceed please contact aliroot-git-admins@cern.ch
244 # Library installation into $CMAKE_INSTALL_PREFIX/lib
245 install(TARGETS ${MODULE}
246 ARCHIVE DESTINATION lib
247 LIBRARY DESTINATION lib)
249 # Header installation into $CMAKE_INSTALL_PREFIX/include
250 install(FILES ${HDRS} DESTINATION include)
252 # Macros installation
253 install(DIRECTORY macros DESTINATION ${MODULE})