]> git.uio.no Git - u/mrichter/AliRoot.git/blob - cmake/CMakeLists.example
PAR: do not prepend ./ to extra include paths
[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 ############################################################################
119 # END GENERAL SETTINGS                                                     #
120 ############################################################################
121
122
123 ############################################################################
124 # COMPILATION AND LINKING CUSTOM FLAGS                                    #
125 ############################################################################
126
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
133 #    generation
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 )
137
138 ############################################################################
139 # END COMPILATION AND LINKING  CUSTOM FLAGS                                #
140 ############################################################################
141
142
143 ############################################################################
144 # LIBRARY CREATION                                                         #
145 ############################################################################
146
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
153 #    that is not used
154
155 ############################################################################
156 ## 1. DYNAMIC LIBRARY CREATION - NO STATIC LIBRARY NEEDED                  #
157 ############################################################################
158
159 # Create the dynamic library
160 #  - DELETE if static libraries are neded and follow Dynamic/Static libraries 
161 #    instructions
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)
165
166 # Additional compilation flags
167 set_target_properties(${MODULE} PROPERTIES COMPILE_FLAGS ${MODULE_COMPILE_FLAGS})
168
169 # Additional linking flags
170 set_target_properties(${MODULE} PROPERTIES LINK_FLAGS ${MODULE_LINK_FLAGS})
171
172 # Link library to dependecies
173 target_link_libraries(${MODULE} ${LIBDEPS})
174
175 ############################################################################
176 ## END DYNAMIC LIBRARY CREATION - NO STATIC LIBRARY NEEDED                 #
177 ############################################################################
178
179
180 ############################################################################
181 ## 2. DYNAMIC/STATIC LIBRARY CREATION                                      #
182 ############################################################################
183
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)
189
190 #  - Add a library to the project using the object
191 add_library(${MODULE} SHARED $<TARGET_OBJECTS:${MODULE}-object>)
192
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>)
196
197 # Additional compilation flags
198 set_target_properties(${MODULE}-object PROPERTIES COMPILE_FLAGS "")
199
200 # Additional linking flags
201 set_target_properties(${MODULE} PROPERTIES LINK_FLAGS ${MODULE_LINK_FLAGS})
202
203 # Link library to dependecies
204 target_link_libraries(${MODULE} ${LIBDEPS})
205
206 # Create the static library only if ALIROOT_STATIC variable is set
207 # ALIROOT_STATIC is automatically set by the DA flag
208 if(ALIROOT_STATIC)
209     add_library(${MODULE}-static STATIC $<TARGET_OBJECTS:${MODULE}-object>)
210     set_target_properties(${MODULE}-static PROPERTIES OUTPUT_NAME ${MODULE})
211
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)
215
216     # Public include folders that will be propagated to the dependecies
217     target_include_directories(${MODULE}-static PUBLIC ${incdirs})
218     
219     set_target_properties(${MODULE}-static PROPERTIES LINK_FLAGS "-Wl,--whole-archive")
220
221     # Installation
222     install(TARGETS ${MODULE}-static
223             ARCHIVE DESTINATION lib
224             LIBRARY DESTINATION lib)
225 endif(ALIROOT_STATIC)
226
227 ############################################################################
228 ## END DYNAMIC/STATIC LIBRARY CREATION                                     #
229 ############################################################################
230
231 ############################################################################
232 # END LIBRARY CREATION                                                     #
233 ############################################################################
234
235 ############################################################################
236 # INSTALLATION                                                             #
237 ############################################################################
238
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
241 # needed as input.
242 #  - If you are not sure how to proceed please contact aliroot-git-admins@cern.ch
243
244 # Library installation into $CMAKE_INSTALL_PREFIX/lib
245 install(TARGETS ${MODULE}
246         ARCHIVE DESTINATION lib
247         LIBRARY DESTINATION lib)
248
249 # Header installation into $CMAKE_INSTALL_PREFIX/include
250 install(FILES ${HDRS} DESTINATION include)
251
252 # Macros installation
253 install(DIRECTORY macros DESTINATION ${MODULE})