forked from root-project/roottest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
167 lines (148 loc) · 6.94 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
project(roottest)
# Use ${ROOTSYS} environment variable to search for ROOT.
# This may be set by sourcing thisroot.sh from an installation.
if(DEFINED ENV{ROOTSYS})
list(INSERT CMAKE_PREFIX_PATH 0 $ENV{ROOTSYS})
endif()
# Use ${ROOTSYS} CMake variable to search for ROOT. This is set when roottest is
# built as part of ROOT, i.e., when ROOT is configured with -Droottest=ON. It
# may also be set by passing -DROOTSYS=<PATH> to CMake when configuring a
# standalone roottest against an installation of ROOT. If this is set, it takes
# precedence over the environment to ensure that when roottest is being built in
# a ROOT build configured with -Droottest=ON, it will find the ROOT being built,
# and not a ROOT installation sourced with thisroot.sh or found in $PATH.
if(DEFINED ROOTSYS)
list(INSERT CMAKE_PREFIX_PATH 0 ${ROOTSYS})
endif()
find_package(ROOT REQUIRED CONFIG)
# If ROOT_SOURCE_DIR is set, roottest is built as part of the root build.
# If ROOT_SOURCE_DIR is not set, search for an installation.
if(DEFINED ROOT_SOURCE_DIR)
# root-config --prefix helps to retrieve ROOTSYS env variable.
# ROOT_BINDIR is set by ROOTConfig.cmake
find_program(ROOT_CONFIG_EXECUTABLE root-config PATHS ${ROOT_BINDIR})
if(NOT ROOT_CONFIG_EXECUTABLE)
message(ERROR "root-config is not found, please rerun configuration step.")
endif()
exec_program(${ROOT_CONFIG_EXECUTABLE} ARGS "--prefix" OUTPUT_VARIABLE ROOTSYS RETURN_VALUE RETVAR)
set(ROOTSYS ${ROOTSYS} CACHE INTERNAL "")
set(ROOT_LIBRARIES Core RIO Net Hist Gpad Tree Rint Matrix MathCore)
set(ROOT_root_CMD ${ROOTSYS}/bin/root.exe)
set(ROOT_hadd_CMD ${ROOTSYS}/bin/hadd)
set(ROOT_genreflex_CMD ${ROOTSYS}/bin/genreflex)
set(ROOT_rootcint_CMD ${ROOTSYS}/bin/rootcint)
set(ROOT_rootcling_CMD rootcling)
else() # standalone roottest.git
include(${ROOT_USE_FILE})
# root-config --prefix helps to retrieve ROOTSYS env variable.
find_program(ROOT_CONFIG_EXECUTABLE root-config)
exec_program(${ROOT_CONFIG_EXECUTABLE} ARGS "--prefix" OUTPUT_VARIABLE ROOTSYS RETURN_VALUE RETVAR)
set(ROOTSYS ${ROOTSYS} CACHE INTERNAL "")
# Some roottest.git tests are checking LZ4 and ZSTD, which has different references depends on its version.
# We recover LZ4/ZSTD version used in ROOT, stored in root-config --config output.
exec_program(${ROOT_CONFIG_EXECUTABLE} ARGS "--srcdir" OUTPUT_VARIABLE ROOT_SOURCE_DIR)
exec_program(${ROOT_CONFIG_EXECUTABLE} ARGS "--config" OUTPUT_VARIABLE ROOT_CONFIG_VARIABLES RETURN_VALUE RETVAR)
separate_arguments(ROOT_CONFIG_VARIABLES)
foreach(item ${ROOT_CONFIG_VARIABLES})
if("${item}" MATCHES "LZ4_VERSION=(.*)")
string(REGEX REPLACE "LZ4_VERSION=(.*)" "\\1" LZ4 ${item})
set(LZ4_VERSION ${LZ4} CACHE INTERNAL "")
elseif("${item}" MATCHES "ZSTD_VERSION=(.*)")
string(REGEX REPLACE "ZSTD_VERSION=(.*)" "\\1" ZSTD ${item})
set(ZSTD_VERSION ${ZSTD} CACHE INTERNAL "")
endif()
endforeach()
# If we didn't manage to find LZ4_VERSION/ZSTD_VERSION in "root-config --config" output,
# we consider that ROOT had used system LZ4/ZSTD and we can find it via find_package().
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/modules ${ROOTSYS}/cmake/modules ${ROOT_SOURCE_DIR}/cmake/modules)
if(NOT LZ4_VERSION)
find_package(LZ4)
if(NOT LZ4_FOUND)
message(FATAL_ERROR "lz4 is required to be installed before running roottest.git")
endif()
endif()
if(NOT ZSTD_VERSION)
find_package(ZSTD)
if(NOT ZSTD_FOUND)
message(FATAL_ERROR "zstd is required to be installed before running roottest.git")
endif()
endif()
# To be able to use the same C++ standard as used in ROOT, we can try to retrieve it from root-config --features
exec_program(root-config ARGS "--features" OUTPUT_VARIABLE ROOT_FEATURES RETURN_VALUE RETVAR)
separate_arguments(ROOT_FEATURES)
foreach(item ${ROOT_FEATURES})
if("${item}" MATCHES "^cxx(.*)")
string(REGEX REPLACE "^cxx(.*)" "\\1" CXX_VERSION ${item})
set(CMAKE_CXX_STANDARD ${CXX_VERSION} CACHE INTERNAL "")
endif()
endforeach()
find_program(ROOT_root_CMD root.exe PATHS ${ROOTSYS}/bin)
find_program(ROOT_hadd_CMD hadd PATHS ${ROOTSYS}/bin)
find_program(ROOT_genreflex_CMD genreflex PATHS ${ROOTSYS}/bin)
find_program(ROOT_rootcint_CMD rootcint PATHS ${ROOTSYS}/bin)
find_program(ROOT_rootcling_CMD rootcling PATHS ${ROOTSYS}/bin)
enable_testing()
endif()
# Synchronizing default compression algorithm used for ROOT.
# We need to have it for CMake settings for switching tests references.
# FIXME: it should be exported from ROOT build.
set(compression_default "zlib" CACHE STRING "" FORCE)
get_filename_component(ROOT_LIBRARY_DIR "${ROOTSYS}/lib" ABSOLUTE)
# Detect bitness.
if(CMAKE_SYSTEM_PROCESSOR MATCHES amd64.*|x86_64.*|aarch64.*|ppc64.*
OR (CMAKE_VERSION VERSION_LESS 3.0 AND CMAKE_SYSTEM_NAME STREQUAL Darwin) )
set(64BIT 1)
message("-- Check for bitness: Found 64 bit architecture.")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES i686.*|i386.*|x86.*)
set(32BIT 1)
message("-- Check for bitness: Found 32 bit architecture.")
endif()
# Setup environment.
set(ROOTTEST_ENV_PATH ${ROOT_BINDIR})
set(ROOTTEST_ENV_PYTHONPATH ${ROOT_LIBRARY_DIR})
set(ROOTTEST_ENV_LIBRARYPATH ${ROOT_LIBRARY_DIR})
set(ROOTTEST_ENV_EXTRA)
set(ROOTTEST_ENVIRONMENT
ROOTSYS=${ROOTSYS}
PATH=${ROOTTEST_ENV_PATH}:$ENV{PATH}
PYTHONPATH=${ROOTTEST_ENV_PYTHONPATH}:$ENV{PYTHONPATH}
${ld_library_path}=${ROOTTEST_ENV_LIBRARYPATH}:$ENV{${ld_library_path}})
if (gnuinstall)
set(ROOTTEST_ENVIRONMENT ${ROOTTEST_ENVIRONMENT} ROOTIGNOREPREFIX=1)
endif()
# Resolve symbolic links for the ROOTTEST_DIR variable.
get_filename_component(ROOTTEST_DIR ${CMAKE_CURRENT_SOURCE_DIR} ABSOLUTE)
# Set some variables that customizes the behaviour of the ROOT macros
set(CMAKE_ROOTTEST_DICT ON)
# Set the CMake module path. Here are all the custom CMake modules.
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${ROOTTEST_DIR}/cmake/modules")
# Find python.
if(ROOT_pyroot_FOUND)
if (NOT PYTHON_EXECUTABLE)
find_package(PythonInterp)
if(PYTHONINTERP_FOUND)
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sys;sys.stdout.write(sys.prefix)"
OUTPUT_VARIABLE PYTHON_PREFIX)
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${PYTHON_PREFIX})
endif()
if (NOT PYTHON_LIBRARIES)
find_package(PythonLibs)
endif()
endif()
endif()
#---Set flag for PyROOT tests that are expected to fail in experimental
if(ROOT_pyroot_experimental_FOUND)
set(PYTESTS_WILLFAIL WILLFAIL)
endif()
# Find OpenGL
find_library(OPENGL_gl_LIBRARY NAMES GL)
# Setup standard includes / links.
include_directories(${ROOT_INCLUDE_DIRS} ${ROOT_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
link_directories(${ROOT_LIBRARY_DIR})
set(CMAKE_MACOSX_RPATH TRUE) # use RPATH for MacOSX
include(RoottestCTest)
include(RoottestMacros)
include(SearchInstalledSoftwareRoottest)
message("-- Scanning subdirectories for tests...")
ROOTTEST_ADD_TESTDIRS()