From a22ce405c88df1c61947f5795ffe56bc03cb5876 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Tue, 2 Dec 2025 17:58:06 +0100 Subject: [PATCH 1/2] [CMake] Never add current binary dir to command in `ROOT_ADD_TEST` If a test added with `ROOT_ADD_TEST` uses a command that can't be found on the system and that is not an absolute path, the `ROOT_ADD_TEST` macro will implicitly prefix `$CMAKE_CURRENT_BINARY_DIR/`, assuming that the executable is supposed to be found in the current binary dir. However, that is not always a reasonable fallback, and can be even wrong if the executable was supposed to be found in the `PATH` that is set in the `ENVIRONMENT` for that test. So I think it's better to remove that fallback, requiring the tests to be explicit about which executable should be called. Note that this doesn't apply to the case when the command is a CMake target name, because then it will already be expanded to an absolute path by CMake. --- cmake/modules/RootMacros.cmake | 3 --- 1 file changed, 3 deletions(-) diff --git a/cmake/modules/RootMacros.cmake b/cmake/modules/RootMacros.cmake index 51c4b21197b28..32efce70e5fef 100644 --- a/cmake/modules/RootMacros.cmake +++ b/cmake/modules/RootMacros.cmake @@ -1542,9 +1542,6 @@ function(ROOT_ADD_TEST test) find_program(_exe ${_prg}) if(_exe) # if the command is found in the system, use it set(_cmd ${_exe} ${ARG_COMMAND}) - elseif(NOT IS_ABSOLUTE ${_prg}) # if not absolute, assume is found in current binary dir - set(_prg ${CMAKE_CURRENT_BINARY_DIR}/${_prg}) - set(_cmd ${_prg} ${ARG_COMMAND}) else() # take as it is set(_cmd ${_prg} ${ARG_COMMAND}) endif() From 1c5372cf489d0e5428df842bbce169942f8ddc3e Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Wed, 3 Dec 2025 11:09:04 +0100 Subject: [PATCH 2/2] [roottest] Use `root` target file in `dotLibraries` test command The `root` executable should not be used directly in the test command, because if there was no `root` CMake target, it might use the literal string "root" in the command, potentially resolving to a ROOT install on the system and not the ROOT from the build directory. It is safer to use a `TARGET_FILE` generator expression here. --- roottest/root/rint/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roottest/root/rint/CMakeLists.txt b/roottest/root/rint/CMakeLists.txt index 5c9fd3ec33c00..5adc68ffbff39 100644 --- a/roottest/root/rint/CMakeLists.txt +++ b/roottest/root/rint/CMakeLists.txt @@ -21,7 +21,7 @@ ROOTTEST_ADD_TEST(missingSymbol if (NOT MSVC) # ROOT-5843 ROOTTEST_ADD_TEST(dotLibraries - COMMAND root -b -q -l -e ".libraries" + COMMAND $ -b -q -l -e ".libraries" PASSREGEX "libRint") endif()