Skip to content

cmake: Use upstream helpers for the Config.cmake file #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
  •  
  •  
  •  
75 changes: 41 additions & 34 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,9 @@ name: CMake CI

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'
Expand All @@ -20,10 +13,14 @@ on:
- '**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:
Expand All @@ -33,15 +30,22 @@ defaults:
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
Expand All @@ -51,29 +55,32 @@ jobs:

- 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 -j $(nproc)

- name: Install
run: cmake --build build --target install
run: cmake --install build --prefix scalapack_install
15 changes: 6 additions & 9 deletions .github/workflows/make.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,9 @@ name: Makefile CI

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'
Expand All @@ -20,6 +13,10 @@ on:
- 'CMAKE**'
- '**CMakeLists.txt'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion BLACS/INSTALL/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
42 changes: 0 additions & 42 deletions CMAKE/CTestCustom.cmake.in

This file was deleted.

1 change: 0 additions & 1 deletion CMAKE/scalapack-config-build.cmake.in

This file was deleted.

2 changes: 0 additions & 2 deletions CMAKE/scalapack-config-install.cmake.in

This file was deleted.

8 changes: 0 additions & 8 deletions CMAKE/scalapack-config-version.cmake.in

This file was deleted.

21 changes: 21 additions & 0 deletions CMAKE/scalapackConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
cmake_minimum_required(VERSION 3.17...4.0)

@PACKAGE_INIT@

include(${CMAKE_CURRENT_LIST_DIR}/scalapackTargets.cmake)

# Deprecated compatibility shims
if(TARGET scalapack::scalapack)
add_library(scalapack INTERFACE IMPORTED)
target_link_libraries(scalapack INTERFACE scalapack::scalapack)
set_target_properties(scalapack PROPERTIES
DEPRECATION "Target scalapack is deprecated, use scalapack::scalapack instead."
)
endif()
if(TARGET scalapack::scalapack-F)
add_library(scalapack-F INTERFACE IMPORTED)
target_link_libraries(scalapack-F INTERFACE scalapack::scalapack-F)
set_target_properties(scalapack-F PROPERTIES
DEPRECATION "Target scalapack-F is deprecated, use scalapack::scalapack-F instead."
)
endif()
74 changes: 41 additions & 33 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
cmake_minimum_required(VERSION 3.9)
cmake_minimum_required(VERSION 3.26...4.0)

project(SCALAPACK VERSION 2.2.2 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})

Expand Down Expand Up @@ -77,18 +70,17 @@ if (UNIX)
endif ()
endif ()

# TODO: Remove this macro
macro(SCALAPACK_install_library lib)
install(TARGETS ${lib} EXPORT scalapack-targets
RUNTIME DESTINATION Testing
)
install(TARGETS ${lib}
EXPORT scalapackTargets
)
endmacro()

# --------------------------------------------------
# Testing
SET(DART_TESTING_TIMEOUT 600)

enable_testing()
include(CTest)
enable_testing()
# --------------------------------------------------

Expand Down Expand Up @@ -237,6 +229,7 @@ append_subdir_files(src-C "SRC")

if (NOT MSVC)
add_library(scalapack ${blacs} ${tools} ${tools-C} ${extra_lapack} ${pblas} ${pblas-F} ${ptzblas} ${ptools} ${pbblas} ${redist} ${src} ${src-C})
add_library(scalapack::scalapack ALIAS scalapack)
set_target_properties(scalapack PROPERTIES
VERSION ${SCALAPACK_VERSION}
SOVERSION ${SCALAPACK_VERSION_MAJOR}.${SCALAPACK_VERSION_MINOR})
Expand All @@ -245,11 +238,13 @@ if (NOT MSVC)
else () # Need to separate Fortran and C Code
OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON )
add_library(scalapack ${blacs} ${tools-C} ${pblas} ${ptools} ${redist} ${src-C})
add_library(scalapack::scalapack ALIAS scalapack)
set_target_properties(scalapack PROPERTIES
VERSION ${SCALAPACK_VERSION}
SOVERSION ${SCALAPACK_VERSION_MAJOR}.${SCALAPACK_VERSION_MINOR})
target_link_libraries( scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_C)
add_library(scalapack-F ${pblas-F} ${pbblas} ${ptzblas} ${tools} ${src} ${extra_lapack} )
add_library(scalapack::scalapack-F ALIAS scalapack-F)
set_target_properties(scalapack-F PROPERTIES
VERSION ${SCALAPACK_VERSION}
SOVERSION ${SCALAPACK_VERSION_MAJOR}.${SCALAPACK_VERSION_MINOR})
Expand All @@ -265,6 +260,16 @@ endif()
option(SCALAPACK_BUILD_TESTS "Build all tests of the ScaLAPACK library" ON)
if(${SCALAPACK_BUILD_TESTS})
add_subdirectory(TESTING)
# Make sure that the build artifacts are exported for the test-suite
foreach(target IN ITEMS scalapack scalapack-F)
if(TARGET ${target})
export(TARGETS ${target}
FILE scalapackTargets.cmake
NAMESPACE scalapack::
APPEND
)
endif()
endforeach()
endif()

# --------------------------------------------------
Expand Down Expand Up @@ -299,33 +304,36 @@ INCLUDE(CPack)
# --------------------------------------------------


export(TARGETS scalapack FILE scalapack-targets.cmake)

if( NOT LAPACK_FOUND )
install(FILES
${BLAS_LIBRARIES} ${LAPACK_LIBRARIES}
DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
endif( NOT LAPACK_FOUND )

configure_file(${SCALAPACK_SOURCE_DIR}/CMAKE/scalapack-config-version.cmake.in
${SCALAPACK_BINARY_DIR}/scalapack-config-version.cmake @ONLY)
configure_file(${SCALAPACK_SOURCE_DIR}/CMAKE/scalapack-config-build.cmake.in
${SCALAPACK_BINARY_DIR}/scalapack-config.cmake @ONLY)
include(CMakePackageConfigHelpers)
configure_package_config_file(
CMAKE/scalapackConfig.cmake.in
scalapackConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/scalapack
)
write_basic_package_version_file(
scalapackConfigVersion.cmake
COMPATIBILITY SameMajorVersion
)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scalapack.pc.in ${CMAKE_CURRENT_BINARY_DIR}/scalapack.pc)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/scalapack.pc
DESTINATION ${PKG_CONFIG_DIR}
)
install(EXPORT scalapackTargets
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/scalapack
NAMESPACE scalapack
)

configure_file(${SCALAPACK_SOURCE_DIR}/CMAKE/scalapack-config-install.cmake.in
${SCALAPACK_BINARY_DIR}/CMakeFiles/scalapack-config.cmake @ONLY)
configure_file(scalapack.pc.in scalapack.pc @ONLY)
install(FILES
${SCALAPACK_BINARY_DIR}/CMakeFiles/scalapack-config.cmake
${SCALAPACK_BINARY_DIR}/scalapack-config-version.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/scalapack-${SCALAPACK_VERSION}
)

install(EXPORT scalapack-targets
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/scalapack-${SCALAPACK_VERSION})
${CMAKE_CURRENT_BINARY_DIR}/scalapack.pc
DESTINATION ${PKG_CONFIG_DIR}
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/scalapackConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/scalapackConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/scalapack
)
13 changes: 0 additions & 13 deletions CTestConfig.cmake

This file was deleted.

Loading
Loading