mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-08 23:00:07 -06:00
FindLAPACK: Provide the LAPACK::LAPACK import target
This commit is contained in:
committed by
Brad King
parent
265fb71c91
commit
4ed936d1b8
4
Help/release/dev/FindLAPACK-import-target.rst
Normal file
4
Help/release/dev/FindLAPACK-import-target.rst
Normal file
@@ -0,0 +1,4 @@
|
||||
FindLAPACK-import-target
|
||||
------------------------
|
||||
|
||||
* The :module:`FindLAPACK` module now provides an imported target.
|
||||
@@ -47,6 +47,14 @@ The following variables may be set to influence this module's behavior:
|
||||
``BLA_F95``
|
||||
if ``ON`` tries to find the BLAS95/LAPACK95 interfaces
|
||||
|
||||
Imported targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module defines the following :prop_tgt:`IMPORTED` target:
|
||||
|
||||
``LAPACK::LAPACK``
|
||||
The libraries to use for LAPACK, if found.
|
||||
|
||||
Result Variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
@@ -526,5 +534,22 @@ if(LAPACK_LIBRARIES STREQUAL "LAPACK_LIBRARIES-PLACEHOLDER-FOR-EMPTY-LIBRARIES")
|
||||
set(LAPACK_LIBRARIES "")
|
||||
endif()
|
||||
|
||||
if(NOT TARGET LAPACK::LAPACK)
|
||||
add_library(LAPACK::LAPACK INTERFACE IMPORTED)
|
||||
set(_lapack_libs "${LAPACK_LIBRARIES}")
|
||||
if(_lapack_libs AND TARGET BLAS::BLAS)
|
||||
# remove the ${BLAS_LIBRARIES} from the interface and replace it
|
||||
# with the BLAS::BLAS target
|
||||
list(REMOVE_ITEM _lapack_libs "${BLAS_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
if(_lapack_libs)
|
||||
set_target_properties(LAPACK::LAPACK PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES "${_lapack_libs}"
|
||||
)
|
||||
endif()
|
||||
unset(_lapack_libs)
|
||||
endif()
|
||||
|
||||
cmake_pop_check_state()
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
|
||||
@@ -1434,6 +1434,7 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH
|
||||
ICU
|
||||
JPEG
|
||||
JsonCpp
|
||||
LAPACK
|
||||
LibArchive
|
||||
LibLZMA
|
||||
LibRHash
|
||||
|
||||
10
Tests/FindLAPACK/CMakeLists.txt
Normal file
10
Tests/FindLAPACK/CMakeLists.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
add_test(NAME FindLAPACK.Test COMMAND
|
||||
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
|
||||
--build-and-test
|
||||
"${CMake_SOURCE_DIR}/Tests/FindLAPACK/Test"
|
||||
"${CMake_BINARY_DIR}/Tests/FindLAPACK/Test"
|
||||
${build_generator_args}
|
||||
--build-project TestFindLAPACK
|
||||
--build-options ${build_options}
|
||||
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
|
||||
)
|
||||
13
Tests/FindLAPACK/Test/CMakeLists.txt
Normal file
13
Tests/FindLAPACK/Test/CMakeLists.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
cmake_minimum_required(VERSION 3.4)
|
||||
project(TestFindLAPACK C)
|
||||
include(CTest)
|
||||
|
||||
find_package(LAPACK REQUIRED)
|
||||
|
||||
add_executable(test_tgt main.c)
|
||||
target_link_libraries(test_tgt LAPACK::LAPACK)
|
||||
add_test(NAME test_tgt COMMAND test_tgt)
|
||||
|
||||
add_executable(test_var main.c)
|
||||
target_link_libraries(test_var PRIVATE ${LAPACK_LIBRARIES})
|
||||
add_test(NAME test_var COMMAND test_var)
|
||||
20
Tests/FindLAPACK/Test/main.c
Normal file
20
Tests/FindLAPACK/Test/main.c
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
// declare what parts of the lapack C-API we need
|
||||
void dgesv_(int*, int*, double*, int*, int*, double*, int*, int*);
|
||||
|
||||
int main()
|
||||
{
|
||||
double A[8] = {
|
||||
0, 1, 2, 3, 4, 5, 6, 7,
|
||||
};
|
||||
double B[2] = { 0, 5 };
|
||||
int ipiv[2] = { 0, 0 };
|
||||
int info = 0;
|
||||
|
||||
int dim = 2;
|
||||
int numCols = 1;
|
||||
dgesv_(&dim, &numCols, A, &dim, ipiv, B, &dim, &info);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user