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