Skip to content

Commit 38e5b08

Browse files
Apply @mgates3's patch and add BUILD_TYPE to BLAS++ and LAPACK++
See mgates3@ecf6f41
1 parent ca6673b commit 38e5b08

File tree

1 file changed

+54
-99
lines changed

1 file changed

+54
-99
lines changed

CMakeLists.txt

Lines changed: 54 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ include(FetchContent)
1616
FetchContent_Declare(
1717
blaspp
1818
GIT_REPOSITORY https://github.com/icl-utk-edu/blaspp
19-
GIT_TAG f8f983d5b45a8f366aae41fbe9888b14cbae20f8 # v2023.08.25
19+
GIT_TAG 91dd418fa910498cc03dee397826099914cc3185 # v2023.08.25 +
2020
)
2121
FetchContent_Declare(
2222
lapackpp
2323
GIT_REPOSITORY https://github.com/icl-utk-edu/lapackpp
24-
GIT_TAG 62680a16a9aba2a426e3d089dd13e18bfd140c74 # v2023.08.25
24+
GIT_TAG 88088c33cd9467475e8f139f42d158620f11e64d # v2023.08.25 +
2525
)
2626

2727
# Allow setting a prefix for the library names
@@ -416,22 +416,8 @@ endif()
416416
option(BLAS++ "Build BLAS++" OFF)
417417
option(LAPACK++ "Build LAPACK++" OFF)
418418

419-
420-
function(_display_cpp_implementation_msg name)
421-
string(TOLOWER ${name} name_lc)
422-
message(STATUS "${name}++ enable")
423-
message(STATUS "----------------")
424-
message(STATUS "Thank you for your interest in ${name}++, a newly developed C++ API for ${name} library")
425-
message(STATUS "The objective of ${name}++ is to provide a convenient, performance oriented API for development in the C++ language, that, for the most part, preserves established conventions, while, at the same time, takes advantages of modern C++ features, such as: namespaces, templates, exceptions, etc.")
426-
message(STATUS "For support ${name}++ related question, please email: [email protected]")
427-
message(STATUS "----------------")
428-
endfunction()
429-
430419
if (BLAS++ OR LAPACK++)
431-
432-
if (BLAS++)
433-
_display_cpp_implementation_msg("BLAS")
434-
endif()
420+
message( STATUS "BLAS++ enabled; for support, email [email protected]" )
435421

436422
# Check if population has already been performed
437423
FetchContent_GetProperties(blaspp)
@@ -440,16 +426,35 @@ if (BLAS++ OR LAPACK++)
440426
FetchContent_Populate(blaspp)
441427
endif()
442428

443-
# For static builds, we may need to link against a Fortran library
444-
set(BLAS_Fortran_LIB "")
445-
if (NOT BLAS_FOUND AND NOT BUILD_SHARED_LIBS)
429+
# Determine Fortran runtime library.
430+
# todo: CMake ought to know this already -- how to access?
431+
set( Fortran_LIB "" )
432+
if (NOT BUILD_SHARED_LIBS)
446433
if (CMAKE_Fortran_COMPILER_ID MATCHES GNU)
447-
set(BLAS_Fortran_LIB ";-lgfortran")
434+
set( Fortran_LIB ";-lgfortran" )
448435
else()
449436
# TODO: This is incomplete. Fill in the other cases.
450-
set(BLAS_Fortran_LIB "")
451437
endif()
452438
endif()
439+
message( DEBUG "Fortran_LIB '${Fortran_LIB}'" )
440+
441+
if (NOT BLAS_FOUND)
442+
# Link with Reference BLAS.
443+
set( BLAS_LIBS "$<TARGET_FILE:${BLASLIB}>${Fortran_LIB}" )
444+
else()
445+
# Link with optimized BLAS.
446+
set( BLAS_LIBS "${BLAS_LIBRARIES}" )
447+
endif()
448+
message( DEBUG "BLAS_LIBS '${BLAS_LIBS}'" )
449+
450+
if (NOT LATESTLAPACK_FOUND)
451+
# Link with Reference LAPACK.
452+
set( LAPACK_LIBS "$<TARGET_FILE:${LAPACKLIB}>${Fortran_LIB}" )
453+
else()
454+
# Link with optimized BLAS.
455+
set( LAPACK_LIBS "${LAPACK_LIBRARIES}" )
456+
endif()
457+
message( DEBUG "LAPACK_LIBS '${LAPACK_LIBS}'" )
453458

