Skip to content

Commit 2be4fbe

Browse files
committed
[tutorials][test] Specify the include path for SOFIE tutorials in CMake
We don't want to rely on environment variables like `ROOTSYS` in the tutorials, and we should also not leak details of the test setup like `$ROOTSYS/runtutorials` in the user-facing tutorials.
1 parent 6bd7830 commit 2be4fbe

3 files changed

Lines changed: 19 additions & 5 deletions

File tree

tutorials/CMakeLists.txt

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,25 @@ set(ROOT_root_CMD $<TARGET_FILE:root.exe>)
99
set(pythonpaths ${localruntimedir} $ENV{PYTHONPATH})
1010
cmake_path(CONVERT "${pythonpaths}" TO_NATIVE_PATH_LIST pythonpaths_native)
1111

12-
set(root_includepaths ${CMAKE_BINARY_DIR}/tutorials/io/tree ${DEFAULT_ROOT_INCLUDE_PATH})
12+
set(root_includepaths
13+
${CMAKE_BINARY_DIR}/tutorials/io/tree
14+
# Some SOFIE tutorials include headers with code generated by other
15+
# tutorials, which ends up in runtutorials/
16+
${CMAKE_BINARY_DIR}/runtutorials
17+
${DEFAULT_ROOT_INCLUDE_PATH}
18+
)
1319
cmake_path(CONVERT "${root_includepaths}" TO_NATIVE_PATH_LIST root_includepaths_native)
1420

21+
# The environment argument gets serialized in ROOT_ADD_TEST for the
22+
# RootTestDriver, and then deserialized in the latter with multiple steps of
23+
# string parsing. We have to escape the semicolon excessively, because in every
24+
# parsing step we lose one semicolon. Also we use the SEMICOLON generator
25+
# expression, so at least we don't have to worry about escaping for the initial
26+
# configuration stage.
27+
# TODO: consider improving ROOT_ADD_TEST and RootTestDriver.cmake so this is not necessary.
28+
string(REPLACE ";" "\\\\\\\\$<SEMICOLON>" pythonpaths_escaped "${pythonpaths_native}")
29+
string(REPLACE ";" "\\\\\\\\$<SEMICOLON>" root_includepaths_escaped "${root_includepaths_native}")
30+
1531
# - Set the environment for the tutorials, which also contains some environment
1632
# variables related to limiting the number of threads used by NumPy and
1733
# enabling batch mode.
@@ -22,9 +38,9 @@ set(TUTORIAL_ENV
2238
MPLBACKEND=AGG
2339
OMP_NUM_THREADS=1
2440
OPENBLAS_NUM_THREADS=1
25-
PYTHONPATH=${pythonpaths_native}
41+
PYTHONPATH=${pythonpaths_escaped}
2642
ROOT_BATCH=1
27-
ROOT_INCLUDE_PATH=${root_includepaths_native}
43+
ROOT_INCLUDE_PATH=${root_includepaths_escaped}
2844
)
2945

3046
#---Copy the CTestCustom.cmake file into the build directory--------

tutorials/machine_learning/TMVA_SOFIE_GNN_Application.C

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// need to add include path to find generated model file
99
#ifdef __CLING__
1010
R__ADD_INCLUDE_PATH($PWD)
11-
R__ADD_INCLUDE_PATH($ROOTSYS/runtutorials)
1211
#endif
1312

1413
#include "encoder.hxx"

tutorials/machine_learning/TMVA_SOFIE_RDataFrame.C

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ using namespace TMVA::Experimental;
2525
// need to add the current directory (from where we are running this macro)
2626
// to the include path for Cling
2727
R__ADD_INCLUDE_PATH($PWD)
28-
R__ADD_INCLUDE_PATH($ROOTSYS/runtutorials)
2928
#include "Higgs_trained_model.hxx"
3029
#include "TMVA/SOFIEHelpers.hxx"
3130

0 commit comments

Comments
 (0)