]>
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 |
fffaf6a5 | 30 | # - ROOT_INCLUDE_DIRS - 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 | ||
41 | # Setting the LD_LiBRARY_PATH to point to ROOT lib folder | |
42 | set(ROOT_LIBDIR ${ROOTSYS}/lib) | |
43 | set(ROOT_INCLUDE_DIRS ${ROOTSYS}/include) | |
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) |
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) | |
a0f34e87 | 73 | string(STRIP ${ROOT_VERSION} ROOT_VERSION) |
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) | |
a0f34e87 | 88 | string(STRIP ${ROOT_FEATURES} ROOT_FEATURES) |
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) | |
a0f34e87 | 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) | |
a0f34e87 | 102 | string(STRIP ${ROOT_LIBS} ROOT_LIBS) |
103 | ||
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() | |
109 | string(STRIP ${ROOT_LIBRARIES} ROOT_LIBRARIES) | |
110 | separate_arguments(ROOT_LIBRARIES) | |
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) | |
a0f34e87 | 117 | string(STRIP ${ROOT_INCDIR} ROOT_INCDIR) |
118 | ||
fffaf6a5 | 119 | # Checking for glibs |
a0f34e87 | 120 | execute_process(COMMAND ${ROOT_CONFIG} --noldflags --glibs OUTPUT_VARIABLE ROOT_GLIBS ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE ) |
fffaf6a5 | 121 | if(error) |
122 | message(FATAL_ERROR "Error retrieving ROOT glibs: ${error}") | |
123 | endif(error) | |
124 | ||
125 | # Checking for glibs | |
a0f34e87 | 126 | string(STRIP ${ROOT_GLIBS} ROOT_GLIBS) |
127 | ||
128 | foreach(lib ${ROOT_GLIBS}) | |
129 | string(REPLACE "-rdynamic" "" new_lib "${lib}") | |
130 | string(REPLACE "-l" "" lib "${new_lib}") | |
131 | set(ROOT_GLIBRARIES ${ROOT_GLIBRARIES} ${lib}) | |
132 | endforeach() | |
133 | string(STRIP ${ROOT_GLIBRARIES} ROOT_GLIBRARIES) | |
134 | separate_arguments(ROOT_GLIBRARIES) | |
135 | ||
136 | # Checking for AliEn support | |
fffaf6a5 | 137 | execute_process(COMMAND ${ROOT_CONFIG} --has-alien OUTPUT_VARIABLE ROOT_HASALIEN ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE ) |
138 | if(error) | |
139 | message(FATAL_ERROR "Error checking if ROOT was build with AliEn support: ${error}") | |
140 | endif(error) | |
a0f34e87 | 141 | string(STRIP ${ROOT_HASALIEN} ROOT_HASALIEN) |
142 | ||
143 | # Checking for xml support | |
fffaf6a5 | 144 | execute_process(COMMAND ${ROOT_CONFIG} --has-xml OUTPUT_VARIABLE ROOT_HASXML ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE ) |
145 | if(error) | |
146 | message(FATAL_ERROR "Error checking if ROOT was build with xml support: ${error}") | |
147 | endif(error) | |
a0f34e87 | 148 | string(STRIP ${ROOT_HASXML} ROOT_HASXML) |
1dbe1076 | 149 | |
aac9c09b | 150 | # Checking for OpenGL support |
151 | execute_process(COMMAND ${ROOT_CONFIG} --has-opengl OUTPUT_VARIABLE ROOT_HASOPENGL ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE ) | |
152 | if(error) | |
153 | message(FATAL_ERROR "Error checking if ROOT was build with OpenGL support: ${error}") | |
154 | endif(error) | |
155 | string(STRIP ${ROOT_HASOPENGL} ROOT_HASOPENGL) | |
1dbe1076 | 156 | |
aac9c09b | 157 | # Checking for fortran compiler |
1dbe1076 | 158 | execute_process(COMMAND ${ROOT_CONFIG} --f77 OUTPUT_VARIABLE ROOT_FORTRAN ERROR_VARIABLE error OUTPUT_STRIP_TRAILING_WHITESPACE ) |
159 | if(error) | |
160 | message(FATAL_ERROR "Error checking ROOT fortran compiler: ${error}") | |
161 | endif(error) | |
162 | string(STRIP ${ROOT_FORTRAN} ROOT_FORTRAN) | |
a0f34e87 | 163 | |
fffaf6a5 | 164 | set(ROOT_FOUND TRUE) |
6db31708 | 165 | else() |
fffaf6a5 | 166 | message(FATAL_ERROR "ROOT installation not found! Please point to the ROOT installation using -DROOTSYS=ROOT_INSTALL_DIR.") |
167 | endif(ROOTSYS) |