Skip to content

Commit 994c94c

Browse files
committed
[CMake] Don't use find_package(ROOT REQUIRED) in test/ subdirectory
As Sergey said in the comment in `test/CMakeLists.txt`, this test project stopped working standalone. But, it still uses `find_package(ROOT)` to find ROOT, even though it's not installed yet as we are building ROOT itself at the same time. Apparently that works, and sets the flags like `ROOT_opengl_FOUND`, but we should not rely on this and use the build-time configuration flags instead.
1 parent 36a4e01 commit 994c94c

File tree

2 files changed

+31
-61
lines changed

2 files changed

+31
-61
lines changed

test/CMakeLists.txt

Lines changed: 30 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,11 @@
33
#
44
# For the licensing terms see $ROOTSYS/LICENSE.
55
# For the list of contributors see $ROOTSYS/README/CREDITS.
6-
7-
# CMakeLists.txt for the ROOT test programs.
8-
# This shows nicely how to compile and link applications
9-
# using the ROOT libraries on all supported platforms.
106
#
117
# Author: Pere Mato, 25/10/2010
12-
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
13-
14-
project(test)
15-
16-
# Sergey: make no sense while CMakeLists.txt file cannot be used separately from ROOT
17-
# but variables like ROOT_asimage_FOUND used here and produced in ROOTConfig.cmake
18-
find_package(ROOT REQUIRED)
19-
20-
#---Copy the CTestCustom.cmake file into the build directory---------------------------------
21-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
22-
enable_testing()
238

24-
if(CMAKE_SYSTEM_NAME MATCHES Darwin)
25-
# To avoid to set ld_Library_path to locate the test libraries
26-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,@loader_path/.")
27-
endif()
28-
29-
if(DEFINED ROOT_SOURCE_DIR)
30-
# Testing using the binary tree
31-
set(ROOT_root_CMD ${ROOT_BINDIR}/root.exe)
32-
include_directories(${ROOT_SOURCE_DIR}/tutorials)
33-
else()
34-
# Testing using an installation (assuming access to ROOT CMake modules)
35-
include_directories(${ROOT_INCLUDE_DIRS})
36-
include_directories(${ROOT_INCLUDE_DIRS}/../tutorials)
37-
add_definitions(${ROOT_DEFINITIONS})
38-
include(RootMacros)
39-
endif()
9+
# Testing using the binary tree
10+
set(root_exe $<TARGET_FILE:root.exe>)
4011

4112
#---environment-------------------------------------------------------------------------------
4213
ROOT_ADD_TEST(show-environment COMMAND ${CMAKE_COMMAND} -E environment)
@@ -79,12 +50,12 @@ endif()
7950
#---invalid pointer checks---------------------------------------------------------------------
8051
if((NOT (APPLE AND CMAKE_SYSTEM_PROCESSOR MATCHES arm64) OR M1_BROKEN_TESTS) AND NOT experimental_adaptivecpp)
8152
ROOT_ADD_TEST(test-check-nullptr
82-
COMMAND ${ROOT_root_CMD} -b -q -l --ptrcheck -e "int*ptr=(int*)0" -e "*ptr"
53+
COMMAND ${root_exe} -b -q -l --ptrcheck -e "int*ptr=(int*)0" -e "*ptr"
8354
PASSREGEX "dereference null pointer")
8455

8556
if(NOT MSVC OR win_broken_tests)
8657
ROOT_ADD_TEST(test-check-invalidptr
87-
COMMAND ${ROOT_root_CMD} -b -q -l --ptrcheck -e "int*ptr=(int*)1" -e "*ptr"
58+
COMMAND ${root_exe} -b -q -l --ptrcheck -e "int*ptr=(int*)1" -e "*ptr"
8859
PASSREGEX "invalid memory address")
8960
endif()
9061
endif()
@@ -95,7 +66,6 @@ ROOT_ADD_TEST(test-minexam COMMAND minexam)
9566

