Skip to content

cmake: Use standard try_run instead of execute_process #126

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

- 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.

85 changes: 27 additions & 58 deletions CMAKE/FortranMangling.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,67 +8,36 @@
# NoChange
# f77IsF2C
# UpCase
#

FUNCTION(COMPILE RESULT)
MESSAGE(STATUS "=========")
MESSAGE(STATUS "Compiling and Building BLACS INSTALL Testing to set correct variables")
#

if(CMAKE_BUILD_TYPE)
SET(BUILD_TYPE -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE})
endif()
include_guard()

# Configure:
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND}
"${PROJECT_SOURCE_DIR}/BLACS/INSTALL"
-G ${CMAKE_GENERATOR} ${BUILD_TYPE}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/BLACS/INSTALL/
RESULT_VARIABLE RESVAR OUTPUT_VARIABLE LOG1_OUT ERROR_VARIABLE LOG1_ERR
block()
# TODO: This path is hard-coded
set(BLACS_INSTALL_SRC
${CMAKE_CURRENT_LIST_DIR}/../BLACS/INSTALL
)
if(RESVAR EQUAL 0)
MESSAGE(STATUS "Configure in the INSTALL directory successful")
else()
MESSAGE(STATUS " Build Output:\n ${LOG1_OUT}")
MESSAGE(STATUS " Error Output:\n ${LOG1_ERR}")
MESSAGE(FATAL_ERROR " Configure in the BLACS INSTALL directory FAILED")
endif()

# Build:
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} --build
${PROJECT_SOURCE_DIR}/BLACS/INSTALL/
RESULT_VARIABLE RESVAR OUTPUT_VARIABLE LOG2_OUT ERROR_VARIABLE LOG2_ERR
try_run(xintface_res xintface_compile_res
SOURCES
${BLACS_INSTALL_SRC}/Fintface.f
${BLACS_INSTALL_SRC}/Cintface.c
NO_CACHE
COMPILE_OUTPUT_VARIABLE xintface_compile_output
RUN_OUTPUT_VARIABLE xintface_output
)
if(RESVAR EQUAL 0)
MESSAGE(STATUS "Build in the BLACS INSTALL directory successful")
else()
MESSAGE(STATUS " Build Output:\n ${LOG2_OUT}")
MESSAGE(STATUS " Error Output:\n ${LOG2_ERR}")
MESSAGE(FATAL_ERROR " Build in the BLACS INSTALL directory FAILED")
if(NOT xintface_compile_res)
message(FATAL_ERROR
"Could not compile BLACS/INSTALL:\n"
"${xintface_compile_output}"
)
endif()
# Clean up:
FILE(REMOVE_RECURSE ${PROJECT_SOURCE_DIR}/BLACS/INSTALL/CMakeCache.txt)
FILE(REMOVE_RECURSE ${PROJECT_SOURCE_DIR}/BLACS/INSTALL/CMakeFiles )
ENDFUNCTION()


macro(FORTRAN_MANGLING CDEFS)
MESSAGE(STATUS "=========")
MESSAGE(STATUS "Testing FORTRAN_MANGLING")

execute_process ( COMMAND ${PROJECT_SOURCE_DIR}/BLACS/INSTALL/xintface
RESULT_VARIABLE xintface_RES
OUTPUT_VARIABLE xintface_OUT
ERROR_VARIABLE xintface_ERR)


# MESSAGE(STATUS "FORTRAN MANGLING:RUN \n${xintface_OUT}")

if (xintface_RES EQUAL 0)
STRING(REPLACE "\n" "" xintface_OUT "${xintface_OUT}")
MESSAGE(STATUS "CDEFS set to ${xintface_OUT}")
SET(CDEFS ${xintface_OUT} CACHE STRING "Fortran Mangling" FORCE)
else()
MESSAGE(STATUS " xintface Output:\n ${xintface_OUT}")
MESSAGE(FATAL_ERROR "FORTRAN_MANGLING:ERROR ${xintface_ERR}")
endif()
endmacro(FORTRAN_MANGLING)
if(NOT ${xintface_res} EQUAL 0)
message(FATAL_ERROR
"xintface did not execute properly:\n"
"${xintface_output}"
)
endif()
string(STRIP "${xintface_output}" xintface_output)
set(CDEFS ${xintface_output} CACHE STRING "Fortran Mangling")
endblock()
15 changes: 1 addition & 14 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 @@ -87,8 +80,6 @@ endmacro()
# Testing
SET(DART_TESTING_TIMEOUT 600)

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

Expand Down Expand Up @@ -127,11 +118,7 @@ set(PKG_CONFIG_DIR ${CMAKE_INSTALL_LIBDIR}/pkgconfig CACHE PATH "pkg-config inst
# Fortran Mangling, MPI Tests and BLACS settings
#
include(FortranMangling)
COMPILE(install_COMPILED)

if (NOT DEFINED CDEFS)
FORTRAN_MANGLING(CDEFS)
endif ()
#MESSAGE(STATUS "Setting CDEFS = ${CDEFS}")
#set(CDEFS ${CDEFS} CACHE STRING "Fortran Mangling" FORCE)
MESSAGE(STATUS "=========")
Expand Down
13 changes: 0 additions & 13 deletions CTestConfig.cmake

This file was deleted.

Loading