]>
Commit | Line | Data |
---|---|---|
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 | ||
16 | # Checking for a proper ROOT installation based on the ROOTSYS variable | |
17 | # received during configuration | |
18 | # If proper root installation it is setting the following variables | |
19 | # - ROOT_VERSION - ROOT version as reported by root-config | |
20 | # - ROOT_VERSION_MAJOR | |
21 | # - ROOT_VERSIOM_MINOR | |
22 | # - ROOT_VERSION_PATCH | |
23 | # - ROOT_CONFIG - path to root-config script | |
24 | # - ROOT_CINT - path to rootcint executable | |
25 | # - ROOT_LIBMAP - path to rlibmap executable | |
26 | # - ROOT_FEATURES - list of build features for ROOT | |
27 | # - ROOT_LIBDIR - full path to ROOT library folder | |
28 | # - ROOT_ETCDIR - full path to the ROOT's configuration directory | |
29 | # - ROOT_LIBRARIES - libraries needed for the package to be used | |
30 | # - ROOT_GLIBRARIES - regular + GUI ROOT libraries + path to be used during linking | |
31 | # - ROOT_INCLUDE_DIR - full path to ROOT include folder | |
32 | # - ROOT_HASALIEN - ROOT was built with AliEn support | |
33 | # - ROOT_HASOPENGL - ROOT was built with OpenGL support | |
34 | # - ROOT_HASXML - ROOT was built with XML support | |
35 | # - ROOT_FORTRAN - fortran compiler | |
36 | ||
37 | set(ROOT_FOUND FALSE) | |
38 | ||
39 | if(ROOTSYS) | |
40 | message(STATUS "Checking for a proper ROOT installation in ${ROOTSYS}.") | |
41 | ||
42 | # Setting defaults | |
43 | set(ROOT_LIBDIR ${ROOTSYS}/lib) | |
44 | set(ROOT_INCLUDE_DIR ${ROOTSYS}/include) | |
45 | ||
46 | # Check for root-config scripts | |
47 | find_program(ROOT_CONFIG NAMES root-config PATHS ${ROOTSYS}/bin NO_DEFAULT_PATH) | |
48 | ||
49 | if(NOT ROOT_CONFIG) | |
50 | message(FATAL_ERROR "Could not find root-config script.") | |
51 | endif(NOT ROOT_CONFIG) | |
52 | ||
53 | # Check for rlibmap | |
54 | find_program(ROOT_LIBMAP NAMES rlibmap rootcling PATHS ${ROOTSYS}/bin NO_DEFAULT_PATH) | |
55 | if(ROOT_LIBMAP) | |
56 | message(STATUS "Found ${ROOT_LIBMAP}") | |
57 | else() | |
58 | message(FATAL_ERROR "Could not find rlibmap executable.") | |
59 | endif(ROOT_LIBMAP) | |
60 | ||
61 | # Check for rootcint | |
62 | find_program(ROOT_CINT NAMES rootcint PATHS ${ROOTSYS}/bin NO_DEFAULT_PATH) | |
63 | if(ROOT_CINT) | |
64 | message(STATUS "Found ${ROOT_CINT}") | |
65 | else() | |
66 | message(FATAL_ERROR "Could not find rootcint executable.") | |
67 | endif(ROOT_CINT) | |
68 | ||
69 | # Checking ROOT version | |
70 | execute_process(COMMAND ${ROOT_CONFIG} --version OUTPUT_VARIABLE ROOT_VERSION ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE ) | |
71 | if(error) | |
72 | message(FATAL_ERROR "Error retrieving ROOT version : ${error}") | |
73 | endif(error) | |
74 | string(STRIP "${ROOT_VERSION}" ROOT_VERSION) | |
75 | ||
76 | # Extract major, minor, and patch versions from | |
77 | string(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+.*" "\\1" ROOT_VERSION_MAJOR "${ROOT_VERSION}") | |
78 | string(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+\\/[0-9][0-9]+.*" "\\1" ROOT_VERSION_MINOR "${ROOT_VERSION}") | |
79 | string(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+\\/([0-9][0-9]+).*" "\\1" ROOT_VERSION_PATCH "${ROOT_VERSION}") | |
80 | message(STATUS "Found ROOT version ${ROOT_VERSION_MAJOR}.${ROOT_VERSION_MINOR}.${ROOT_VERSION_PATCH}") | |
81 | ||
82 | # Print ROOT features | |
83 | execute_process(COMMAND ${ROOT_CONFIG} --features OUTPUT_VARIABLE ROOT_FEATURES ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE ) | |
84 | if(error) | |
85 | message(FATAL_ERROR "Error retrieving ROOT features : ${error}") | |
86 | else() | |
87 | message(STATUS "ROOT was built with the following features: ${ROOT_FEATURES}") | |
88 | endif(error) | |
89 | string(STRIP "${ROOT_FEATURES}" ROOT_FEATURES) | |
90 | ||
91 | # Checking for ROOT libdir | |
92 | execute_process(COMMAND ${ROOT_CONFIG} --libdir OUTPUT_VARIABLE ROOT_LIBDIR ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE ) | |
93 | if(error) | |
94 | message(FATAL_ERROR "Error retrieving ROOT libdir: ${error}") | |
95 | endif(error) | |
96 | string(STRIP "${ROOT_LIBDIR}" ROOT_LIBDIR) | |
97 | ||
98 | # Checking for ROOT etcdir | |
99 | execute_process(COMMAND ${ROOT_CONFIG} --etcdir OUTPUT_VARIABLE ROOT_ETCDIR ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE) | |
100 | if(error) | |
101 | message(FATAL_ERROR "Error retrieving ROOT etcdir: ${error}") | |
102 | endif(error) | |
103 | string(STRIP "${ROOT_ETCDIR}" ROOT_ETCDIR) | |
104 | ||
105 | # Checking for ROOT libs | |
106 | execute_process(COMMAND ${ROOT_CONFIG} --noldflags --libs OUTPUT_VARIABLE ROOT_LIBS ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE ) | |
107 | if(error) | |
108 | message(FATAL_ERROR "Error retrieving ROOT libdir: ${error}") | |
109 | endif(error) | |
110 | string(STRIP "${ROOT_LIBS}" ROOT_LIBS) | |
111 | ||
112 | foreach(lib ${ROOT_LIBS}) | |
113 | string(REPLACE "-rdynamic" "" new_lib ${lib}) | |
114 | string(REPLACE "-l" "" lib ${new_lib}) | |
115 | set(ROOT_LIBRARIES ${ROOT_LIBRARIES} ${lib}) | |
116 | endforeach() | |
117 | string(STRIP "${ROOT_LIBRARIES}" ROOT_LIBRARIES) | |
118 | separate_arguments(ROOT_LIBRARIES) | |
119 | ||
120 | # Checking for ROOT incdir | |
121 | execute_process(COMMAND ${ROOT_CONFIG} --incdir OUTPUT_VARIABLE ROOT_INCDIR ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE ) | |
122 | if(error) | |
123 | message(FATAL_ERROR "Error retrieving ROOT incdir: ${error}") | |
124 | endif(error) | |
125 | string(STRIP "${ROOT_INCDIR}" ROOT_INCDIR) | |
126 | set(ROOT_INCLUDE_DIR ${ROOT_INCDIR}) | |
127 | ||
128 | # Checking for glibs | |
129 | execute_process(COMMAND ${ROOT_CONFIG} --noldflags --glibs OUTPUT_VARIABLE ROOT_GLIBS ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE ) | |
130 | if(error) | |
131 | message(FATAL_ERROR "Error retrieving ROOT glibs: ${error}") | |
132 | endif(error) | |
133 | ||
134 | # Checking for glibs | |
135 | string(STRIP "${ROOT_GLIBS}" ROOT_GLIBS) | |
136 | ||
137 | foreach(lib ${ROOT_GLIBS}) | |
138 | string(REPLACE "-rdynamic" "" new_lib "${lib}") | |
139 | string(REPLACE "-l" "" lib "${new_lib}") | |
140 | set(ROOT_GLIBRARIES ${ROOT_GLIBRARIES} ${lib}) | |
141 | endforeach() | |
142 | string(STRIP "${ROOT_GLIBRARIES}" ROOT_GLIBRARIES) | |
143 | separate_arguments(ROOT_GLIBRARIES) | |
144 | ||
145 | # Checking for AliEn support | |
146 | # If AliEn support is enabled we need to point to AliEn | |
147 | execute_process(COMMAND ${ROOT_CONFIG} --has-alien OUTPUT_VARIABLE ROOT_HASALIEN ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE ) | |
148 | if(error) | |
149 | message(FATAL_ERROR "Error checking if ROOT was built with AliEn support: ${error}") | |
150 | endif(error) | |
151 | ||
152 | #if defined | |
153 | if(ROOT_HASALIEN) | |
154 | string(STRIP "${ROOT_HASALIEN}" ROOT_HASALIEN) | |
155 | if(ROOT_HASALIEN STREQUAL "yes") | |
156 | if(ALIEN) | |
157 | add_definitions(-DWITHALIEN) | |
158 | ||
159 | # AliEn might bring some system libraries, we need to use them | |
160 | if(EXISTS "${ALIEN}/lib") | |
161 | link_directories(${ALIEN}/lib) | |
162 | endif() | |
163 | ||
164 | # api/lib should always exists | |
165 | if(EXISTS "${ALIEN}/api/lib") | |
166 | link_directories(${ALIEN}/api/lib) | |
167 | endif() | |
168 | ||
169 | # include for AliEn | |
170 | if(EXISTS "${ALIEN}/include") | |
171 | include_directories(SYSTEM ${ALIEN}/include) | |
172 | endif() | |
173 | ||
174 | # api/include always exists | |
175 | if(EXISTS "${ALIEN}/api/include") | |
176 | include_directories(SYSTEM ${ALIEN}/api/include) | |
177 | endif() | |
178 | ||
179 | set(ROOT_HASALIEN TRUE) | |
180 | else(ALIEN) | |
181 | message(FATAL_ERROR "ROOT was built with AliEn support but no AliEn installation found. Please set \"ALIEN\" to point to your AliEn installation.") | |
182 | endif(ALIEN) | |
183 | else() | |
184 | set(ROOT_HASALIEN FALSE) | |
185 | endif() | |
186 | endif(ROOT_HASALIEN) | |
187 | ||
188 | # Checking for xml support | |
189 | execute_process(COMMAND ${ROOT_CONFIG} --has-xml OUTPUT_VARIABLE ROOT_HASXML ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE ) | |
190 | if(error) | |
191 | message(FATAL_ERROR "Error checking if ROOT was built with xml support: ${error}") | |
192 | endif(error) | |
193 | ||
194 | # if defined | |
195 | if(ROOT_HASXML) | |
196 | string(STRIP "${ROOT_HASXML}" ROOT_HASXML) | |
197 | if(ROOT_HASXML STREQUAL "yes") | |
198 | add_definitions(-DWITHXML) | |
199 | set(ROOT_HASXML TRUE) | |
200 | else() | |
201 | set(ROOT_HASXML FALSE) | |
202 | endif() | |
203 | endif(ROOT_HASXML) | |
204 | ||
205 | # Checking for OpenGL support | |
206 | execute_process(COMMAND ${ROOT_CONFIG} --has-opengl OUTPUT_VARIABLE ROOT_HASOPENGL ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE ) | |
207 | if(error) | |
208 | message(FATAL_ERROR "Error checking if ROOT was built with OpenGL support: ${error}") | |
209 | endif(error) | |
210 | ||
211 | if(ROOT_HASOPENGL) | |
212 | string(STRIP "${ROOT_HASOPENGL}" ROOT_HASOPENGL) | |
213 | if(ROOT_HASOPENGL STREQUAL "yes") | |
214 | set(ROOT_HASOPENGL TRUE) | |
215 | else() | |
216 | set(ROOT_HASOPENGL FALSE) | |
217 | endif() | |
218 | endif() | |
219 | ||
220 | ||
221 | # Checking for fortran compiler | |
222 | execute_process(COMMAND ${ROOT_CONFIG} --f77 OUTPUT_VARIABLE ROOT_FORTRAN ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE ) | |
223 | if(error) | |
224 | message(FATAL_ERROR "Error checking ROOT fortran compiler: ${error}") | |
225 | endif(error) | |
226 | string(STRIP "${ROOT_FORTRAN}" ROOT_FORTRAN) | |
227 | ||
228 | # adding the libraries and the inc dir | |
229 | link_directories(${ROOT_LIBDIR}) | |
230 | include_directories(SYSTEM ${ROOT_INCLUDE_DIR}) | |
231 | set(ROOT_FOUND TRUE) | |
232 | ||
233 | # Workaround misssing XML, VMC, Minuit from ROOT static library | |
234 | # Also adding libzma.a libfreetype.a libpcre.a | |
235 | # To be removed where https://sft.its.cern.ch/jira/browse/ROOT-6904 issue is fixed | |
236 | if(ALIROOT_STATIC) | |
237 | message(WARNING "AliRoot static build enabled! libRootExtra.a will be created.\nPlease remove when ROOT https://sft.its.cern.ch/jira/browse/ROOT-6904 issue is fixed") | |
238 | ||
239 | # ROOT needs xml2 but it is not built with the static version so we have to add it | |
240 | find_package(LibXml2) | |
241 | ||
242 | if(LIBXML2_FOUND) | |
243 | ||
244 | # adding SSL | |
245 | find_package(OpenSSL) | |
246 | ||
247 | if(OPENSSL_FOUND) | |
248 | file(GLOB _extraroot "${ROOTSYS}/montercarlo/vmc/src/*.o" "${ROOTSYS}/tree/treeplayer/src/*.o" "${ROOTSYS}/io/xmlparser/src/*.o" "${ROOTSYS}/math/minuit2/src/*.o") | |
249 | add_library(RootExtra STATIC ${_extraroot}) | |
250 | set_target_properties(RootExtra PROPERTIES COMPILE_FLAGS "${LIBXML2_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR}") | |
251 | set_target_properties(RootExtra PROPERTIES LINKER_LANGUAGE CXX) | |
252 | target_link_libraries(RootExtra ${ROOT_LIBDIR}/libfreetype.a ${ROOT_LIBDIR}/libpcre.a ${ROOT_LIBDIR}/liblzma.a ${LIBXML2_LIBRARIES} ${OPENSSL_LIBRARIES}) | |
253 | else() | |
254 | message(FATAL_ERROR "OpenSSL not found. Coould not generate the static RootExtra. Please install Openssl") | |
255 | endif() | |
256 | else() | |
257 | message(FATAL_ERROR "libxml2 not found. Can not generate the static RootExtra. Please install libxml2") | |
258 | endif() | |
259 | endif(ALIROOT_STATIC) | |
260 | else() | |
261 | message(FATAL_ERROR "ROOT installation not found! Please point to the ROOT installation using -DROOTSYS=ROOT_INSTALL_DIR.") | |
262 | endif(ROOTSYS) |