Skip to content

Commit

Permalink
workaround bug in older CMake versions
Browse files Browse the repository at this point in the history
  • Loading branch information
gardner48 committed Jul 18, 2024
1 parent 074e7d6 commit 7e982f3
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions cmake/tpl/SundialsLapack.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,23 @@ if(NOT LAPACK_WORKS)

# Attempt to build and link the test executable, pass --debug-trycompile to
# the cmake command to save build files for debugging
try_compile(
COMPILE_OK ${LAPACK_TEST_DIR}
${LAPACK_TEST_DIR}/test.c
LINK_LIBRARIES LAPACK::LAPACK
OUTPUT_VARIABLE COMPILE_OUTPUT)
if (CMAKE_VERSION VERSION_LESS 3.20)
# Workaround bug in older versions of CMake where the BLAS::BLAS target,
# which LAPACK::LAPACK depends on, is not defined in the file
# ${LAPACK_TEST_DIR}/CMakeFiles/CMakeTmp/<random_name>Targets.cmake
# created by try_compile
try_compile(
COMPILE_OK ${LAPACK_TEST_DIR}
${LAPACK_TEST_DIR}/test.c
LINK_LIBRARIES LAPACK::LAPACK BLAS::BLAS
OUTPUT_VARIABLE COMPILE_OUTPUT)
else()
try_compile(
COMPILE_OK ${LAPACK_TEST_DIR}
${LAPACK_TEST_DIR}/test.c
LINK_LIBRARIES LAPACK::LAPACK
OUTPUT_VARIABLE COMPILE_OUTPUT)
endif()

# Check the result
if(COMPILE_OK)
Expand Down

0 comments on commit 7e982f3

Please sign in to comment.