FindLAPACK defines LAPACK:LAPACK target with wrong properties
Problem
When using the FindLapack module via find_package(LAPACK REQUIRED)
, the returned LAPACK::LAPACK
target does not contain enough information to link the LAPACK library.
System tested
Linux + OpenBlas (CentOS 8), MacOS (latest, as provided by GitHub actions)
Reproduce
CMakeLists.txt
cmake_minimum_required(VERSION 3.19)
project(lapacktest VERSION 0.1 LANGUAGES Fortran)
find_package(LAPACK REQUIRED)
message(STATUS "LAPACK LIBRARIES: ${LAPACK_LIBRARIES}")
get_target_property(targetlib LAPACK::LAPACK INTERFACE_LINK_LIBRARIES)
message(STATUS "LAPACK INTERFACE LINK LIBRARIES FROM TARGET: ${targetlib}")
add_executable(lapacktest test.f90)
target_link_libraries(lapacktest PRIVATE LAPACK::LAPACK) # Linking fails
#target_link_libraries(lapacktest PRIVATE ${LAPACK_LIBRARIES}) # Linking succesful
test.f90
program test
implicit none
integer, parameter :: dp = kind(1.0d0)
interface
function dlamch(cc)
import :: dp
character :: cc
real(dp) :: dlamch
end function dlamch
end interface
real(dp) :: eps
eps = dlamch('E')
print *, 'LAPACK epsilon: ', eps
end program test
Expected behavior
Once LAPACK had been detected, linking should be successful. Also, content of ${LAPACK_LIBRARIES}
variable should be identical to the INTERFACE_LINK_LIBRARIES
property of the LAPACK::LAPACK
target.
Observed behavior
When using the target, the code does not link LAPACK correctly, despite successful detection. The contents of the variable and the target property differ.