Skip to content
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

CMake build: Add -DLAPACK option, un-break CBLAS+BLAS build, do not require C++ if unnecessary #972

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

drhpc
Copy link

@drhpc drhpc commented Jan 8, 2024

This fixes some build issues I face when packaging for pkgsrc using the CMake build.

  • Adds option to build without LAPACK, so that any of BLAS, LAPACK, CBLAS, LAPACKE can be built as individual library from source.
  • Fixes CBLAS build missing blas-targets for CMake by adding that. Note that I do not use those cmake files and scrub them from the install. Would like an option to avoid that machinery, as we use pkg-config also for CMake to locate BLAS deps (BLA_PREFER_PKGCONFIG in FindBLAS).
  • Avoids requiring a C++ compiler when not needed.
  • Also fixes macro usage for BLAS++ / LAPACK++.

I hope that can be merged in one go. Though, I have to admit that I am no CMake expert and someone might find further errors. But this works for me at least.

All components are optional now, so that only BLAS can be built.
This enables

  cmake -DLAPACK=off -DLAPACKE=off -DCBLAS=ON -DUSE_OPTIMIZED_BLAS=OFF ..

to finish without complaining about cblas missing blas-targets. This installs
additional cmake machinery for libblas, which seems to be fair, like the other
libs.
The current setup requires a C++ compiler when none is needed, tripping
up some build frameworks that are picky about that. And … there are situations
where you have a C compiler and no C++.
@drhpc
Copy link
Author

drhpc commented Jan 8, 2024

Does #834 mean that LAPACKE may be built without Fortran … but only LAPACKE? This PR might need some adaptation to only enable Fortran for BLAS, LAPACK … and CBLAS?

@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.6)

project(LAPACK)
project(LAPACK Fortran C)
Copy link

Choose a reason for hiding this comment

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

With the project language specified here, statements enable_language(Fortran) at lines 226 and 301 are not needed anymore.

@@ -278,6 +282,10 @@ endif()

option(USE_OPTIMIZED_LAPACK "Whether or not to use an optimized LAPACK library instead of included netlib LAPACK" OFF)

option(LAPACK "Whether to build or use LAPACK (to enable a BLAS-only build)")
Copy link

@quant quant Jan 29, 2024

Choose a reason for hiding this comment

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

Please be explicit, do not omit OFF, even though it is the default.
And consider building LAPACK enabled by default, in the project named LAPACK.

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