Skip to content

Commit 6866f37

Browse files
committed
TMG bundled with LAPACKE in certain case
If otimized/preinstalled LAPACK without TMG is used, TMG is part of LAPACKE. This is necessary for installation to work properly.
1 parent 61673db commit 6866f37

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

CMakeLists.txt

Lines changed: 24 additions & 2 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)
@@ -451,7 +469,7 @@ if(NOT LATESTLAPACK_FOUND)
451469
set(ALL_TARGETS ${ALL_TARGETS} ${LAPACKLIB})
452470
endif()
453471

454-
if(BUILD_TESTING OR LAPACKE_WITH_TMG)
472+
if(BUILD_TESTING)
455473
set(ALL_TARGETS ${ALL_TARGETS} ${TMGLIB})
456474
endif()
457475

@@ -479,6 +497,10 @@ if(LAPACKE)
479497
set(ALL_TARGETS ${ALL_TARGETS} ${LAPACKELIB})
480498
endif()
481499

500+
if(NOT LAPACK_WITH_TMGLIB_FOUND AND LAPACKE_WITH_TMG)
501+
set(ALL_TARGETS ${ALL_TARGETS} ${TMGLIB})
502+
endif()
503+
482504
# Export lapack and lapacke targets from the build tree, if any.
483505
set(_lapack_config_build_guard_target "")
484506
if(ALL_TARGETS)

0 commit comments

Comments
 (0)