]> git.uio.no Git - u/mrichter/AliRoot.git/blob - cmake/CMakeLists.example
ALIROOT-5792 data/galice.cuts modified for ZDC
[u/mrichter/AliRoot.git] / cmake / CMakeLists.example
1 # **************************************************************************
2 # * Copyright(c) 1998-2015, 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 ############################################################################
17 # GENERAL SETTINGS                                                         #
18 ############################################################################
19
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 
25 #     version 2.8.11
26 #     http://www.cmake.org/cmake/help/v2.8.11/cmake.html
27
28 # Module name
29 # Module name translates into library name
30 # Ex: set(MODULE ANALYSIS)
31 set(MODULE ModuleNameExample)
32
33 # Module include folder
34 #  - Add here all include folders containing headers that belong
35 #    to this module. 
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})
42 include_directories()
43
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
53 #                   )
54 include_directories(
55                    )
56
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
60 # Ex:
61 #set(SRCS
62 #    AliAnalysisDataContainer.cxx
63 #    AliAnalysisDataSlot.cxx
64 #   )
65 set(SRCS
66    )
67
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 
74 #    generation
75 #  - If you are not sure how to proceed please contact aliroot-git-admins@cern.ch
76 string(REPLACE ".cxx" ".h" HDRS "${SRCS}")
77
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")
85
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
94
95 # Seting ROOT and AliRoot dependecies
96 #  - Any ROOT symbols used in the current sources has to be added to the list of 
97 #    dependecies. 
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:
101 # Ex:
102 #       $ cd $ROOTSYS/lib
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)
111
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
117
118 # Generate a PARfile target for this library
119 #  - This command tells CMake to generate a target that, in turn, will generate a PARfile
120 #  - With a PARfile it's possible to override an AliRoot/AliPhysics library with our modified
121 #    version
122 #  - This "hotpatching" is useful if we want to test local modifications e.g. on the Grid without
123 #    pushing our commits
124 #  - There is a 1:1 correspondence between a library (e.g. libMODULE.so) and a PARfile
125 #    (e.g. MODULE.par): if we load remotely a PARfile for a certain library, we are going to
126 #    override only that library
127 #  - This command only generates a target: PARfiles are not generated automatically. If a library
128 #    is PARfile-enabled (condition achieved by using the command below), then the PARfile can be
129 #    created by:
130 #      cd <aliroot_build_dir>  # e.g. cd $ALICE_ROOT/../build
131 #      make MODULE.par
132 #      make install
133 #    The file MODULE.par will be found in $ALICE_ROOT/PARfiles/MODULE.par
134 #  - It is also possible to specify another string after "${LIBDEPS}", an optional parameter to tell
135 #    the PARfile that extra include paths (both relative to the current directory and absolute) are
136 #    needed in order to build the corresponding library
137 #add_target_parfile(${MODULE} "${SRCS}" "${HDRS}" "${MODULE}LinkDef.h" "${LIBDEPS}")
138 # End Generate a PARfile target for this library
139
140 ############################################################################
141 # END GENERAL SETTINGS                                                     #
142 ############################################################################
143
144
145 ############################################################################
146 # COMPILATION AND LINKING CUSTOM FLAGS                                    #
147 ############################################################################
148
149 # Setting custom compilation and linking flags
150 # Ex system dependent: Modify the way the library is build
151 #       if(${CMAKE_SYSTEM} MATCHES Darwin)
152 #               set(MODULE_LINK_FLAGS "-undefined dynamic_lookup")
153 #       endif(${CMAKE_SYSTEM} MATCHES Darwin)
154 #  - MODULE_COMPILE_FLAGS and MODULE_LINK_FLAGS will be used later for library
155 #    generation
156 #  - If you are not sure how to proceed please contact aliroot-git-admins@cern.ch
157 set(MODULE_COMPILE_FLAGS )
158 set(MODULE_LINK_FLAGS )
159
160 ############################################################################
161 # END COMPILATION AND LINKING  CUSTOM FLAGS                                #
162 ############################################################################
163
164
165 ############################################################################
166 # LIBRARY CREATION                                                         #
167 ############################################################################
168
169 # Two options are availabe when creating the libraries:
170 #       - dynamic only libraries
171 #       - dinamic and static libraries
172 #         Static libraries are by used the DAs. If you are sure the library will 
173 #         be used by the DAs it is mandatory to create the static version.
174 #  - Use only one of the options at a time, DO NOT FORGET to delete the content
175 #    that is not used
176
177 ############################################################################
178 ## 1. DYNAMIC LIBRARY CREATION - NO STATIC LIBRARY NEEDED                  #
179 ############################################################################
180
181 # Create the dynamic library
182 #  - DELETE if static libraries are neded and follow Dynamic/Static libraries 
183 #    instructions
184 #  - DELETE the dynamic/static block if only dynamic libraries are needed
185 #  - If you are not sure how to proceed please contact aliroot-git-admins@cern.ch
186 add_library(${MODULE} SHARED ${SRCS} G__${MODULE}.cxx)
187
188 # Additional compilation flags
189 set_target_properties(${MODULE} PROPERTIES COMPILE_FLAGS ${MODULE_COMPILE_FLAGS})
190
191 # Additional linking flags
192 set_target_properties(${MODULE} PROPERTIES LINK_FLAGS ${MODULE_LINK_FLAGS})
193
194 # Link library to dependecies
195 target_link_libraries(${MODULE} ${LIBDEPS})
196
197 ############################################################################
198 ## END DYNAMIC LIBRARY CREATION - NO STATIC LIBRARY NEEDED                 #
199 ############################################################################
200
201
202 ############################################################################
203 ## 2. DYNAMIC/STATIC LIBRARY CREATION                                      #
204 ############################################################################
205
206 #  - If you are not sure how to proceed please contact aliroot-git-admins@cern.ch
207 #  - DELETE if no static libraries are needed
208 #  - Create an object to be reused in case of static libraries 
209 #    otherwise the sources will be compiled twice
210 add_library(${MODULE}-object OBJECT ${SRCS} G__${MODULE}.cxx)
211
212 #  - Add a library to the project using the object
213 add_library(${MODULE} SHARED $<TARGET_OBJECTS:${MODULE}-object>)
214
215 # Setting the correct headers for the object as gathered from the dependencies
216 target_include_directories(${MODULE}-object PUBLIC $<TARGET_PROPERTY:${MODULE},INCLUDE_DIRECTORIES>)
217 set_target_properties(${MODULE}-object PROPERTIES COMPILE_DEFINITIONS $<TARGET_PROPERTY:${MODULE},COMPILE_DEFINITIONS>)
218
219 # Additional compilation flags
220 set_target_properties(${MODULE}-object PROPERTIES COMPILE_FLAGS "")
221
222 # Additional linking flags
223 set_target_properties(${MODULE} PROPERTIES LINK_FLAGS ${MODULE_LINK_FLAGS})
224
225 # Link library to dependecies
226 target_link_libraries(${MODULE} ${LIBDEPS})
227
228 # Create the static library only if ALIROOT_STATIC variable is set
229 # ALIROOT_STATIC is automatically set by the DA flag
230 if(ALIROOT_STATIC)
231     add_library(${MODULE}-static STATIC $<TARGET_OBJECTS:${MODULE}-object>)
232     set_target_properties(${MODULE}-static PROPERTIES OUTPUT_NAME ${MODULE})
233
234     # list of shared dependencies / the name of the variable containing the list of static ones
235     generate_static_dependencies("${ALIROOT_DEPENDENCIES}" "STATIC_ALIROOT_DEPENDENCIES")
236     target_link_libraries(${MODULE}-static ${STATIC_ALIROOT_DEPENDENCIES} Root RootExtra)
237
238     # Public include folders that will be propagated to the dependecies
239     target_include_directories(${MODULE}-static PUBLIC ${incdirs})
240     
241     set_target_properties(${MODULE}-static PROPERTIES LINK_FLAGS "-Wl,--whole-archive")
242
243     # Installation
244     install(TARGETS ${MODULE}-static
245             ARCHIVE DESTINATION lib
246             LIBRARY DESTINATION lib)
247 endif(ALIROOT_STATIC)
248
249 ############################################################################
250 ## END DYNAMIC/STATIC LIBRARY CREATION                                     #
251 ############################################################################
252
253 ############################################################################
254 # END LIBRARY CREATION                                                     #
255 ############################################################################
256
257 ############################################################################
258 # INSTALLATION                                                             #
259 ############################################################################
260
261 # The installation step is copying files needed at runtime into CMAKE_INSTALL_PREFIX
262 # DO NOT forget to install all macros needed to run Grid jobs or any files that are
263 # needed as input.
264 #  - If you are not sure how to proceed please contact aliroot-git-admins@cern.ch
265
266 # Library installation into $CMAKE_INSTALL_PREFIX/lib
267 install(TARGETS ${MODULE}
268         ARCHIVE DESTINATION lib
269         LIBRARY DESTINATION lib)
270
271 # Header installation into $CMAKE_INSTALL_PREFIX/include
272 install(FILES ${HDRS} DESTINATION include)
273
274 # Macros installation
275 install(DIRECTORY macros DESTINATION ${MODULE})