]>
Commit | Line | Data |
---|---|---|
b22a7396 | 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 | ||
fffaf6a5 | 16 | # General purpose functions |
17 | ||
7b0a9d94 | 18 | ######################### |
c2f9135f | 19 | # ROOT utilities |
7b0a9d94 | 20 | ######################### |
c2f9135f | 21 | |
fffaf6a5 | 22 | # Generation of the dictionaries |
23 | # @DNAME Dictionary name | |
24 | # @LDNAME LinkDef file name, ex: LinkDef.h | |
25 | # @DHDRS Dictionary headers | |
26 | # @DINCDIR Include folders that need to be passed to cint/cling | |
27 | macro(generate_dictionary DNAME LDNAME DHDRS DINCDIRS) | |
28 | # Creating the INCLUDE path for cint/cling | |
29 | foreach( dir ${DINCDIRS}) | |
30 | set(INCLUDE_PATH -I${dir} ${INCLUDE_PATH}) | |
31 | endforeach() | |
32 | ||
33 | # Generate the dictionary | |
b22a7396 | 34 | # message(STATUS "Generating dictionary ${DNAME} for ${LDNAME}") |
fffaf6a5 | 35 | |
36 | # message(STATUS "${CMAKE_CURRENT_BINARY_DIR}/G__${DNAME}.cxx") | |
37 | # message(STATUS "${CMAKE_CURRENT_BINARY_DIR}/G__${DNAME}.h") | |
38 | # message(STATUS "bbb${INCLUDE_PATH}bbb") | |
39 | # message(STATUS "${DHDRS} ${LDNAME}") | |
40 | # message(STATUS "${CMAKE_CURRENT_SOURCE_DIR}") | |
41 | ||
b168bfa8 | 42 | # Get the definitions from the directory to be sent to CINT |
43 | get_directory_property(tmpdirdefs DEFINITIONS) | |
6f45236b | 44 | string(REPLACE " " ";" tmpdirdefs "${tmpdirdefs}") |
b168bfa8 | 45 | |
fffaf6a5 | 46 | add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/G__${DNAME}.cxx ${CMAKE_CURRENT_BINARY_DIR}/G__${DNAME}.h |
47 | COMMAND LD_LIBRARY_PATH=${ROOT_LIBDIR}:$ENV{LD_LIBRARY_PATH} ${ROOT_CINT} | |
48 | ARGS -f ${CMAKE_CURRENT_BINARY_DIR}/G__${DNAME}.cxx -c -p | |
b168bfa8 | 49 | ${tmpdirdefs} ${INCLUDE_PATH} |
fffaf6a5 | 50 | ${DHDRS} ${LDNAME} |
0224bae4 | 51 | DEPENDS ${DHDRS} ${LDNAME} ${ROOT_CINT} |
fffaf6a5 | 52 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
53 | ) | |
0224bae4 | 54 | endmacro(generate_dictionary) |
55 | ||
56 | # Generate the ROOTmap files | |
57 | # @LIBNAME - library name: libAnalysis.so -> Analysis.rootmap | |
58 | # @LIBDEPS - library dependencies | |
59 | # @LINKDEF - LinkDef header | |
60 | macro(generate_rootmap LIBNAME LIBDEPS LINKDEF) | |
a0f34e87 | 61 | # message(STATUS "LIBNAME = ${LIBNAME}") |
62 | # message(STATUS "LIBDEPS = ${LIBDEPS}") | |
63 | # message(STATUS "LINKDEF = ${LINKDEF}") | |
a0f34e87 | 64 | # message(STATUS "ROOT_LIBMAP=${ROOT_LIBMAP}") |
5e8fe0e0 | 65 | |
66 | set(LOCAL_DEPS) | |
a0f34e87 | 67 | foreach(file ${LIBDEPS}) |
68 | get_filename_component(ext ${file} EXT) | |
69 | if(ext) | |
271875a7 | 70 | set(LOCAL_DEPS ${LOCAL_DEPS} ${file}) |
0224bae4 | 71 | else() |
e3dfb233 | 72 | set(LOCAL_DEPS ${LOCAL_DEPS} lib${file}) |
0224bae4 | 73 | endif() |
74 | endforeach() | |
5e8fe0e0 | 75 | |
b22a7396 | 76 | # message(STATUS "Generating ROOT map for ${LIBNAME}") |
0224bae4 | 77 | add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lib${LIBNAME}.rootmap |
78 | COMMAND LD_LIBRARY_PATH=${ROOT_LIBDIR}:$ENV{LD_LIBRARY_PATH} ${ROOT_LIBMAP} | |
e3dfb233 | 79 | ARGS -o ${CMAKE_CURRENT_BINARY_DIR}/lib${LIBNAME}.rootmap -l lib${LIBNAME} -d ${LOCAL_DEPS} -c ${LINKDEF} |
0224bae4 | 80 | DEPENDS ${LIBNAME} |
81 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} VERBATIM | |
82 | ) | |
83 | add_custom_target(lib${LIBNAME}.rootmap ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/lib${LIBNAME}.rootmap) | |
84 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${LIBNAME}.rootmap DESTINATION lib) | |
85 | ||
befa423d | 86 | endmacro(generate_rootmap) |
87 | ||
7b0a9d94 | 88 | ######################### |
89 | # Static utilities | |
90 | ######################### | |
c2f9135f | 91 | |
befa423d | 92 | # Generate the static dependecies from dynamic list |
93 | # @ shared_list - list of shared libraries | |
94 | # @ static_list - the name of the variable that will contain the list of static libraries | |
95 | macro(generate_static_dependencies shared_list static_list) | |
befa423d | 96 | set(static_list_tmp "") |
97 | foreach(shared_lib ${shared_list}) | |
98 | set(static_list_tmp ${static_list_tmp} "${shared_lib}-static") | |
99 | endforeach() | |
100 | ||
101 | # create the variable with the name received by the macro | |
102 | set(${static_list} ${static_list_tmp}) | |
103 | # set the scope to parent in order to be visible in the parent | |
104 | set(${static_list} PARENT_SCOPE) | |
c2f9135f | 105 | endmacro(generate_static_dependencies) |
106 | ||
7b0a9d94 | 107 | ######################### |
c2f9135f | 108 | # DA utilities |
7b0a9d94 | 109 | ######################### |
252db43c | 110 | |
111 | # Extract the first comment from a DA file | |
112 | # Find the position for first /* and */ and extract the substring | |
113 | macro(getDAdescription _detector _daname) | |
114 | # Reading the file into a string | |
115 | file(READ "${_detector}${_daname}da.cxx" tmpinfo) | |
116 | ||
117 | # Find the first occurance of /* */ | |
118 | string(FIND "${tmpinfo}" "/*" _first_position) | |
119 | string(FIND "${tmpinfo}" "*/" _second_position) | |
120 | ||
121 | # Adding and removing 2 characters to remove /* */ | |
122 | math(EXPR _first_position ${_first_position}+2) | |
123 | math(EXPR _second_position ${_second_position}-2) | |
124 | ||
125 | # Generating the length of the comment in order to take out the description | |
126 | math(EXPR _desc_length ${_second_position}-${_first_position}) | |
127 | ||
128 | if(${_desc_length} EQUAL 0 OR ${_desc_length} LESS 0) | |
129 | message(FATAL_ERROR "{_detector}${_daname}da.cxx does not contain a description. Please add the description as the first /*comment*/ in the file") | |
130 | else() | |
131 | string(SUBSTRING "${tmpinfo}" ${_first_position} ${_second_position} _da_description) | |
6646d571 | 132 | string(STRIP "${_da_description}" _da_description) |
252db43c | 133 | |
134 | # The variable can be accesed by the parent | |
135 | set(RPM_DESCRIPTION ${_da_description}) | |
136 | endif() | |
137 | endmacro() | |
138 | ||
139 | # Set the compilation flags | |
140 | macro(setDAflags) | |
141 | # DIM | |
142 | link_directories(${DIMDIR}/${ODIR}) | |
143 | ||
144 | #daqDA flags | |
145 | include_directories(${daqDA}) | |
146 | link_directories(${daqDA}) | |
147 | ||
148 | # AMORE definitions | |
149 | add_definitions(${AMORE_DEFINITIONS}) | |
150 | include_directories(${AMORE_INCLUDE_DIR}) | |
151 | ||
152 | endmacro() | |
153 | ||
154 | # Generate a DA | |
155 | macro(generateDA DETECTOR ALGORITHM STATIC_DEPENDENCIES) | |
156 | setDAflags() | |
157 | ||
158 | # Generating the DA executable | |
159 | add_executable(${DETECTOR}${ALGORITHM}da ${DETECTOR}${ALGORITHM}da.cxx) # | |
160 | ||
161 | # DA flags and linking information | |
162 | set(MODULE_COMPILE_FLAGS) | |
163 | set(MODULE_LINK_FLAGS) | |
164 | ||
165 | target_link_libraries(${DETECTOR}${ALGORITHM}da ${STATIC_DEPENDENCIES} ${AMORE_AUXLIBS} daqDA ${DATE_MONLIBRARIES} ${DATE_RCPROXYLIBRARIES} Root RootExtra) # 1 | |
166 | ||
167 | # different flags | |
168 | set(MODULE_COMPILE_FLAGS " ${DATE_CFLAGS} ${AMORE_CFLAGS}") | |
169 | set(MODULE_LINK_FLAGS "${DATE_LDFLAGS} ${AMORE_STATICLIBS}") | |
170 | ||
171 | set_target_properties(${DETECTOR}${ALGORITHM}da PROPERTIES COMPILE_FLAGS ${MODULE_COMPILE_FLAGS}) | |
172 | set_target_properties(${DETECTOR}${ALGORITHM}da PROPERTIES LINK_FLAGS "${MODULE_LINK_FLAGS}") | |
173 | ||
174 | # Installation | |
175 | install(TARGETS ${DETECTOR}${ALGORITHM}da RUNTIME DESTINATION bin) | |
176 | ||
177 | if(DARPM) | |
178 | createDArpm("${DETECTOR}" "${ALGORITHM}") | |
179 | endif(DARPM) | |
180 | endmacro() | |
c2f9135f | 181 | |
182 | # DA rpm creation | |
183 | macro(createDArpm DETECTOR ALGORITHM) | |
252db43c | 184 | getDAdescription("${DETECTOR}" "${ALGORITHM}") |
c2f9135f | 185 | |
186 | set(DA_EXECUTABLE "${DETECTOR}${ALGORITHM}da") | |
252db43c | 187 | set(DETECTOR "${DETECTOR}") |
188 | set(ALGORITHM "${ALGORITHM}") | |
189 | set(RPM_DESCRIPTION ${RPM_DESCRIPTION}) | |
190 | ||
191 | if(ALGORITHM STREQUAL "") | |
192 | set(_ALGORITHM "none") | |
193 | set(DA_PREFIX "opt/daqDA-${DETECTOR}") | |
194 | set(DA_NAME "daqDA-${DETECTOR}") | |
195 | else() | |
196 | set(_ALGORITHM ${ALGORITHM}) | |
197 | set(DA_PREFIX "opt/daqDA-${DETECTOR}-${ALGORITHM}") | |
198 | set(DA_NAME "daqDA-${DETECTOR}-${ALGORITHM}") | |
199 | endif() | |
200 | ||
201 | configure_file("${AliRoot_SOURCE_DIR}/cmake/da.spec.in" "${_ALGORITHM}-da.spec" @ONLY) | |
c2f9135f | 202 | |
203 | add_custom_command(TARGET ${DETECTOR}${ALGORITHM}da POST_BUILD | |
252db43c | 204 | COMMAND mkdir ARGS -p da-${_ALGORITHM}-rpm/root/${DA_PREFIX}/ |
205 | COMMAND cp ARGS ${DETECTOR}${ALGORITHM}da da-${_ALGORITHM}-rpm/root/${DA_PREFIX}/ | |
206 | COMMAND rpmbuild ARGS --verbose --define "_topdir ${CMAKE_CURRENT_BINARY_DIR}/da-${_ALGORITHM}-rpm" --define "%buildroot ${CMAKE_CURRENT_BINARY_DIR}/da-${_ALGORITHM}-rpm/root" -bb ${_ALGORITHM}-da.spec | |
c2f9135f | 207 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} VERBATIM |
252db43c | 208 | COMMENT "RPM creation for ${DETECTOR}-${_ALGORITHM}" |
c2f9135f | 209 | ) |
252db43c | 210 | |
211 | # make clean will remove also the rpm folder | |
212 | # Retrive the current list of file to be deleted - set_directory_property is overwriting, not adding to the list | |
213 | get_directory_property(_clean_files ADDITIONAL_MAKE_CLEAN_FILES) | |
214 | set(_clean_files da-${_ALGORITHM}-rpm ${_clean_files}) | |
215 | set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${_clean_files}") | |
216 | ||
217 | # install RPM into $CMAKE_INSTALL_PREFIX/darpms | |
218 | install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/da-${_ALGORITHM}-rpm/RPMS/ DESTINATION darpms PATTERN "\\.rpm") | |
6646d571 | 219 | endmacro() |