forked from BristolTopGroup/AnalysisSoftware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindROOT.cmake
147 lines (114 loc) · 5.21 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
# -*- mode: cmake -*-
# - Finds ROOT instalation
# Based on http://alimv.googlecode.com/svn-history/r2/trunk/cmake/modules/FindROOT.cmake
# This module sets up ROOT information
# We suppose root-config to be in the PATH. Otherwise we stop.
Find_program(ROOT_CONFIG root-config)
If (${ROOT_CONFIG} MATCHES "ROOT_CONFIG-NOTFOUND")
Set(ROOT_FOUND FALSE)
Message(STATUS "Install Root and make sure it is in the PATH")
Else (${ROOT_CONFIG} MATCHES "ROOT_CONFIG-NOTFOUND")
Set(ROOT_FOUND TRUE)
Execute_process(
COMMAND root-config --prefix
OUTPUT_VARIABLE ROOTSYS
OUTPUT_STRIP_TRAILING_WHITESPACE)
Execute_process(
COMMAND root-config --cc
OUTPUT_VARIABLE _cc
OUTPUT_STRIP_TRAILING_WHITESPACE)
If(APPLE)
Execute_process(
COMMAND which ${_cc}
OUTPUT_VARIABLE _ccpath
OUTPUT_STRIP_TRAILING_WHITESPACE)
Set(ENV{CC} ${_ccpath})
Else(APPLE)
Set(ENV{CC} ${_cc})
Endif(APPLE)
Execute_process(
COMMAND root-config --cxx
OUTPUT_VARIABLE _cxx
OUTPUT_STRIP_TRAILING_WHITESPACE)
If(APPLE)
Execute_process(
COMMAND which ${_cxx}
OUTPUT_VARIABLE _cxxpath
OUTPUT_STRIP_TRAILING_WHITESPACE)
Set(ENV{CXX} ${_cxxpath})
Else(APPLE)
Set(ENV{CXX} ${_cxx})
Endif(APPLE)
Execute_process(
COMMAND root-config --version
OUTPUT_VARIABLE ROOT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
Execute_process(
COMMAND root-config --incdir
OUTPUT_VARIABLE ROOT_INCLUDE_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
Execute_process(
COMMAND root-config --libs --glibs --cflags --ldflags --auxlibs --auxcflags
OUTPUT_VARIABLE ROOT_LIBRARIES
OUTPUT_STRIP_TRAILING_WHITESPACE)
Find_program(ROOTCINT rootcint)
If(NOT ROOTCINT)
Message(FATAL_ERROR "Found ROOT but not rootcint, your ROOT installation is corrupted")
EndIf(NOT ROOTCINT)
# Set(ROOT_LIBRARIES ${ROOT_LIBRARIES} -lThread -lMinuit -lHtml -lVMC -lEG -lGeom -lTreePlayer -lXMLIO -lProof)
# Set(ROOT_LIBRARIES ${ROOT_LIBRARIES} -lProofPlayer -lMLP -lSpectrum -lEve -lRGL -lGed -lXMLParser -lPhysics)
Set(ROOT_LIBRARY_DIR ${ROOTSYS}/lib)
# Make variables changeble to the advanced user
Mark_as_advanced(ROOT_LIBRARY_DIR ROOT_INCLUDE_DIR ROOT_DEFINITIONS)
Set(LD_LIBRARY_PATH ${LD_LIBRARY_PATH} ${ROOT_LIBRARY_DIR})
Message(STATUS "Found Root ${ROOT_VERSION} in ${ROOTSYS}/bin/root")
# we need at least version 5.00/00
If (NOT ROOT_MIN_VERSION)
Set(ROOT_MIN_VERSION "5.00/00")
Endif (NOT ROOT_MIN_VERSION)
# now parse the parts of the user given version string into variables
String(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+" "\\1" req_root_major_vers "${ROOT_MIN_VERSION}")
String(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+\\/[0-9][0-9]+.*" "\\1" req_root_minor_vers "${ROOT_MIN_VERSION}")
String(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+\\/([0-9][0-9]+)" "\\1" req_root_patch_vers "${ROOT_MIN_VERSION}")
# and now the version string given by qmake
String(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+.*" "\\1" found_root_major_vers "${ROOT_VERSION}")
String(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+\\/[0-9][0-9]+.*" "\\1" found_root_minor_vers "${ROOT_VERSION}")
String(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+\\/([0-9][0-9]+).*" "\\1" found_root_patch_vers "${ROOT_VERSION}")
If (found_root_major_vers LESS 5)
Message(FATAL_ERROR "Invalid ROOT version \"${ROOT_VERSION}\", at least major version 4 is required, e.g. \"5.00/00\"")
Endif(found_root_major_vers LESS 5)
# compute an overall version number which can be compared at once
Math(EXPR req_vers "${req_root_major_vers}*10000 + ${req_root_minor_vers}*100 + ${req_root_patch_vers}")
Math(EXPR found_vers "${found_root_major_vers}*10000 + ${found_root_minor_vers}*100 + ${found_root_patch_vers}")
If (found_vers LESS req_vers)
Set(ROOT_FOUND FALSE)
Set(ROOT_INSTALLED_VERSION_TOO_OLD TRUE)
Else (found_vers LESS req_vers)
Set(ROOT_FOUND TRUE)
Endif (found_vers LESS req_vers)
Endif (${ROOT_CONFIG} MATCHES "ROOT_CONFIG-NOTFOUND")
#####################################################################################
Macro(ROOT_GENERATE_DICTIONARY INFILES LINKDEF_FILE OUTFILE INCLUDE_DIRS_IN)
Set(_special_settings "${ARGV4}")
Set(INCLUDE_DIRS)
Set(infiles_nopath)
Foreach (_current_FILE ${INCLUDE_DIRS_IN})
Set(INCLUDE_DIRS ${INCLUDE_DIRS} -I${_current_FILE})
Endforeach (_current_FILE ${INCLUDE_DIRS_IN})
String(REGEX REPLACE "^(.*)\\.(.*)$" "\\1.h" bla "${OUTFILE}")
Set(OUTFILES ${OUTFILE} ${bla})
Foreach (_current_FILE ${INFILES})
Get_filename_component(name_wo_path ${_current_FILE} NAME)
Set(infiles_nopath ${infiles_nopath} ${name_wo_path})
Endforeach (_current_FILE ${INFILES})
Get_property(_defs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY COMPILE_DEFINITIONS)
Set(_ddefs)
Foreach (_def ${_defs})
Set(_ddefs "${_ddefs} -D${_def}")
Endforeach (_def ${_defs})
Separate_arguments(_ddefs)
Add_custom_command(OUTPUT ${OUTFILES}
COMMAND DYLD_LIBRARY_PATH=$ENV{DYLD_LIBRARY_PATH}:${ROOT_LIBRARY_DIR} ${ROOTCINT}
ARGS -f ${OUTFILE} -c -DHAVE_CONFIG_H ${_ddefs} ${_special_settings} ${INCLUDE_DIRS} ${infiles_nopath} ${LINKDEF_FILE}
DEPENDS ${INFILES} ${LINKDEF_FILE})
Endmacro(ROOT_GENERATE_DICTIONARY)