forked from lbaehren/CMakeModules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindROOT.cmake
176 lines (157 loc) · 6.49 KB
/
FindROOT.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#-------------------------------------------------------------------------------
# Copyright (c) 2013-2013, Lars Baehren <[email protected]>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#-------------------------------------------------------------------------------
# - Check for the presence of ROOT
#
# The following variables are set when ROOT is found:
# ROOT_FOUND = Set to true, if all components of ROOT have been found.
# ROOT_INCLUDES = Include path for the header files of ROOT
# ROOT_LIBRARIES = Link these to use ROOT
# ROOT_LFLAGS = Linker flags (optional)
if (NOT ROOT_FOUND)
if (NOT ROOT_ROOT_DIR)
set (ROOT_ROOT_DIR ${CMAKE_INSTALL_PREFIX})
endif (NOT ROOT_ROOT_DIR)
##__________________________________________________________________________
## Check for configuration tool; if it is found, wean use it to gather most
## of the information.
find_program (ROOT_CONFIG_EXECUTABLE root-config
HINTS ${ROOT_ROOT_DIR} ${CMAKE_INSTALL_PREFIX}
ENV ROOTSYS
PATH_SUFFIXES bin
)
if (ROOT_CONFIG_EXECUTABLE)
## Root directory of installation
execute_process (COMMAND ${ROOT_CONFIG_EXECUTABLE} --prefix
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
OUTPUT_VARIABLE ROOT_ROOT_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
## Release version
execute_process (COMMAND ${ROOT_CONFIG_EXECUTABLE} --version
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
OUTPUT_VARIABLE ROOT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
## Available features
execute_process (COMMAND ${ROOT_CONFIG_EXECUTABLE} --features
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
OUTPUT_VARIABLE ROOT_FEATURES
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif (ROOT_CONFIG_EXECUTABLE)
##__________________________________________________________________________
## Check for the header files
if (ROOT_CONFIG_EXECUTABLE)
execute_process (COMMAND ${ROOT_CONFIG_EXECUTABLE} --incdir
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
RESULT_VARIABLE ROOT_CONFIG_INCDIR_RESULT
OUTPUT_VARIABLE ROOT_INCLUDES
OUTPUT_STRIP_TRAILING_WHITESPACE
)
else (ROOT_CONFIG_EXECUTABLE)
find_path (ROOT_INCLUDES
NAMES TGlobal.h TGrid.h TObject.h
HINTS ${ROOT_ROOT_DIR} ${CMAKE_INSTALL_PREFIX}
ENV ROOTSYS
PATH_SUFFIXES include include/root root/include
)
endif (ROOT_CONFIG_EXECUTABLE)
##__________________________________________________________________________
## Check for the library
if (ROOT_CONFIG_EXECUTABLE)
execute_process (COMMAND ${ROOT_CONFIG_EXECUTABLE} --glibs
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
OUTPUT_VARIABLE _rootLibs
OUTPUT_STRIP_TRAILING_WHITESPACE
)
## Convert output to list
string (REGEX REPLACE " -l" ";" _rootLibs ${_rootLibs})
## ... and remove the first entry
list (REMOVE_AT _rootLibs 0)
else (ROOT_CONFIG_EXECUTABLE)
set (_rootLibs
Gui
Core
Cint
RIO
Net
Hist
Graf
Graf3d
Gpad
Tree
Rint
Postscript
Matrix
Physics
MathCore
Thread)
endif (ROOT_CONFIG_EXECUTABLE)
foreach (_lib ${_rootLibs})
message (STATUS "Searching for ${_lib} ...")
## Convert to upper-case
string (TOUPPER ${_lib} _libUpper)
## Search for library
find_library (ROOT_${_libUpper}_LIBRARY ${_libUpper}
HINTS ${ROOT_ROOT_DIR} ${CMAKE_INSTALL_PREFIX}
PATH_SUFFIXES lib lib/root root/lib
)
## Add individual library to overall list
if (ROOT_${_libUpper}_LIBRARY)
list (APPEND ROOT_LIBRARIES ${ROOT_${_libUpper}_LIBRARY})
endif (ROOT_${_libUpper}_LIBRARY)
endforeach (_lib)
##__________________________________________________________________________
## Check for the executables
find_program (ROOT_EXECUTABLE root
HINTS ${ROOT_ROOT_DIR} ${CMAKE_INSTALL_PREFIX}
PATH_SUFFIXES bin
)
##__________________________________________________________________________
## Actions taken when all components have been found
find_package_handle_standard_args (ROOT DEFAULT_MSG ROOT_LIBRARIES ROOT_INCLUDES)
if (ROOT_FOUND)
if (NOT ROOT_FIND_QUIETLY)
message (STATUS "Found components for ROOT")
message (STATUS "ROOT_VERSION = ${ROOT_VERSION}")
message (STATUS "ROOT_ROOT_DIR = ${ROOT_ROOT_DIR}")
message (STATUS "ROOT_INCLUDES = ${ROOT_INCLUDES}")
message (STATUS "ROOT_LIBRARIES = ${ROOT_LIBRARIES}")
message (STATUS "ROOT_FEATURES = ${ROOT_FEATURES}")
endif (NOT ROOT_FIND_QUIETLY)
else (ROOT_FOUND)
if (ROOT_FIND_REQUIRED)
message (FATAL_ERROR "Could not find ROOT!")
endif (ROOT_FIND_REQUIRED)
endif (ROOT_FOUND)
##__________________________________________________________________________
## Mark advanced variables
mark_as_advanced (
ROOT_ROOT_DIR
ROOT_INCLUDES
ROOT_LIBRARIES
ROOT_FEATURES
)
endif (NOT ROOT_FOUND)