Skip to content

Commit 1c8d81a

Browse files
authored
Merge pull request #413 from derpda/master
Improvements of CMake (instalL) code for CBLAS, LAPACKE
2 parents 48e4108 + ab7261e commit 1c8d81a

File tree

2 files changed

+35
-43
lines changed

2 files changed

+35
-43
lines changed

CBLAS/CMakeLists.txt

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -39,60 +39,34 @@ install(FILES ${CBLAS_INCLUDE} ${LAPACK_BINARY_DIR}/include/cblas_mangling.h
3939
COMPONENT Development
4040
)
4141

42-
# --------------------------------------------------
4342
if(BUILD_TESTING)
4443
add_subdirectory(testing)
4544
add_subdirectory(examples)
4645
endif()
4746

48-
if(NOT BLAS_FOUND)
49-
set(ALL_TARGETS ${ALL_TARGETS} ${BLASLIB})
50-
endif()
51-
52-
# Export cblas targets from the
53-
# install tree, if any.
54-
set(_cblas_config_install_guard_target "")
55-
if(ALL_TARGETS)
56-
install(EXPORT ${CBLASLIB}-targets
57-
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CBLASLIB}-${LAPACK_VERSION}
58-
COMPONENT Development
59-
)
60-
# Choose one of the cblas targets to use as a guard for
61-
# cblas-config.cmake to load targets from the install tree.
62-
list(GET ALL_TARGETS 0 _cblas_config_install_guard_target)
63-
endif()
64-
65-
# Export cblas targets from the build tree, if any.
66-
set(_cblas_config_build_guard_target "")
67-
if(ALL_TARGETS)
68-
export(TARGETS ${ALL_TARGETS} FILE ${CBLASLIB}-targets.cmake)
69-
70-
# Choose one of the cblas targets to use as a guard
71-
# for cblas-config.cmake to load targets from the build tree.
72-
list(GET ALL_TARGETS 0 _cblas_config_build_guard_target)
73-
endif()
47+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cblas.pc.in
48+
${CMAKE_CURRENT_BINARY_DIR}/${CBLASLIB}.pc @ONLY)
49+
install(FILES
50+
${CMAKE_CURRENT_BINARY_DIR}/${CBLASLIB}.pc
51+
DESTINATION ${PKG_CONFIG_DIR}
52+
COMPONENT Development
53+
)
7454

7555
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/cblas-config-version.cmake.in
7656
${LAPACK_BINARY_DIR}/${CBLASLIB}-config-version.cmake @ONLY)
7757
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/cblas-config-build.cmake.in
7858
${LAPACK_BINARY_DIR}/${CBLASLIB}-config.cmake @ONLY)
7959

80-
81-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cblas.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${CBLASLIB}.pc @ONLY)
82-
install(FILES
83-
${CMAKE_CURRENT_BINARY_DIR}/${CBLASLIB}.pc
84-
DESTINATION ${PKG_CONFIG_DIR}
85-
)
86-
8760
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/cblas-config-install.cmake.in
8861
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${CBLASLIB}-config.cmake @ONLY)
8962
install(FILES
9063
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${CBLASLIB}-config.cmake
9164
${LAPACK_BINARY_DIR}/${CBLASLIB}-config-version.cmake
9265
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CBLASLIB}-${LAPACK_VERSION}
66+
COMPONENT Development
9367
)
9468

95-
#install(EXPORT ${CBLASLIB}-targets
96-
# DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CBLASLIB}-${LAPACK_VERSION}
97-
# COMPONENT Development
98-
# )
69+
install(EXPORT ${CBLASLIB}-targets
70+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CBLASLIB}-${LAPACK_VERSION}
71+
COMPONENT Development
72+
)

CMakeLists.txt

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,27 @@ option(LAPACKE_WITH_TMG "Build LAPACKE with tmglib routines" OFF)
353353
if(LAPACKE_WITH_TMG)
354354
set(LAPACKE ON)
355355
endif()
356-
if(BUILD_TESTING OR LAPACKE_WITH_TMG) #already included, avoid double inclusion
356+
357+
# TMGLIB
358+
# Cache export target
359+
set(LAPACK_INSTALL_EXPORT_NAME_CACHE ${LAPACK_INSTALL_EXPORT_NAME})
360+
if(BUILD_TESTING OR LAPACKE_WITH_TMG)
361+
if(LATESTLAPACK_FOUND AND LAPACKE_WITH_TMG)
362+
set(CMAKE_REQUIRED_LIBRARIES ${LAPACK_LIBRARIES})
363+
# Check if dlatms (part of tmg) is found
364+
CHECK_FORTRAN_FUNCTION_EXISTS("dlatms" LAPACK_WITH_TMGLIB_FOUND)
365+
unset(CMAKE_REQUIRED_LIBRARIES)
366+
if(NOT LAPACK_WITH_TMGLIB_FOUND)
367+
# Build and install TMG as part of LAPACKE targets (as opposed to LAPACK
368+
# targets)
369+
set(LAPACK_INSTALL_EXPORT_NAME ${LAPACKELIB}-targets)
370+
endif()
371+
endif()
357372
add_subdirectory(TESTING/MATGEN)
358373
endif()
374+
# Reset export target
375+
set(LAPACK_INSTALL_EXPORT_NAME ${LAPACK_INSTALL_EXPORT_NAME_CACHE})
376+
unset(LAPACK_INSTALL_EXPORT_NAME_CACHE)
359377

360378
if(LAPACKE)
361379
add_subdirectory(LAPACKE)
@@ -450,10 +468,6 @@ if(NOT LATESTLAPACK_FOUND)
450468
set(ALL_TARGETS ${ALL_TARGETS} ${LAPACKLIB})
451469
endif()
452470

453-
if(BUILD_TESTING OR LAPACKE_WITH_TMG)
454-
set(ALL_TARGETS ${ALL_TARGETS} ${TMGLIB})
455-
endif()
456-
457471
# Export lapack targets, not including lapacke, from the
458472
# install tree, if any.
459473
set(_lapack_config_install_guard_target "")
@@ -478,6 +492,10 @@ if(LAPACKE)
478492
set(ALL_TARGETS ${ALL_TARGETS} ${LAPACKELIB})
479493
endif()
480494

495+
if(NOT LAPACK_WITH_TMGLIB_FOUND AND LAPACKE_WITH_TMG)
496+
set(ALL_TARGETS ${ALL_TARGETS} ${TMGLIB})
497+
endif()
498+
481499
# Export lapack and lapacke targets from the build tree, if any.
482500
set(_lapack_config_build_guard_target "")
483501
if(ALL_TARGETS)

0 commit comments

Comments
 (0)