454459
# Adds target blaspp
455460
add_custom_target( blaspp ALL DEPENDS blaspp-cmd )
@@ -458,48 +463,19 @@ if (BLAS++ OR LAPACK++)
458463
COMMENT "Building BLAS++" )
459464

460465
# Set up information about the BLAS and LAPACK libraries
461-
if(NOT BLAS_FOUND)
462-
if(NOT LATESTLAPACK_FOUND)
463-
add_custom_command( OUTPUT blaspp-cmd APPEND
464-
COMMAND ${CMAKE_COMMAND}
465-
-B "${blaspp_BINARY_DIR}"
466-
-D BLAS_LIBRARIES="$<TARGET_FILE:${BLASLIB}>${BLAS_Fortran_LIB}"
467-
-D LAPACK_LIBRARIES="$<TARGET_FILE:${LAPACKLIB}>" )
468-
else()
469-
add_custom_command( OUTPUT blaspp-cmd APPEND
470-
COMMAND ${CMAKE_COMMAND}
471-
-B "${blaspp_BINARY_DIR}"
472-
-D BLAS_LIBRARIES="$<TARGET_FILE:${BLASLIB}>${BLAS_Fortran_LIB}"
473-
-D LAPACK_LIBRARIES="${LAPACK_LIBRARIES}" )
474-
endif()
475-
else()
476-
if(NOT LATESTLAPACK_FOUND)
477-
add_custom_command( OUTPUT blaspp-cmd APPEND
478-
COMMAND ${CMAKE_COMMAND}
479-
-B "${blaspp_BINARY_DIR}"
480-
-D BLAS_LIBRARIES="${BLAS_LIBRARIES}"
481-
-D LAPACK_LIBRARIES="$<TARGET_FILE:${LAPACKLIB}>${BLAS_Fortran_LIB}" )
482-
else()
483-
add_custom_command( OUTPUT blaspp-cmd APPEND
484-
COMMAND ${CMAKE_COMMAND}
485-
-B "${blaspp_BINARY_DIR}"
486-
-D BLAS_LIBRARIES="${BLAS_LIBRARIES}"
487-
-D LAPACK_LIBRARIES="${LAPACK_LIBRARIES}" )
488-
endif()
489-
endif()
490-
491-
# Setup remaining configuration options and installation
492466
add_custom_command( OUTPUT blaspp-cmd APPEND
493467
COMMAND ${CMAKE_COMMAND}
494-
-B "${blaspp_BINARY_DIR}"
495-
-D CMAKE_INSTALL_PREFIX="${blaspp_BINARY_DIR}"
496-
-D CMAKE_INSTALL_LIBDIR="${PROJECT_BINARY_DIR}/lib"
497-
-D blas_libraries_cached=""
498-
-D lapack_libraries_cached=""
499-
-D build_tests=OFF
500-
-D BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
468+
-B "${blaspp_BINARY_DIR}"
469+
-D CMAKE_INSTALL_PREFIX="${LAPACK_BINARY_DIR}"
470+
-D BLAS_LIBRARIES="${BLAS_LIBS}"
471+
-D LAPACK_LIBRARIES="${LAPACK_LIBS}"
472+
-D build_tests=OFF
473+
-D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
474+
-D BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
475+
501476
COMMAND ${CMAKE_COMMAND}
502477
--build "${blaspp_BINARY_DIR}"
478+
--config ${CMAKE_BUILD_TYPE}
503479
--target install
504480
)
505481

@@ -513,7 +489,7 @@ if (BLAS++ OR LAPACK++)
513489
endif()
514490

515491
if (LAPACK++)
516-
_display_cpp_implementation_msg("LAPACK")
492+
message( STATUS "LAPACK++ enabled; for support, email [email protected]" )
517493

