aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjulie <julielangou@users.noreply.github.com>2014-02-09 00:37:45 +0000
committerjulie <julielangou@users.noreply.github.com>2014-02-09 00:37:45 +0000
commitdf747406083c0d2a08d7e2c9b8ad7b93a570e104 (patch)
treea98b3e15c0f92544337618fbdfc41435c9478b24
parenta681d8fc7a25c6fc3c90ce0fff72dfd60c23e0f8 (diff)
== Patch provided by Brad King from Kitware - brad.king@kitware.com ==
Provide CMake packages for both LAPACK and LAPACKE Teach "lapack-config.cmake" to provide variables LAPACK_blas_LIBRARIES LAPACK_lapack_LIBRARIES that contain either the target names when using the reference implementation or the system libraries found for them. Configure a "lapacke-config.cmake" file for the build and install trees to package LAPACKE. Teach it to load the LAPACK package installed with it. Provide variables LAPACKE_INCLUDE_DIRS LAPACKE_LIBRARIES containing the header file search path for lapacke headers and the list of lapacke library targets. This requires CMake 2.8.10 to separate the installation export for the lapacke library from the other targets.
-rw-r--r--CMAKE/lapack-config-build.cmake.in11
-rw-r--r--CMAKE/lapack-config-install.cmake.in17
-rw-r--r--CMakeLists.txt36
-rw-r--r--lapacke/CMakeLists.txt18
-rw-r--r--lapacke/cmake/lapacke-config-build.cmake.in14
-rw-r--r--lapacke/cmake/lapacke-config-install.cmake.in23
-rw-r--r--lapacke/cmake/lapacke-config-version.cmake.in8
7 files changed, 117 insertions, 10 deletions
diff --git a/CMAKE/lapack-config-build.cmake.in b/CMAKE/lapack-config-build.cmake.in
index 8d60cc88..1d084fe1 100644
--- a/CMAKE/lapack-config-build.cmake.in
+++ b/CMAKE/lapack-config-build.cmake.in
@@ -1 +1,10 @@
-include("@LAPACK_BINARY_DIR@/lapack-targets.cmake")
+# Load lapack targets from the build tree if necessary.
+set(_LAPACK_TARGET "@_lapack_config_build_guard_target@")
+if(_LAPACK_TARGET AND NOT TARGET "${_LAPACK_TARGET}")
+ include("@LAPACK_BINARY_DIR@/lapack-targets.cmake")
+endif()
+unset(_LAPACK_TARGET)
+
+# Report the blas and lapack raw or imported libraries.
+set(LAPACK_blas_LIBRARIES "@BLAS_LIBRARIES@")
+set(LAPACK_lapack_LIBRARIES "@LAPACK_LIBRARIES@")
diff --git a/CMAKE/lapack-config-install.cmake.in b/CMAKE/lapack-config-install.cmake.in
index 0c55fc17..4e04f871 100644
--- a/CMAKE/lapack-config-install.cmake.in
+++ b/CMAKE/lapack-config-install.cmake.in
@@ -1,2 +1,15 @@
-get_filename_component(_SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
-include(${_SELF_DIR}/lapack-targets.cmake)
+# Compute locations from <prefix>/lib/cmake/lapack-<v>/<self>.cmake
+get_filename_component(_LAPACK_SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+
+# Load lapack targets from the install tree if necessary.
+set(_LAPACK_TARGET "@_lapack_config_install_guard_target@")
+if(_LAPACK_TARGET AND NOT TARGET "${_LAPACK_TARGET}")
+ include("${_LAPACK_SELF_DIR}/lapack-targets.cmake")
+endif()
+unset(_LAPACK_TARGET)
+
+# Report the blas and lapack raw or imported libraries.
+set(LAPACK_blas_LIBRARIES "@BLAS_LIBRARIES@")
+set(LAPACK_lapack_LIBRARIES "@LAPACK_LIBRARIES@")
+
+unset(_LAPACK_SELF_DIR)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cb4a3658..0ab93224 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,8 @@
-cmake_minimum_required(VERSION 2.8.7)
+cmake_minimum_required(VERSION 2.8.10)
project(LAPACK Fortran)
+set(LAPACK_VERSION 3.4.2)
+
# Configure the warning and code coverage suppression file
configure_file(
"${LAPACK_SOURCE_DIR}/CTestCustom.cmake.in"
@@ -31,8 +33,11 @@ if (PYTHONINTERP_FOUND)
endif()
# --------------------------------------------------
+set(LAPACK_INSTALL_EXPORT_NAME lapack-targets)
+
macro(lapack_install_library lib)
- install(TARGETS ${lib} EXPORT lapack-targets
+ install(TARGETS ${lib}
+ EXPORT ${LAPACK_INSTALL_EXPORT_NAME}
ARCHIVE DESTINATION lib${LIB_SUFFIX}
LIBRARY DESTINATION lib${LIB_SUFFIX}
RUNTIME DESTINATION bin
@@ -203,7 +208,6 @@ endif(LAPACKE)
SET(CPACK_PACKAGE_NAME "LAPACK")
SET(CPACK_PACKAGE_VENDOR "University of Tennessee, Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "LAPACK- Linear Algebra Package")
-set(LAPACK_VERSION 3.4.2)
set(CPACK_PACKAGE_VERSION_MAJOR 3)
set(CPACK_PACKAGE_VERSION_MINOR 4)
set(CPACK_PACKAGE_VERSION_PATCH 2)
@@ -245,11 +249,32 @@ if(BUILD_TESTING OR LAPACKE_WITH_TMG)
set(ALL_TARGETS ${ALL_TARGETS} tmglib)
endif(BUILD_TESTING OR LAPACKE_WITH_TMG)
+# Export lapack targets, not including lapacke, from the
+# install tree, if any.
+set(_lapack_config_install_guard_target "")
+if(ALL_TARGETS)
+ install(EXPORT lapack-targets
+ DESTINATION lib/cmake/lapack-${LAPACK_VERSION})
+
+ # Choose one of the lapack targets to use as a guard for
+ # lapack-config.cmake to load targets from the install tree.
+ list(GET ALL_TARGETS 0 _lapack_config_install_guard_target)
+endif()
+
+# Include lapacke in targets exported from the build tree.
if(LAPACKE)
set(ALL_TARGETS ${ALL_TARGETS} lapacke)
endif(LAPACKE)
-export(TARGETS ${ALL_TARGETS} FILE lapack-targets.cmake)
+# Export lapack and lapacke targets from the build tree, if any.
+set(_lapack_config_build_guard_target "")
+if(ALL_TARGETS)
+ export(TARGETS ${ALL_TARGETS} FILE lapack-targets.cmake)
+
+ # Choose one of the lapack or lapacke targets to use as a guard
+ # for lapack-config.cmake to load targets from the build tree.
+ list(GET ALL_TARGETS 0 _lapack_config_build_guard_target)
+endif()
configure_file(${LAPACK_SOURCE_DIR}/CMAKE/lapack-config-version.cmake.in
${LAPACK_BINARY_DIR}/lapack-config-version.cmake @ONLY)
@@ -270,6 +295,3 @@ install(FILES
${LAPACK_BINARY_DIR}/lapack-config-version.cmake
DESTINATION lib/cmake/lapack-${LAPACK_VERSION}
)
-
-install(EXPORT lapack-targets
- DESTINATION lib/cmake/lapack-${LAPACK_VERSION})
diff --git a/lapacke/CMakeLists.txt b/lapacke/CMakeLists.txt
index fc702758..4d735a98 100644
--- a/lapacke/CMakeLists.txt
+++ b/lapacke/CMakeLists.txt
@@ -1,6 +1,8 @@
message(STATUS "LAPACKE enable")
enable_language(C)
+set(LAPACK_INSTALL_EXPORT_NAME lapacke-targets)
+
# Create a header file netlib.h for the routines called in my C programs
include(FortranCInterface)
FortranCInterface_HEADER( ${CMAKE_CURRENT_SOURCE_DIR}/include/lapacke_mangling.h
@@ -69,3 +71,19 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/lapacke.pc.in ${CMAKE_CURRENT_BINARY_
${CMAKE_CURRENT_BINARY_DIR}/lapacke.pc
DESTINATION ${PKG_CONFIG_DIR}
)
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/lapacke-config-version.cmake.in
+ ${LAPACK_BINARY_DIR}/lapacke-config-version.cmake @ONLY)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/lapacke-config-build.cmake.in
+ ${LAPACK_BINARY_DIR}/lapacke-config.cmake @ONLY)
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/lapacke-config-install.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/lapacke-config.cmake @ONLY)
+install(FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/lapacke-config.cmake
+ ${LAPACK_BINARY_DIR}/lapacke-config-version.cmake
+ DESTINATION lib/cmake/lapacke-${LAPACK_VERSION}
+ )
+
+install(EXPORT lapacke-targets
+ DESTINATION lib/cmake/lapacke-${LAPACK_VERSION})
diff --git a/lapacke/cmake/lapacke-config-build.cmake.in b/lapacke/cmake/lapacke-config-build.cmake.in
new file mode 100644
index 00000000..eaf71f81
--- /dev/null
+++ b/lapacke/cmake/lapacke-config-build.cmake.in
@@ -0,0 +1,14 @@
+# Load the LAPACK package with which we were built.
+set(LAPACK_DIR "@LAPACK_BINARY_DIR@")
+find_package(LAPACK NO_MODULE)
+
+# Load lapack targets from the build tree, including lapacke targets.
+if(NOT TARGET lapacke)
+ include("@LAPACK_BINARY_DIR@/lapack-targets.cmake")
+endif()
+
+# Report lapacke header search locations.
+set(LAPACKE_INCLUDE_DIRS "@LAPACK_SOURCE_DIR@/lapacke/include")
+
+# Report lapacke libraries.
+set(LAPACKE_LIBRARIES lapacke)
diff --git a/lapacke/cmake/lapacke-config-install.cmake.in b/lapacke/cmake/lapacke-config-install.cmake.in
new file mode 100644
index 00000000..2b6b3f0c
--- /dev/null
+++ b/lapacke/cmake/lapacke-config-install.cmake.in
@@ -0,0 +1,23 @@
+# Compute locations from <prefix>/lib/cmake/lapacke-<v>/<self>.cmake
+get_filename_component(_LAPACKE_SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+get_filename_component(_LAPACKE_PREFIX "${_LAPACKE_SELF_DIR}" PATH)
+get_filename_component(_LAPACKE_PREFIX "${_LAPACKE_PREFIX}" PATH)
+get_filename_component(_LAPACKE_PREFIX "${_LAPACKE_PREFIX}" PATH)
+
+# Load the LAPACK package with which we were built.
+set(LAPACK_DIR "${_LAPACKE_PREFIX}/lib/cmake/lapack-@LAPACK_VERSION@")
+find_package(LAPACK NO_MODULE)
+
+# Load lapacke targets from the install tree.
+if(NOT TARGET lapacke)
+ include(${_LAPACKE_SELF_DIR}/lapacke-targets.cmake)
+endif()
+
+# Report lapacke header search locations.
+set(LAPACKE_INCLUDE_DIRS ${_LAPACKE_PREFIX}/include)
+
+# Report lapacke libraries.
+set(LAPACKE_LIBRARIES lapacke)
+
+unset(_LAPACKE_PREFIX)
+unset(_LAPACKE_SELF_DIR)
diff --git a/lapacke/cmake/lapacke-config-version.cmake.in b/lapacke/cmake/lapacke-config-version.cmake.in
new file mode 100644
index 00000000..2caeb4ab
--- /dev/null
+++ b/lapacke/cmake/lapacke-config-version.cmake.in
@@ -0,0 +1,8 @@
+set(PACKAGE_VERSION "@LAPACK_VERSION@")
+if(NOT ${PACKAGE_FIND_VERSION} VERSION_GREATER ${PACKAGE_VERSION})
+ set(PACKAGE_VERSION_COMPATIBLE 1)
+ if(${PACKAGE_FIND_VERSION} VERSION_EQUAL ${PACKAGE_VERSION})
+ set(PACKAGE_VERSION_EXACT 1)
+ endif()
+endif()
+