-
Notifications
You must be signed in to change notification settings - Fork 194
Modularize BLAS and LAPACK modules in CMake to make it easier to use in external projects #1033
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
Conversation
There was a problem hiding this 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.
I had to slightly change the |
A solution could also be to have a |
There was a problem hiding this 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.
Thanks! |
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.
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
orfortran_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.