Skip to content

CMake: Clean up through the build system - #170

Open
Growl1234 wants to merge 2 commits into
Reference-ScaLAPACK:masterfrom
Growl1234:cmake
Open

Growl1234 wants to merge 2 commits into
Reference-ScaLAPACK:masterfrom
Growl1234:cmake

Conversation

@Growl1234

@Growl1234 Growl1234 commented Sep 29, 2026 •

Copy link
Copy Markdown

Modernize and simplify the ScaLAPACK CMake build by using standard imported targets for MPI/LAPACK, a canonical ScaLAPACK::scalapack target, target-based source aggregation, and standard install(EXPORT) package configuration. This PR also makes the library unconditionally PIC, fixes broken pkg-config path generation, removes obsolete custom dependency/download logic, and aligns testing and version compatibility with standard CMake mechanisms.

Closes #109. Closes #124. Closes #169.

@Growl1234
Growl1234 force-pushed the cmake branch 5 times, most recently from 461a63a to 1f2f08d Compare September 29, 2026 14:46
@Growl1234
Growl1234 marked this pull request as ready for review September 29, 2026 15:09

@LecrisUT LecrisUT left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a quick comment to ack that I can help on this review.

Comment thread CMakeLists.txt
Comment thread CMakeLists.txt Outdated

@LecrisUT LecrisUT left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM. Some followups if possible

Comment thread BLACS/SRC/CMakeLists.txt
Comment thread BLACS/CMakeLists.txt
Comment on lines +17 to +20
if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
if("${CMAKE_Fortran_FLAGS}" MATCHES "-ffpe-trap=[izoupd]")
set(FPE_EXIT TRUE)
endif()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible, would rather this go away in this form. It should instead be explicitly linked to the target that uses it, make them generator expressions, opt-in variables etc.

But would also be hard to review all of the changes of what actually makes sense, e.g. "Ensure that Release builds use O2 instead of O3". Let's split this up for a later PR?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be a tricky one I think 🤔

Comment on lines +14 to +18
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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am pretty sure this thing can die? 15 years later, there must be a fixed format each compiler uses now.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if CMake's FortranCInterface would be of help. If possible maybe do it in a dedicated PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for dedicated PR as usual.

Comment thread CMAKE/scalapack-config.cmake.in
Comment thread CMakeLists.txt
Comment on lines +106 to +111
if(MSVC)
add_library(scalapack-F)
add_library(ScaLAPACK::scalapack-F ALIAS scalapack-F)
set(SCALAPACK_FORTRAN_TARGET scalapack-F)
list(APPEND _scalapack_library_targets scalapack-F)
endif()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this, make a common INTERFACE target for this and add it either to scalapack or a new library.

Although, how relevant is this anymore? What Fortran compiler is there anymore for MSVC?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I'm also confused; just didn't check it as I rarely open Windows now :(

Comment thread CMakeLists.txt Outdated
Comment thread scalapack.pc.in
Comment thread CMakeLists.txt Outdated
Comment on lines +92 to +104
- name: Check CMake package
run: |
mkdir consumer
cat > consumer/CMakeLists.txt <<'EOF'
cmake_minimum_required(VERSION 3.26)
project(consumer LANGUAGES C Fortran)
find_package(ScaLAPACK CONFIG REQUIRED)
if(NOT TARGET ScaLAPACK::scalapack)
message(FATAL_ERROR "ScaLAPACK::scalapack target not found")
endif()
EOF
cmake -S consumer -B consumer/build \
-DCMAKE_PREFIX_PATH="$PWD/scalapack_install"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a file and added in the testing infrastructure, but let's do that later

@Growl1234
Growl1234 force-pushed the cmake branch 4 times, most recently from 75feacc to 8aa9f45 Compare October 15, 2026 11:28

@LecrisUT LecrisUT left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good from my review @langou could you or someone move this forward?

Also can mark this PR as closing #124.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

broken .pc file what targets are published by cmake?

3 participants