Skip to content

Conversation

eduardz1
Copy link
Contributor

This PR is the start of #1031, it currently only separates the BLAS and LAPACK. This means that, when including the stdlib in a CMake project through FetchContent, we can link only the fortran_stdlib::blas or fortran_stdlib::lapack targets. This kind of approach might become a bit difficult to manage in the future so there should be some careful discussion about which library could be exported as separate targets. I have started with BLAS and LAPACK because writing interfaces for the two is something that happens way too often. I have also created aliased targets with the namespace to make it a bit nicer to work with when included.

Copy link
Member

@perazz perazz left a comment

Choose a reason for hiding this comment

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

Thank you for this PR @eduardz1. In the interest of maintainability, I think it would be preferable to keep the file lists for blas and lapack targets in their respective blas/ and lapack/ subfolders, rather than moving everything into the top-level CMakeLists.txt.

I would suggest to move the BLAS/LAPACK file lists and target setup code back into their blas/ and lapack/ subfolders.
Keep the top-level src/CMakeLists.txt streamlined.
Then, use add_subdirectory(blas) and add_subdirectory(lapack) from the top-level.

@eduardz1
Copy link
Contributor Author

Thank you for this PR @eduardz1. In the interest of maintainability, I think it would be preferable to keep the file lists for blas and lapack targets in their respective blas/ and lapack/ subfolders, rather than moving everything into the top-level CMakeLists.txt.

I would suggest to move the BLAS/LAPACK file lists and target setup code back into their blas/ and lapack/ subfolders. Keep the top-level src/CMakeLists.txt streamlined. Then, use add_subdirectory(blas) and add_subdirectory(lapack) from the top-level.

I had to slightly change the preprocess function to make it work again with subfolders

@eduardz1
Copy link
Contributor Author

A solution could also be to have a stdlib_commons target or similar, but I am not familiar enough with the codebase to judge what would be best suited for it (surely stdlib_kinds, probably stdlib_error, but the others I am less confident). At the moment the common modules are compiled once for the common target, once for the LAPACK one and once for the BLAS one. I don't think this is too bad, as it allows us to worry less about having a perfect dependency graph

@eduardz1 eduardz1 requested a review from perazz September 24, 2025 07:44
Copy link
Member

@perazz perazz left a comment

Choose a reason for hiding this comment

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

LGTM, thank you @eduardz1 for this improvement.

@perazz perazz merged commit 80a8164 into fortran-lang:master Sep 26, 2025
16 checks passed
@eduardz1
Copy link
Contributor Author

Thanks!

perazz added a commit to perazz/stdlib that referenced this pull request Oct 6, 2025
Add if(NOT TARGET) guards around add_library calls to prevent conflicts
when the target already exists (e.g., when using stdlib with FetchContent
after PR fortran-lang#1033 which adds ALIAS targets automatically).

This allows users to use the Find module pattern with libraries that
already provide namespaced ALIAS targets.
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.

2 participants