From 41ac62c28fab33cd9ccc1b010c9c215b5f05201b Mon Sep 17 00:00:00 2001
From: Cristian Le <git@lecris.dev>
Date: Mon, 31 Mar 2025 11:03:15 +0200
Subject: [PATCH 1/5] Adjust CI to test for CMake versions

---
 .github/workflows/cmake.yml  | 19 +++++++++++++++++--
 BLACS/INSTALL/CMakeLists.txt |  2 +-
 CMakeLists.txt               |  2 +-
 3 files changed, 19 insertions(+), 4 deletions(-)

Index: scalapack/.github/workflows/cmake.yml
===================================================================
--- scalapack.orig/.github/workflows/cmake.yml	2025-09-28 00:35:54.586884890 +0200
+++ scalapack/.github/workflows/cmake.yml	2025-09-28 00:35:54.583653350 +0200
@@ -2,16 +2,9 @@
 
 on:
   push:
-    paths-exclude:
-    - '.github/workflows/make.yml'
-    - '.gitignore'
-    - 'README'
-    - '**README'
-    - 'LICENSE'
-    - '**Makefile'
-    - 'SLmake.inc.example'
+    branches: [master]
   pull_request:
-    paths-exclude:
+    paths-ignore:
     - '.github/workflows/make.yml'
     - '.gitignore'
     - 'README'
@@ -20,10 +13,14 @@
     - '**Makefile'
     - 'SLmake.inc.example'
 
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: true
+
 env:
   CFLAGS: "-Wall -pedantic"
   FFLAGS: "-fcheck=all,no-bounds"
-  BUILD_TYPE: Release
+  CMAKE_BUILD_TYPE: Release
   MPIEXEC_PREFLAGS: "--oversubscribe"
 
 defaults:
@@ -33,15 +30,22 @@
 jobs:
 
   build-all:
+    name: >
+      CMake ${{ matrix.cmake }}
     runs-on: ubuntu-latest
-
+    strategy:
+      matrix:
+        # CMake versions to test:
+        # - minimum and maximum in the `cmake_minimum_required`
+        #   (if needed expand this to add all intermediate values
+        #    for *temporary* CI testing)
+        # - latest version
+        cmake: ["3.26", "4.0", latest]
+      fail-fast: false
     steps:
 
     - name: Checkout ScaLAPACK
-      uses: actions/checkout@v2
-
-    - name: Install ninja-build tool
-      uses: seanmiddleditch/gha-setup-ninja@v3
+      uses: actions/checkout@v4
 
     - name: Setup MPI
       # uses: mpi4py/setup-mpi@v1
@@ -51,29 +55,32 @@
 
     - name: Install BLAS and LAPACK
       run: sudo apt -y install libblas-dev liblapack-dev
-        
+
+    - name: Setup CMake
+      uses: jwlawson/actions-setup-cmake@v2
+      with:
+        cmake-version: ${{ matrix.cmake }}
+
     - name: CMake configuration
+      # TODO: Use cmake presets for newer versions
+      # TODO: Simplify the defaults to not require configuration
       run: >
-        cmake -B build
-        -G Ninja
-        -D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
-        -D CMAKE_INSTALL_PREFIX=${{github.workspace}}/scalapack_install
-        -D BUILD_SHARED_LIBS=ON
-        -D SCALAPACK_BUILD_TESTS=ON
-        -D MPIEXEC_PREFLAGS=${{env.MPIEXEC_PREFLAGS}}
-        
+        cmake -B build \
+          -G Ninja \
+          -DCMAKE_BUILD_TYPE=${{env.CMAKE_BUILD_TYPE}} \
+          -DBUILD_SHARED_LIBS=ON \
+          -DSCALAPACK_BUILD_TESTS=ON \
+          -DMPIEXEC_PREFLAGS=${{env.MPIEXEC_PREFLAGS}}
+
     - name: Build
-      working-directory: ${{github.workspace}}/build
-      run: |
-        ctest -D ExperimentalStart
-        ctest -D ExperimentalConfigure
-        ctest -D ExperimentalBuild
+      run: >
+        cmake --build build
 
     - name: Test
+      # CMake<3.20 does not have -B option
       working-directory: ${{github.workspace}}/build
-      run: |
-        ctest -D ExperimentalTest --schedule-random --output-on-failure --timeout 180
-        ctest -D ExperimentalSubmit
-        
+      run: >
+        ctest --output-on-failure
+
     - name: Install
-      run: cmake --build build --target install
+      run: cmake --install build --prefix scalapack_install
Index: scalapack/BLACS/INSTALL/CMakeLists.txt
===================================================================
--- scalapack.orig/BLACS/INSTALL/CMakeLists.txt	2025-09-28 00:35:54.586884890 +0200
+++ scalapack/BLACS/INSTALL/CMakeLists.txt	2025-09-28 00:35:54.583810331 +0200
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 3.26...4.0)
 project(INSTALL C Fortran)
 
 add_executable(xintface Fintface.f Cintface.c)