9667
#--tstring-------------------------------------------------------------------------------------
9768
ROOT_EXECUTABLE(tstring tstring.cxx LIBRARIES Core)
98-
configure_file(tstring.cxx tstring.cxx COPYONLY)
9969
ROOT_ADD_TEST(test-tstring COMMAND tstring)
10070

10171
#--tcollex-------------------------------------------------------------------------------------
@@ -129,7 +99,7 @@ ROOT_LINKER_LIBRARY(Aclock Aclock.cxx G__Aclock.cxx LIBRARIES Graf Gpad)
12999
#--bench------------------------------------------------------------------------------------
130100
ROOT_GENERATE_DICTIONARY(G__TBench ${CMAKE_CURRENT_SOURCE_DIR}/TBench.h MODULE TBench LINKDEF benchLinkDef.h DEPENDENCIES MathCore Tree)
131101
ROOT_LINKER_LIBRARY(TBench TBench.cxx G__TBench.cxx LIBRARIES Core MathCore RIO Tree)
132-
ROOT_EXECUTABLE(bench bench.cxx LIBRARIES Core TBench)
102+
ROOT_EXECUTABLE(bench bench.cxx LIBRARIES Core TBench RIO)
133103
ROOT_ADD_TEST(test-bench COMMAND bench -s LABELS longtest)
134104

