@@ -353,9 +353,27 @@ option(LAPACKE_WITH_TMG "Build LAPACKE with tmglib routines" OFF)
353
353
if (LAPACKE_WITH_TMG )
354
354
set (LAPACKE ON )
355
355
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 ()
357
372
add_subdirectory (TESTING/MATGEN )
358
373
endif ()
374
+ # Reset export target
375
+ set (LAPACK_INSTALL_EXPORT_NAME ${LAPACK_INSTALL_EXPORT_NAME_CACHE} )
376
+ unset (LAPACK_INSTALL_EXPORT_NAME_CACHE )
359
377
360
378
if (LAPACKE )
361
379
add_subdirectory (LAPACKE )
@@ -451,7 +469,7 @@ if(NOT LATESTLAPACK_FOUND)
451
469
set (ALL_TARGETS ${ALL_TARGETS} ${LAPACKLIB} )
452
470
endif ()
453
471
454
- if (BUILD_TESTING OR LAPACKE_WITH_TMG )
472
+ if (BUILD_TESTING )
455
473
set (ALL_TARGETS ${ALL_TARGETS} ${TMGLIB} )
456
474
endif ()
457
475
@@ -479,6 +497,10 @@ if(LAPACKE)
479
497
set (ALL_TARGETS ${ALL_TARGETS} ${LAPACKELIB} )
480
498
endif ()
481
499
500
+ if (NOT LAPACK_WITH_TMGLIB_FOUND AND LAPACKE_WITH_TMG )
501
+ set (ALL_TARGETS ${ALL_TARGETS} ${TMGLIB} )
502
+ endif ()
503
+
482
504
# Export lapack and lapacke targets from the build tree, if any.
483
505
set (_lapack_config_build_guard_target "" )
484
506
if (ALL_TARGETS )
0 commit comments