Skip to content

Commit 00f51ca

Browse files
Apply most of @mgates3 patch
See mgates3@ecf6f41
1 parent 680cfd8 commit 00f51ca

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
@@ -476,22 +476,8 @@ endif()
476476
option(BLAS++ "Build BLAS++" OFF)
477477
option(LAPACK++ "Build LAPACK++" OFF)
478478

479-
480-
function(_display_cpp_implementation_msg name)
481-
string(TOLOWER ${name} name_lc)
482-
message(STATUS "${name}++ enable")
483-
message(STATUS "----------------")
484-
message(STATUS "Thank you for your interest in ${name}++, a newly developed C++ API for ${name} library")
485-
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.")
486-
message(STATUS "For support ${name}++ related question, please email: [email protected]")
487-
message(STATUS "----------------")
488-
endfunction()
489-
490479
if (BLAS++ OR LAPACK++)
491-
492-
if (BLAS++)
493-
_display_cpp_implementation_msg("BLAS")
494-
endif()
480+
message( STATUS "BLAS++ enabled; for support, email [email protected]" )
495481

496482
# Check if population has already been performed
497483
FetchContent_GetProperties(blaspp)
@@ -500,16 +486,35 @@ if (BLAS++ OR LAPACK++)
500486
FetchContent_Populate(blaspp)
501487
endif()
502488

503-
# For static builds, we may need to link against a Fortran library
504-
set(BLAS_Fortran_LIB "")
505-
if (NOT BLAS_FOUND AND NOT BUILD_SHARED_LIBS)
489+
# Determine Fortran runtime library.
490+
# todo: CMake ought to know this already -- how to access?
491+
set( Fortran_LIB "" )
492+
if (NOT BUILD_SHARED_LIBS)
506493
if (CMAKE_Fortran_COMPILER_ID MATCHES GNU)
507-
set(BLAS_Fortran_LIB ";-lgfortran")
494+
set( Fortran_LIB ";-lgfortran" )
508495
else()
509496
# TODO: This is incomplete. Fill in the other cases.
510-
set(BLAS_Fortran_LIB "")
511497
endif()
512498
endif()
499+
message( DEBUG "Fortran_LIB '${Fortran_LIB}'" )
500+
501+
if (NOT BLAS_FOUND)
502+
# Link with Reference BLAS.
503+
set( BLAS_LIBS "$<TARGET_FILE:${BLASLIB}>${Fortran_LIB}" )
504+
else()
505+
# Link with optimized BLAS.
506+
set( BLAS_LIBS "${BLAS_LIBRARIES}" )
507+
endif()
508+
message( DEBUG "BLAS_LIBS '${BLAS_LIBS}'" )
509+
510+
if (NOT LATESTLAPACK_FOUND)
511+
# Link with Reference LAPACK.
512+
set( LAPACK_LIBS "$<TARGET_FILE:${LAPACKLIB}>${Fortran_LIB}" )
513+
else()
514+
# Link with optimized BLAS.
515+
set( LAPACK_LIBS "${LAPACK_LIBRARIES}" )
516+
endif()
517+
message( DEBUG "LAPACK_LIBS '${LAPACK_LIBS}'" )
513518

514519
# Adds target blaspp
515520
add_custom_target( blaspp ALL DEPENDS blaspp-cmd )
@@ -518,48 +523,19 @@ if (BLAS++ OR LAPACK++)
518523
COMMENT "Building BLAS++" )
519524

520525
# Set up information about the BLAS and LAPACK libraries
521-
if(NOT BLAS_FOUND)
522-
if(NOT LATESTLAPACK_FOUND)
523-
add_custom_command( OUTPUT blaspp-cmd APPEND
524-
COMMAND ${CMAKE_COMMAND}
525-
-B "${blaspp_BINARY_DIR}"
526-
-D BLAS_LIBRARIES="$<TARGET_FILE:${BLASLIB}>${BLAS_Fortran_LIB}"
527-
-D LAPACK_LIBRARIES="$<TARGET_FILE:${LAPACKLIB}>" )
528-
else()
529-
add_custom_command( OUTPUT blaspp-cmd APPEND
530-
COMMAND ${CMAKE_COMMAND}
531-
-B "${blaspp_BINARY_DIR}"
532-
-D BLAS_LIBRARIES="$<TARGET_FILE:${BLASLIB}>${BLAS_Fortran_LIB}"
533-
-D LAPACK_LIBRARIES="${LAPACK_LIBRARIES}" )
534-
endif()
535-
else()
536-
if(NOT LATESTLAPACK_FOUND)
537-
add_custom_command( OUTPUT blaspp-cmd APPEND
538-
COMMAND ${CMAKE_COMMAND}
539-
-B "${blaspp_BINARY_DIR}"
540-
-D BLAS_LIBRARIES="${BLAS_LIBRARIES}"
541-
-D LAPACK_LIBRARIES="$<TARGET_FILE:${LAPACKLIB}>${BLAS_Fortran_LIB}" )
542-
else()
543-
add_custom_command( OUTPUT blaspp-cmd APPEND
544-
COMMAND ${CMAKE_COMMAND}
545-
-B "${blaspp_BINARY_DIR}"
546-
-D BLAS_LIBRARIES="${BLAS_LIBRARIES}"
547-
-D LAPACK_LIBRARIES="${LAPACK_LIBRARIES}" )
548-
endif()
549-
endif()
550-
551-
# Setup remaining configuration options and installation
552526
add_custom_command( OUTPUT blaspp-cmd APPEND
553527
COMMAND ${CMAKE_COMMAND}
554-
-B "${blaspp_BINARY_DIR}"
555-
-D CMAKE_INSTALL_PREFIX="${blaspp_BINARY_DIR}"
556-
-D CMAKE_INSTALL_LIBDIR="${PROJECT_BINARY_DIR}/lib"
557-
-D blas_libraries_cached=""
558-
-D lapack_libraries_cached=""
559-
-D build_tests=OFF
560-
-D BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
528+
-B "${blaspp_BINARY_DIR}"
529+
-D CMAKE_INSTALL_PREFIX="${LAPACK_BINARY_DIR}"
530+
-D BLAS_LIBRARIES="${BLAS_LIBS}"
531+
-D LAPACK_LIBRARIES="${LAPACK_LIBS}"
532+
-D build_tests=OFF
533+
-D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
534+
-D BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
535+
561536
COMMAND ${CMAKE_COMMAND}
562537
--build "${blaspp_BINARY_DIR}"
538+
--config ${CMAKE_BUILD_TYPE}
563539
--target install
564540
)
565541

