sundials icon indicating copy to clipboard operation
sundials copied to clipboard

CMake: Use LAPACK imported target

Open gardner48 opened this issue 1 year ago • 6 comments

  1. Use LAPACK::LAPACK rather than LAPACK_LIBRARIES
  2. Simplify try_compile test
  3. Don't overwrite LAPACK_WORKS (test every configuration pass)
  4. Use CHECK_START, CHECK_PASSED, and CHECK_FAILED messages in compile test
  5. Replace manual include guard with include_guard(GLOBAL)
  6. Update SundialsTPL.cmake.template with above changes

gardner48 avatar Jul 15 '24 05:07 gardner48

This may help address #350.

gardner48 avatar Jul 15 '24 05:07 gardner48

@balos1 If you're good with the updates to SundialsTPL.cmake.template and LAPACK_WORKS, I'll see about propagating these changes to the other TPL files (in follow on PRs).

With LAPACK_WORKS this is now only used to bypass the compile test and not to indicate if the compile test passed (since failing is a fatal error). So _WORKS might not be the best name, maybe LAPACK_TEST or SUNDIALS_LAPACK_TEST or SUN_LAPACK_TEST (for better namespacing).

gardner48 avatar Jul 15 '24 05:07 gardner48

This looks great!

balos1 avatar Jul 16 '24 13:07 balos1

Looks like there is a problem with the compile test that might be specific to CMake 3.18, I'm looking into it.

gardner48 avatar Jul 17 '24 01:07 gardner48

It's unclear how I would use the spack version for compilation.

Unfortunately FindLAPACK does not seem to support the usual _ROOT or _DIR options to help the set search path so you'll probably have to set LAPACK_LIBRARIES and LAPACK_LINKER_FLAGS manually. I've not tried it but setting BLA_VENDOR might also work e.g., -DBLA_VENDOR="OpenBLAS"

gardner48 avatar Jul 29 '24 15:07 gardner48

Got it working with David's help. For posterity, -DBLA_VENDOR="OpenBLAS" did work as well as manually setting LAPACK_LIBRARIES and LAPACK_LINKER_FLAGS. Just had to make sure the compiler version was consistent with the OpenBLAS build from spack.

Steven-Roberts avatar Jul 29 '24 23:07 Steven-Roberts

@gardner48 The latest version still works for me, both with a system LAPACK and spack one.

Steven-Roberts avatar Sep 14 '24 03:09 Steven-Roberts