CMake: Use LAPACK imported target
- Use
LAPACK::LAPACKrather thanLAPACK_LIBRARIES - Simplify
try_compiletest - Don't overwrite
LAPACK_WORKS(test every configuration pass) - Use
CHECK_START,CHECK_PASSED, andCHECK_FAILEDmessages in compile test - Replace manual include guard with
include_guard(GLOBAL) - Update
SundialsTPL.cmake.templatewith above changes
This may help address #350.
@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).
This looks great!
Looks like there is a problem with the compile test that might be specific to CMake 3.18, I'm looking into it.
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"
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.
@gardner48 The latest version still works for me, both with a system LAPACK and spack one.