135105
#--stress------------------------------------------------------------------------------------
@@ -141,14 +111,14 @@ if(geom)
141111
#--stressShapes------------------------------------------------------------------------------------
142112
ROOT_EXECUTABLE(stressShapes stressShapes.cxx LIBRARIES Geom Tree GenVector Gpad)
143113
ROOT_ADD_TEST(test-stressshapes COMMAND stressShapes -b FAILREGEX "FAILED|Error in")
144-
ROOT_ADD_TEST(test-stressshapes-interpreted COMMAND ${ROOT_root_CMD} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressShapes.cxx
114+
ROOT_ADD_TEST(test-stressshapes-interpreted COMMAND ${root_exe} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressShapes.cxx
145115
FAILREGEX "FAILED|Error in")
146116

147117
#--stressGeometry------------------------------------------------------------------------------------
148118
if (NOT MSVC) # Prevents the access to the web, which could happen through https
149119
ROOT_EXECUTABLE(stressGeometry stressGeometry.cxx LIBRARIES Geom Tree GenVector Gpad)
150120
ROOT_ADD_TEST(test-stressgeometry COMMAND stressGeometry -b FAILREGEX "FAILED|Error in" LABELS longtest)
151-
ROOT_ADD_TEST(test-stressgeometry-interpreted COMMAND ${ROOT_root_CMD} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressGeometry.cxx
121+
ROOT_ADD_TEST(test-stressgeometry-interpreted COMMAND ${root_exe} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressGeometry.cxx
152122
FAILREGEX "FAILED|Error in" DEPENDS test-stressgeometry LABELS longtest)
153123
endif()
154124
endif()
@@ -157,11 +127,11 @@ endif()
157127
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/linearIO.root ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
158128
ROOT_EXECUTABLE(stressLinear stressLinear.cxx LIBRARIES Matrix Hist RIO)
159129
ROOT_ADD_TEST(test-stresslinear COMMAND stressLinear FAILREGEX "FAILED|Error in" LABELS longtest)
160-
ROOT_ADD_TEST(test-stresslinear-interpreted COMMAND ${ROOT_root_CMD} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressLinear.cxx
130+
ROOT_ADD_TEST(test-stresslinear-interpreted COMMAND ${root_exe} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressLinear.cxx
161131
FAILREGEX "FAILED|Error in" LABELS longtest)
162132

163133
#--stressGraphics------------------------------------------------------------------------------------
164-
if(ROOT_opengl_FOUND AND TARGET TreeViewer)
134+
if(opengl AND TARGET TreeViewer)
165135
ROOT_EXECUTABLE(stressGraphics stressGraphics.cxx LIBRARIES Graf Gpad Postscript TreeViewer HistPainter)
166136
if(MSVC)
167137
set_property(TARGET stressGraphics APPEND_STRING PROPERTY LINK_FLAGS "/STACK:4000000")
@@ -180,7 +150,7 @@ if(ROOT_opengl_FOUND AND TARGET TreeViewer)
180150
FAILREGEX "FAILED|Error in"
181151
LABELS longtest)
182152
ROOT_ADD_TEST(test-stressgraphics-interpreted
183-
COMMAND ${ROOT_root_CMD} -b --web=off -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressGraphics.cxx
153+
COMMAND ${root_exe} -b --web=off -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressGraphics.cxx
184154
FAILREGEX "FAILED|Error in"
185155
DEPENDS test-stressgraphics)
186156
ROOT_ADD_TEST(test-stressgraphics-svg
@@ -210,33 +180,33 @@ endif()
210180
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/stressHistogram.5.18.00.root ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
211181
ROOT_EXECUTABLE(stressHistogram stressHistogram.cxx LIBRARIES Hist RIO)
212182
ROOT_ADD_TEST(test-stresshistogram COMMAND stressHistogram FAILREGEX "FAILED|Error in" LABELS longtest)
213-
ROOT_ADD_TEST(test-stresshistogram-interpreted COMMAND ${ROOT_root_CMD} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressHistogram.cxx
183+
ROOT_ADD_TEST(test-stresshistogram-interpreted COMMAND ${root_exe} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressHistogram.cxx
214184
FAILREGEX "FAILED|Error in")
215185

216186
#--stressGUI---------------------------------------------------------------------------------------
217-
if(ROOT_asimage_FOUND)
187+
if(asimage)
218188
ROOT_EXECUTABLE(stressGUI stressGUI.cxx LIBRARIES Gui Recorder GuiHtml ASImageGui)
219189
endif()
220190

221191
#--stressSpectrum----------------------------------------------------------------------------------
222192
if (spectrum)
223193
ROOT_EXECUTABLE(stressSpectrum stressSpectrum.cxx LIBRARIES Hist Spectrum Gpad)
224194
ROOT_ADD_TEST(test-stressspectrum COMMAND stressSpectrum -b FAILREGEX "FAILED|Error in" LABELS longtest)
225-
ROOT_ADD_TEST(test-stressspectrum-interpreted COMMAND ${ROOT_root_CMD} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressSpectrum.cxx
195+
ROOT_ADD_TEST(test-stressspectrum-interpreted COMMAND ${root_exe} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressSpectrum.cxx
226196
FAILREGEX "FAILED|Error in" DEPENDS test-stressspectrum LABELS longtest)
227197
endif()
228198

229199
#--stressVector------------------------------------------------------------------------------------
230-
ROOT_EXECUTABLE(stressVector stressVector.cxx LIBRARIES Physics GenVector)
200+
ROOT_EXECUTABLE(stressVector stressVector.cxx LIBRARIES Physics GenVector Smatrix)
231201
ROOT_ADD_TEST(test-stressvector COMMAND stressVector FAILREGEX "FAILED|Error in")
232-
ROOT_ADD_TEST(test-stressvector-interpreted COMMAND ${ROOT_root_CMD} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressVector.cxx
202+
ROOT_ADD_TEST(test-stressvector-interpreted COMMAND ${root_exe} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressVector.cxx
233203
FAILREGEX "FAILED|Error in" DEPENDS test-stressvector)
234204

235205
#--stressMathMore----------------------------------------------------------------------------------
236-
if(ROOT_mathmore_FOUND)
206+
if(mathmore)
237207
ROOT_EXECUTABLE(stressMathMore stressMathMore.cxx LIBRARIES MathMore Smatrix)
238208
ROOT_ADD_TEST(test-stressmathmore COMMAND stressMathMore FAILREGEX "FAILED|Error in" LABELS longtest)
239-
ROOT_ADD_TEST(test-stressmathmore-interpreted COMMAND ${ROOT_root_CMD} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressMathMore.cxx
209+
ROOT_ADD_TEST(test-stressmathmore-interpreted COMMAND ${root_exe} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressMathMore.cxx
240210
FAILREGEX "FAILED|Error in" DEPENDS test-stressmathmore TIMEOUT 1800)
241211
endif()
242212

@@ -252,37 +222,37 @@ if(MSVC AND NOT CMAKE_GENERATOR MATCHES Ninja)
252222
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/libTrackMathCoreDict.dll
253223
${CMAKE_CURRENT_BINARY_DIR}/libTrackMathCoreDict.dll)
254224
endif()
255-
ROOT_EXECUTABLE(stressMathCore stressMathCore.cxx LIBRARIES MathCore Hist RIO Tree GenVector)
225+
ROOT_EXECUTABLE(stressMathCore stressMathCore.cxx LIBRARIES MathCore Hist RIO Tree GenVector Smatrix)
256226
ROOT_ADD_TEST(test-stressmathcore COMMAND stressMathCore FAILREGEX "FAILED|Error in" LABELS longtest)
257-
ROOT_ADD_TEST(test-stressmathcore-interpreted COMMAND ${ROOT_root_CMD} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressMathCore.cxx
227+
ROOT_ADD_TEST(test-stressmathcore-interpreted COMMAND ${root_exe} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressMathCore.cxx
258228
FAILREGEX "FAILED|Error in" DEPENDS test-stressmathcore)
259229

260230
#--stressFit---------------------------------------------------------------------------------
261231
ROOT_EXECUTABLE(stressFit stressFit.cxx LIBRARIES MathCore Matrix)
262232
ROOT_ADD_TEST(test-stressfit COMMAND stressFit FAILREGEX "FAILED|Error in" LABELS longtest)
263-
ROOT_ADD_TEST(test-stressfit-interpreted COMMAND ${ROOT_root_CMD} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressFit.cxx
233+
ROOT_ADD_TEST(test-stressfit-interpreted COMMAND ${root_exe} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressFit.cxx
264234
FAILREGEX "FAILED|Error in" DEPENDS test-stressfit)
265235

266236
#--stressHistoFit-----------------------------------------------------------------------------
267-
if(ROOT_unuran_FOUND)
237+
if(unuran)
268238
ROOT_EXECUTABLE(stressHistoFit stressHistoFit.cxx LIBRARIES MathCore Matrix Unuran Tree Gpad)
269239
ROOT_ADD_TEST(test-stresshistofit COMMAND stressHistoFit FAILREGEX "FAILED|Error in" LABELS longtest)
270240
if(NOT MSVC OR llvm13_broken_tests)
271-
ROOT_ADD_TEST(test-stresshistofit-interpreted COMMAND ${ROOT_root_CMD} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressHistoFit.cxx
241+
ROOT_ADD_TEST(test-stresshistofit-interpreted COMMAND ${root_exe} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressHistoFit.cxx
272242
FAILREGEX "FAILED|Error in" DEPENDS test-stresshistofit )
273243
endif()
274244
endif()
275245

276246
#--stressEntryList---------------------------------------------------------------------------
277247
ROOT_EXECUTABLE(stressEntryList stressEntryList.cxx LIBRARIES MathCore Tree Hist)
278248
ROOT_ADD_TEST(test-stressentrylist COMMAND stressEntryList -b FAILREGEX "FAILED|Error in")
279-
ROOT_ADD_TEST(test-stressentrylist-interpreted COMMAND ${ROOT_root_CMD} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressEntryList.cxx
249+
ROOT_ADD_TEST(test-stressentrylist-interpreted COMMAND ${root_exe} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressEntryList.cxx
280250
FAILREGEX "FAILED|Error in" DEPENDS test-stressentrylist)
281251

282252
#--stressIterators---------------------------------------------------------------------------
283253
ROOT_EXECUTABLE(stressIterators stressIterators.cxx LIBRARIES Core)
284254
ROOT_ADD_TEST(test-stressiterators COMMAND stressIterators FAILREGEX "FAILED|Error in")
285-
ROOT_ADD_TEST(test-stressiterators-interpreted COMMAND ${ROOT_root_CMD} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressIterators.cxx
255+
ROOT_ADD_TEST(test-stressiterators-interpreted COMMAND ${root_exe} -b -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressIterators.cxx
286256
FAILREGEX "FAILED|Error in" DEPENDS test-stressiterators)
287257

288258
#--stressInterpreter-------------------------------------------------------------------------
@@ -319,10 +289,10 @@ ROOT_EXECUTABLE(threads threads.cxx LIBRARIES Thread Hist Gpad)
319289

320290
#--stressIOPlugins--------------------------------------------------------------------------
321291
ROOT_EXECUTABLE(stressIOPlugins stressIOPlugins.cxx LIBRARIES Event Core Hist RIO Tree Gpad Postscript)
322-
if(ROOT_xrootd_FOUND)
292+
if(xrootd)
323293
ROOT_ADD_TEST(test-stressIOPlugins-xroot COMMAND stressIOPlugins root FAILREGEX "FAILED|Error in")
324294
endif()
325-
if(ROOT_davix_FOUND)
295+
if(davix)
326296
ROOT_ADD_TEST(test-stressIOPlugins-http COMMAND stressIOPlugins http FAILREGEX "FAILED|Error in")
327297
endif()
328298

@@ -338,26 +308,26 @@ endif()
338308
ROOT_ADD_TEST(test-TFormulaTests COMMAND TFormulaTests FAILREGEX "FAILED|Error in")
339309

340310
#--Vc basic test-----------------------------------------------------------------------------------
341-
if(ROOT_vc_FOUND)
311+
if(vc)
342312
ROOT_EXECUTABLE(testVc testVc.cxx LIBRARIES ${Vc_LIBRARIES} BUILTINS Vc)
343313
target_include_directories(testVc SYSTEM BEFORE PRIVATE ${Vc_INCLUDE_DIRS})
344314
ROOT_ADD_TEST(test-Vc COMMAND testVc FAILREGEX "FAILED|Error in")
345315
endif()
346316

347317
#--VecCore basic test------------------------------------------------------------------------------
348-
if(ROOT_veccore_FOUND)
318+
if(veccore)
349319
ROOT_EXECUTABLE(test-veccore test-veccore.cxx LIBRARIES ${VecCore_LIBRARIES} BUILTINS VECCORE)
350320
target_include_directories(test-veccore BEFORE PRIVATE ${VecCore_INCLUDE_DIRS})
351321
target_compile_definitions(test-veccore PRIVATE ${VecCore_DEFINITIONS})
352-
if(VecCore_Vc_FOUND)
322+
if(veccore AND vc)
353323
ROOT_ADD_TEST(VecCore COMMAND test-veccore REGEX "Vc")
354324
else()
355325
ROOT_ADD_TEST(VecCore COMMAND test-veccore REGEX "Scalar")
356326
endif()
357327
endif()
358328

359329
#--Vc GenVector test-----------------------------------------------------------------------------------
360-
if(ROOT_vc_FOUND)
330+
if(vc)
361331
ROOT_EXECUTABLE(testGenVectorVc testGenVectorVc.cxx LIBRARIES Physics GenVector ${Vc_LIBRARIES} BUILTINS Vc)
362332
target_include_directories(testGenVectorVc SYSTEM BEFORE PRIVATE ${Vc_INCLUDE_DIRS})
363333
ROOT_ADD_TEST(test-GenVector-Vc COMMAND testGenVectorVc FAILREGEX "FAILED|Error in")

test/stressHistoFit.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
#include "Math/IFunction.h"
8787
#include "Math/IParamFunction.h"
8888
#include "TMath.h"
89-
#include "Math/DistFunc.h"
89+
#include "Math/PdfFuncMathCore.h"
9090

9191
#include "TUnuran.h"
9292
#include "TUnuranMultiContDist.h"

0 commit comments

Comments
 (0)