Index: scalapack/CMakeLists.txt
===================================================================
--- scalapack.orig/CMakeLists.txt	2025-09-28 00:35:54.586884890 +0200
+++ scalapack/CMakeLists.txt	2025-09-28 00:35:54.584012727 +0200
@@ -1,14 +1,7 @@
-cmake_minimum_required(VERSION 3.9)
+cmake_minimum_required(VERSION 3.26...4.0)
 
 project(SCALAPACK VERSION 2.2.1 LANGUAGES C Fortran)
 
-# Configure the warning and code coverage suppression file
-configure_file(
-  "${SCALAPACK_SOURCE_DIR}/CMAKE/CTestCustom.cmake.in"
-  "${SCALAPACK_BINARY_DIR}/CTestCustom.cmake"
-  COPYONLY
-)
-
 # Add the CMake directory for custon CMake modules
 set(CMAKE_MODULE_PATH "${SCALAPACK_SOURCE_DIR}/CMAKE" ${CMAKE_MODULE_PATH})
 
@@ -91,8 +84,6 @@
 SET(DART_TESTING_TIMEOUT 600)
 
 enable_testing()
-include(CTest)
-enable_testing()
 # --------------------------------------------------
 
 # Organize output files.  On Windows this also keeps .dll files next
Index: scalapack/CMAKE/CTestCustom.cmake.in
===================================================================
--- scalapack.orig/CMAKE/CTestCustom.cmake.in	2025-09-28 00:35:54.586884890 +0200
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,42 +0,0 @@
-#
-# For further details regarding this file, 
-# see http://www.vtk.org/Wiki/CMake_Testing_With_CTest#Customizing_CTest
-#
-
-SET(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE   0)
-SET(CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE   0)
-SET(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS        500)
-SET(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS      500)
-
-# Files to explicitly exclude from code coverage
-SET(CTEST_CUSTOM_COVERAGE_EXCLUDE
- ${CTEST_CUSTOM_COVERAGE_EXCLUDE}
- 
- # Exclude the testing code itself from code coverage
- "/TESTING/"
-)
-
-# Warnings to explicitly ignore
-SET(CTEST_CUSTOM_WARNING_EXCEPTION
-  ${CTEST_CUSTOM_WARNING_EXCEPTION}
-
-  # Common warning when linking ATLAS built with GNU Fortran 4.1 and building 
-  # with GNU Fortran 4.4.  It can be safely ignored.
-  "libgfortran.*may conflict with libgfortran"
-
-  # Harmless warning often seen on IRIX
-  "WARNING 84 : .*libm.* is not used for resolving any symbol"
-
-  # Warnings caused by sun compilers when building code to only run on your 
-  # native platform
-  "xarch=native on this architecture implies -xarch=.*which generates code that does not run"
-  
-  # Harmless warnings from the Intel compiler on Windows
-  "ipo: warning #11010: file format not recognized for .*\\.exe\\.embed\\.manifest\\.res"
-  "LINK : warning LNK4224: /INCREMENTAL:YES is no longer supported;  ignored"
-
-  # Warnings caused by string truncation in the test code.  The truncation is 
-  # intentional
-  "Character string truncated to length 1 on assignment"
-)
-
Index: scalapack/CTestConfig.cmake
===================================================================
--- scalapack.orig/CTestConfig.cmake	2025-09-28 00:35:54.586884890 +0200
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,13 +0,0 @@
-## This file should be placed in the root directory of your project.
-## Then modify the CMakeLists.txt file in the root directory of your
-## project to incorporate the testing dashboard.
-## # The following are required to uses Dart and the Cdash dashboard
-##   ENABLE_TESTING()
-##   INCLUDE(CTest)
-set(CTEST_PROJECT_NAME "ScaLAPACK")
-set(CTEST_NIGHTLY_START_TIME "00:00:00 EST")
-
-set(CTEST_DROP_METHOD "http")
-set(CTEST_DROP_SITE "icl.cs.utk.edu/cdash")
-set(CTEST_DROP_LOCATION "/submit.php?project=ScaLAPACK")
-set(CTEST_DROP_SITE_CDASH TRUE)
Index: scalapack/.github/workflows/make.yml
===================================================================
--- scalapack.orig/.github/workflows/make.yml	2025-09-28 00:35:54.586884890 +0200
+++ scalapack/.github/workflows/make.yml	2025-09-28 00:35:54.583217572 +0200
@@ -2,16 +2,9 @@
 
 on:
   push:
-    paths-exclude:
-    - '.github/workflows/cmake.yml'
-    - '.gitignore'
-    - 'README'
-    - '**README'
-    - 'LICENSE'
-    - 'CMAKE**'
-    - '**CMakeLists.txt'
+    branches: [master]
   pull_request:
-    paths-exclude:
+    paths-ignore:
     - '.github/workflows/cmake.yml'
     - '.gitignore'
     - 'README'
@@ -20,6 +13,10 @@
     - 'CMAKE**'
     - '**CMakeLists.txt'
 
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: true
+
 defaults:
   run:
     shell: bash
