From 44fe87f3fc289f8b72e0a72a1b0017fb7135b2db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Sat, 22 Jun 2024 21:07:50 +0200 Subject: [PATCH 1/4] Make ctests platform independent Windows doesn't have a mechanism similar to rpaths. Instead, shared libraries are searched in the current working directory and in the directory with the executable followed by directories in the environment variable PATH. Add the path to the shared libarpack library to PATH for ctests that run executables that are located in a different directory and that set the current working directory not to the directory with the libarpack.dll. Use a generator expression that should be working independent on the CMake generator. --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ac2000b..36a14a20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -711,6 +711,11 @@ function(build_tests) configure_file(EXAMPLES/MATRIX_MARKET/issue215.mtx ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/issue215.mtx) configure_file(EXAMPLES/MATRIX_MARKET/issue215.sh ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/issue215.sh) add_test(NAME issue215_tst WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND ${BASH_PROGRAM} issue215.sh) + if (WIN32 AND BUILD_SHARED_LIBS) + set_tests_properties(arpackmm_tst issue401_tst issue215_tst + PROPERTIES + ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$") + endif() endif() if (PYTHON3) From 7671cebf29871ec9f85c1d48997ccb62972234be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Sat, 22 Jun 2024 21:09:29 +0200 Subject: [PATCH 2/4] CI: Remove work-around from rules for MinGW that is no longer needed --- .github/workflows/jobs.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/jobs.yml b/.github/workflows/jobs.yml index ee9f1a6f..dd2d4d4f 100644 --- a/.github/workflows/jobs.yml +++ b/.github/workflows/jobs.yml @@ -330,7 +330,6 @@ jobs: if [[ ${{ matrix.mpi }} == ON ]]; then export PATH="/c/Program Files/Microsoft MPI/Bin":$PATH # add mpiexec to msys2 path fi - export PATH="${GITHUB_WORKSPACE}/build":$PATH # add libarpack.dll to msys2 path for tests that run in different directory cd build ctest - name: Re-run tests @@ -340,7 +339,6 @@ jobs: if [[ ${{ matrix.mpi }} == ON ]]; then export PATH="/c/Program Files/Microsoft MPI/Bin":$PATH # add mpiexec to msys2 path fi - export PATH="${GITHUB_WORKSPACE}/build":$PATH # add libarpack.dll to msys2 path for tests that run in different directory cd build echo "::group::Re-run ctest" ctest --rerun-failed --output-on-failure || true From 32070150c70d27fad70a5422d680cdd2a830fbcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Sun, 30 Jun 2024 12:25:32 +0200 Subject: [PATCH 3/4] CMake: Add function to add tests that change working directory. Add a new CMake function that helps to add tests that change their working directory to somewhere else than the directory with the libarpack library. In that case, the environment variable PATH is set to include the directory with the library on Windows while running the tests. Use that new CMake function for the three ctests involving the Eigen library. --- CMakeLists.txt | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 36a14a20..b4a97030 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -626,7 +626,23 @@ endif() ############################ # TEST ############################ -function(build_tests) + +function(add_test_with_rpath test_name) + # Add test which sets a current working directory that doesn't contain the + # libarpack library. + # Windows doesn't have a mechanism similar to RPATH on Linux or macOS. + # On Windows, if a test is running in a working directory that doesn't contain + # the ARPACK (and PARPACK) libraries, the path to these libraries has to be + # added to the PATH environment variable. + add_test(NAME ${test_name} ${ARGN}) + if (WIN32 AND BUILD_SHARED_LIBS) + set_tests_properties(${test_name} + PROPERTIES + ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$") + endif() +endfunction() + +function(build_tests) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/TESTS) add_executable(dnsimp_test TESTS/dnsimp.f TESTS/mmio.f TESTS/debug.h) @@ -704,18 +720,13 @@ function(build_tests) configure_file(EXAMPLES/MATRIX_MARKET/B.mtx ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/B.mtx) configure_file(EXAMPLES/MATRIX_MARKET/Bz.mtx ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Bz.mtx) configure_file(EXAMPLES/MATRIX_MARKET/arpackmm.sh ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/arpackmm.sh) - add_test(NAME arpackmm_tst WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND ${BASH_PROGRAM} arpackmm.sh) + add_test_with_rpath(arpackmm_tst WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND ${BASH_PROGRAM} arpackmm.sh) configure_file(EXAMPLES/MATRIX_MARKET/issue401.mtx ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/issue401.mtx) configure_file(EXAMPLES/MATRIX_MARKET/issue401.sh ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/issue401.sh) - add_test(NAME issue401_tst WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND ${BASH_PROGRAM} issue401.sh) + add_test_with_rpath(issue401_tst WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND ${BASH_PROGRAM} issue401.sh) configure_file(EXAMPLES/MATRIX_MARKET/issue215.mtx ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/issue215.mtx) configure_file(EXAMPLES/MATRIX_MARKET/issue215.sh ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/issue215.sh) - add_test(NAME issue215_tst WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND ${BASH_PROGRAM} issue215.sh) - if (WIN32 AND BUILD_SHARED_LIBS) - set_tests_properties(arpackmm_tst issue401_tst issue215_tst - PROPERTIES - ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$") - endif() + add_test_with_rpath(issue215_tst WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND ${BASH_PROGRAM} issue215.sh) endif() if (PYTHON3) @@ -800,7 +811,7 @@ endfunction(build_tests) if(TESTS) enable_testing() - set(CMAKE_CTEST_COMMAND ctest -V) + set(CMAKE_CTEST_COMMAND ctest -V) build_tests() endif() From 2c1203e23f9bbdf73606f0bd548e13a70f0113e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Sun, 22 Sep 2024 18:34:27 +0200 Subject: [PATCH 4/4] Update CHANGELOG. --- CHANGES | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES b/CHANGES index 632b12fc..fbe5c68c 100644 --- a/CHANGES +++ b/CHANGES @@ -9,6 +9,9 @@ [ Kyle Guinn ] * Build PARPACK p[sd]lamch10.f with FFLAGS from ./configure instead of forcing -O0. Build all of PARPACK with AM_FFLAGS. +[ Markus Mützel ] + * CMake: Fix running CTests on Windows. + arpack-ng - 3.9.1 [ Fabien Péan ]