From 5a98ba750e2fbdd748e88181cb6685a730c40f94 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Devenyi" Date: Fri, 14 Aug 2026 23:03:04 -0400 Subject: [PATCH] COMP: Give install_linking the source directory instead of guessing it The test hard-codes the path to the downstream example project: cmake ... ../../nifti_clib/real_easy/minimal_example_of_downstream_usage That only resolves when the build directory happens to be a sibling of a source tree named exactly "nifti_clib". It fails for an in-tree build, for a build directory named anything else, and on CI, where the checkout lives at /nifti_clib and the path resolves to /nifti_clib/nifti_clib/real_easy/... CMake now passes CMAKE_SOURCE_DIR to the script, the way the other test scripts in that directory already receive their arguments. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01KSPnbwpDjVcAYqDdVqLkMU --- nifti2/CMakeLists.txt | 2 +- .../cmake_testscripts/install_linking_test.sh | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/nifti2/CMakeLists.txt b/nifti2/CMakeLists.txt index 6028291d..758df0b9 100644 --- a/nifti2/CMakeLists.txt +++ b/nifti2/CMakeLists.txt @@ -184,7 +184,7 @@ if(NIFTI_BUILD_TESTING AND NIFTI_BUILD_APPLICATIONS) if(TEST_INSTALL) add_test( NAME install_linking - COMMAND sh ${NIFTI_TEST_SCRIPT_DIR}/install_linking_test.sh ${CMAKE_MAKE_PROGRAM} + COMMAND sh ${NIFTI_TEST_SCRIPT_DIR}/install_linking_test.sh ${CMAKE_MAKE_PROGRAM} ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${PROJECT_BINARY_DIR} ) endif() endif() diff --git a/nifti2/nifti_regress_test/cmake_testscripts/install_linking_test.sh b/nifti2/nifti_regress_test/cmake_testscripts/install_linking_test.sh index dccf0fe9..89dcaeaf 100755 --- a/nifti2/nifti_regress_test/cmake_testscripts/install_linking_test.sh +++ b/nifti2/nifti_regress_test/cmake_testscripts/install_linking_test.sh @@ -10,6 +10,18 @@ else export BUILD_TOOL=$1 fi +# Where the project source lives. This used to be hard-coded as +# ../../nifti_clib relative to the build directory, which only resolved +# when the build tree happened to be a sibling of a source tree named +# exactly "nifti_clib" -- so the test failed for an in-tree build, for a +# build directory named anything else, and on CI. +if [ $# -lt 2 ] +then + echo Missing source directory + exit 1 +fi +SRC_DIR=$2 + # Set variables for local install export DESTDIR=installed export PATH="$PWD/$DESTDIR/usr/local/bin:$PATH" @@ -28,7 +40,7 @@ cd downstream_example cmake \ -G 'Unix Makefiles' \ -DCMAKE_MODULE_PATH=../installed/usr/local/share \ - ../../nifti_clib/real_easy/minimal_example_of_downstream_usage + "${SRC_DIR}/real_easy/minimal_example_of_downstream_usage" make echo Success