518494
# Check if population has already been performed
519495
FetchContent_GetProperties(lapackpp)
@@ -528,30 +504,20 @@ if (LAPACK++)
528504
WORKING_DIRECTORY "${lapackpp_SOURCE_DIR}"
529505
COMMENT "Building LAPACK++" )
530506

531-
# Set up information about the LAPACK library
532-
if(NOT LATESTLAPACK_FOUND)
533-
add_custom_command( OUTPUT lapackpp-cmd APPEND
534-
COMMAND ${CMAKE_COMMAND}
535-
-B "${lapackpp_BINARY_DIR}"
536-
-D LAPACK_LIBRARIES="$<TARGET_FILE:${LAPACKLIB}>${BLAS_Fortran_LIB}" )
537-
else()
538-
add_custom_command( OUTPUT lapackpp-cmd APPEND
539-
COMMAND ${CMAKE_COMMAND}
540-
-B "${lapackpp_BINARY_DIR}"
541-
-D LAPACK_LIBRARIES="${LAPACK_LIBRARIES}" )
542-
endif()
543-
544507
# Setup remaining configuration options and installation
545508
add_custom_command( OUTPUT lapackpp-cmd APPEND
546509
COMMAND ${CMAKE_COMMAND}
547-
-B "${lapackpp_BINARY_DIR}"
548-
-D CMAKE_INSTALL_PREFIX="${lapackpp_BINARY_DIR}"
549-
-D CMAKE_INSTALL_LIBDIR="${PROJECT_BINARY_DIR}/lib"
550-
-D lapack_libraries_cached=""
551-
-D build_tests=OFF
552-
-D BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
510+
-B "${lapackpp_BINARY_DIR}"
511+
-D CMAKE_INSTALL_PREFIX="${LAPACK_BINARY_DIR}"
512+
-D blaspp_DIR="${PROJECT_BINARY_DIR}/lib/cmake/blaspp"
513+
-D LAPACK_LIBRARIES="${LAPACK_LIBS}"
514+
-D build_tests=OFF
515+
-D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
516+
-D BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
517+
553518
COMMAND ${CMAKE_COMMAND}
554519
--build "${lapackpp_BINARY_DIR}"
520+
--config ${CMAKE_BUILD_TYPE}
555521
--target install
556522
)
557523

@@ -664,37 +630,26 @@ install(FILES
664630
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${LAPACKLIB}-${LAPACK_VERSION}
665631
COMPONENT Development
666632
)
633+
667634
if (LAPACK++)
668635
install(
669636
DIRECTORY "${LAPACK_BINARY_DIR}/lib/"
670637
DESTINATION ${CMAKE_INSTALL_LIBDIR}
671-
FILES_MATCHING REGEX "liblapackpp.(a|so)$"
672-
)
673-
install(
674-
DIRECTORY "${lapackpp_BINARY_DIR}/include/"
675-
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
676-
FILES_MATCHING REGEX "\\.(h|hh)$"
677-
)
678-
install(
679-
FILES "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/lapackpp/lapackppConfig.cmake"
680-
"${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/lapackpp/lapackppConfigVersion.cmake"
681-
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/"
638+
FILES_MATCHING REGEX "lapackpp"
682639
)
683-
684640
endif()
641+
685642
if (BLAS++)
686-
install(
687-
FILES "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/blaspp/blasppConfig.cmake"
688-
"${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/blaspp/blasppConfigVersion.cmake"
689-
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/"
690-
)
691643
install(
692644
DIRECTORY "${LAPACK_BINARY_DIR}/lib/"
693645
DESTINATION ${CMAKE_INSTALL_LIBDIR}
694-
FILES_MATCHING REGEX "libblaspp.(a|so)$"
646+
FILES_MATCHING REGEX "blaspp"
695647
)
648+
endif()
649+
650+
if (BLAS++ OR LAPACK++)
696651
install(
697-
DIRECTORY "${blaspp_BINARY_DIR}/include/"
652+
DIRECTORY "${LAPACK_BINARY_DIR}/include/"
698653
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
699654
FILES_MATCHING REGEX "\\.(h|hh)$"
700655
)

0 commit comments

Comments
 (0)