@@ -573,7 +549,7 @@ if (BLAS++ OR LAPACK++)
573549
endif()
574550

575551
if (LAPACK++)
576-
_display_cpp_implementation_msg("LAPACK")
552+
message( STATUS "LAPACK++ enabled; for support, email [email protected]" )
577553

578554
# Check if population has already been performed
579555
FetchContent_GetProperties(lapackpp)
@@ -588,30 +564,20 @@ if (LAPACK++)
588564
WORKING_DIRECTORY "${lapackpp_SOURCE_DIR}"
589565
COMMENT "Building LAPACK++" )
590566

591-
# Set up information about the LAPACK library
592-
if(NOT LATESTLAPACK_FOUND)
593-
add_custom_command( OUTPUT lapackpp-cmd APPEND
594-
COMMAND ${CMAKE_COMMAND}
595-
-B "${lapackpp_BINARY_DIR}"
596-
-D LAPACK_LIBRARIES="$<TARGET_FILE:${LAPACKLIB}>${BLAS_Fortran_LIB}" )
597-
else()
598-
add_custom_command( OUTPUT lapackpp-cmd APPEND
599-
COMMAND ${CMAKE_COMMAND}
600-
-B "${lapackpp_BINARY_DIR}"
601-
-D LAPACK_LIBRARIES="${LAPACK_LIBRARIES}" )
602-
endif()
603-
604567
# Setup remaining configuration options and installation
605568
add_custom_command( OUTPUT lapackpp-cmd APPEND
606569
COMMAND ${CMAKE_COMMAND}
607-
-B "${lapackpp_BINARY_DIR}"
608-
-D CMAKE_INSTALL_PREFIX="${lapackpp_BINARY_DIR}"
609-
-D CMAKE_INSTALL_LIBDIR="${PROJECT_BINARY_DIR}/lib"
610-
-D lapack_libraries_cached=""
611-
-D build_tests=OFF
612-
-D BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
570+
-B "${lapackpp_BINARY_DIR}"
571+
-D CMAKE_INSTALL_PREFIX="${LAPACK_BINARY_DIR}"
572+
-D blaspp_DIR="${PROJECT_BINARY_DIR}/lib/cmake/blaspp"
573+
-D LAPACK_LIBRARIES="${LAPACK_LIBS}"
574+
-D build_tests=OFF
575+
-D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
576+
-D BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
577+
613578
COMMAND ${CMAKE_COMMAND}
614579
--build "${lapackpp_BINARY_DIR}"
580+
--config ${CMAKE_BUILD_TYPE}
615581
--target install
616582
)
617583

@@ -724,37 +690,26 @@ install(FILES
724690
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${LAPACKLIB}-${LAPACK_VERSION}
725691
COMPONENT Development
726692
)
693+
727694
if (LAPACK++)
728695
install(
729696
DIRECTORY "${LAPACK_BINARY_DIR}/lib/"
730697
DESTINATION ${CMAKE_INSTALL_LIBDIR}
731-
FILES_MATCHING REGEX "liblapackpp.(a|so)$"
732-
)
733-
install(
734-
DIRECTORY "${lapackpp_BINARY_DIR}/include/"
735-
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
736-
FILES_MATCHING REGEX "\\.(h|hh)$"
737-
)
738-
install(
739-
FILES "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/lapackpp/lapackppConfig.cmake"
740-
"${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/lapackpp/lapackppConfigVersion.cmake"
741-
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/"
698+
FILES_MATCHING REGEX "lapackpp"
742699
)
743-
744700
endif()
701+
745702
if (BLAS++)
746-
install(
747-
FILES "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/blaspp/blasppConfig.cmake"
748-
"${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/blaspp/blasppConfigVersion.cmake"
749-
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/"
750-
)
751703
install(
752704
DIRECTORY "${LAPACK_BINARY_DIR}/lib/"
753705
DESTINATION ${CMAKE_INSTALL_LIBDIR}
754-
FILES_MATCHING REGEX "libblaspp.(a|so)$"
706+
FILES_MATCHING REGEX "blaspp"
755707
)
708+
endif()
709+
710+
if (BLAS++ OR LAPACK++)
756711
install(
757-
DIRECTORY "${blaspp_BINARY_DIR}/include/"
712+
DIRECTORY "${LAPACK_BINARY_DIR}/include/"
758713
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
759714
FILES_MATCHING REGEX "\\.(h|hh)$"
760715
)

0 commit comments

Comments
 (0)