Skip to content

Commit 5db3c7d

Browse files
weslleyspereiraWeslley da Silva Pereira
authored andcommitted
Apply @mgates3's patch and add BUILD_TYPE to BLAS++ and LAPACK++
See mgates3@ecf6f41
1 parent 3426961 commit 5db3c7d

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
@@ -15,12 +15,12 @@ include(FetchContent)
1515
FetchContent_Declare(
1616
blaspp
1717
GIT_REPOSITORY https://github.com/icl-utk-edu/blaspp
18-
GIT_TAG f8f983d5b45a8f366aae41fbe9888b14cbae20f8 # v2023.08.25
18+
GIT_TAG 91dd418fa910498cc03dee397826099914cc3185 # v2023.08.25 +
1919
)
2020
FetchContent_Declare(
2121
lapackpp
2222
GIT_REPOSITORY https://github.com/icl-utk-edu/lapackpp
23-
GIT_TAG 62680a16a9aba2a426e3d089dd13e18bfd140c74 # v2023.08.25
23+
GIT_TAG 88088c33cd9467475e8f139f42d158620f11e64d # v2023.08.25 +
2424
)
2525

2626
# Allow setting a prefix for the library names
@@ -402,22 +402,8 @@ endif()
402402
option(BLAS++ "Build BLAS++" OFF)
403403
option(LAPACK++ "Build LAPACK++" OFF)
404404

405-
406-
function(_display_cpp_implementation_msg name)
407-
string(TOLOWER ${name} name_lc)
408-
message(STATUS "${name}++ enable")
409-
message(STATUS "----------------")
410-
message(STATUS "Thank you for your interest in ${name}++, a newly developed C++ API for ${name} library")
411-
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.")
412-
message(STATUS "For support ${name}++ related question, please email: [email protected]")
413-
message(STATUS "----------------")
414-
endfunction()
415-
416405
if (BLAS++ OR LAPACK++)
417-
418-
if (BLAS++)
419-
_display_cpp_implementation_msg("BLAS")
420-
endif()
406+
message( STATUS "BLAS++ enabled; for support, email [email protected]" )
421407

422408
# Check if population has already been performed
423409
FetchContent_GetProperties(blaspp)
@@ -426,16 +412,35 @@ if (BLAS++ OR LAPACK++)
426412
FetchContent_Populate(blaspp)
427413
endif()
428414

429-
# For static builds, we may need to link against a Fortran library
430-
set(BLAS_Fortran_LIB "")
431-
if (NOT BLAS_FOUND AND NOT BUILD_SHARED_LIBS)
415+
# Determine Fortran runtime library.
416+
# todo: CMake ought to know this already -- how to access?
417+
set( Fortran_LIB "" )
418+
if (NOT BUILD_SHARED_LIBS)
432419
if (CMAKE_Fortran_COMPILER_ID MATCHES GNU)
433-
set(BLAS_Fortran_LIB ";-lgfortran")
420+
set( Fortran_LIB ";-lgfortran" )
434421
else()
435422
# TODO: This is incomplete. Fill in the other cases.
436-
set(BLAS_Fortran_LIB "")
437423
endif()
438424
endif()
425+
message( DEBUG "Fortran_LIB '${Fortran_LIB}'" )
426+
427+
if (NOT BLAS_FOUND)
428+
# Link with Reference BLAS.
429+
set( BLAS_LIBS "$<TARGET_FILE:${BLASLIB}>${Fortran_LIB}" )
430+
else()
431+
# Link with optimized BLAS.
432+
set( BLAS_LIBS "${BLAS_LIBRARIES}" )
433+
endif()
434+
message( DEBUG "BLAS_LIBS '${BLAS_LIBS}'" )
435+
436+
if (NOT LATESTLAPACK_FOUND)
437+
# Link with Reference LAPACK.
438+
set( LAPACK_LIBS "$<TARGET_FILE:${LAPACKLIB}>${Fortran_LIB}" )
439+
else()
440+
# Link with optimized BLAS.
441+
set( LAPACK_LIBS "${LAPACK_LIBRARIES}" )
442+
endif()
443+
message( DEBUG "LAPACK_LIBS '${LAPACK_LIBS}'" )
439444

440445
# Adds target blaspp
441446
add_custom_target( blaspp ALL DEPENDS blaspp-cmd )
@@ -444,48 +449,19 @@ if (BLAS++ OR LAPACK++)
444449
COMMENT "Building BLAS++" )
445450

446451
# Set up information about the BLAS and LAPACK libraries
447-
if(NOT BLAS_FOUND)
448-
if(NOT LATESTLAPACK_FOUND)
449-
add_custom_command( OUTPUT blaspp-cmd APPEND
450-
COMMAND ${CMAKE_COMMAND}
451-
-B "${blaspp_BINARY_DIR}"
452-
-D BLAS_LIBRARIES="$<TARGET_FILE:${BLASLIB}>${BLAS_Fortran_LIB}"
453-
-D LAPACK_LIBRARIES="$<TARGET_FILE:${LAPACKLIB}>" )
454-
else()
455-
add_custom_command( OUTPUT blaspp-cmd APPEND
456-
COMMAND ${CMAKE_COMMAND}
457-
-B "${blaspp_BINARY_DIR}"
458-
-D BLAS_LIBRARIES="$<TARGET_FILE:${BLASLIB}>${BLAS_Fortran_LIB}"
459-
-D LAPACK_LIBRARIES="${LAPACK_LIBRARIES}" )
460-
endif()
461-
else()
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="${BLAS_LIBRARIES}"
467-
-D LAPACK_LIBRARIES="$<TARGET_FILE:${LAPACKLIB}>${BLAS_Fortran_LIB}" )
468-
else()
469-
add_custom_command( OUTPUT blaspp-cmd APPEND
470-
COMMAND ${CMAKE_COMMAND}
471-
-B "${blaspp_BINARY_DIR}"
472-
-D BLAS_LIBRARIES="${BLAS_LIBRARIES}"
473-
-D LAPACK_LIBRARIES="${LAPACK_LIBRARIES}" )
474-
endif()
475-
endif()
476-
477-
# Setup remaining configuration options and installation
478452
add_custom_command( OUTPUT blaspp-cmd APPEND
479453
COMMAND ${CMAKE_COMMAND}
480-
-B "${blaspp_BINARY_DIR}"
481-
-D CMAKE_INSTALL_PREFIX="${blaspp_BINARY_DIR}"
482-
-D CMAKE_INSTALL_LIBDIR="${PROJECT_BINARY_DIR}/lib"
483-
-D blas_libraries_cached=""
484-
-D lapack_libraries_cached=""
485-
-D build_tests=OFF
486-
-D BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
454+
-B "${blaspp_BINARY_DIR}"
455+
-D CMAKE_INSTALL_PREFIX="${LAPACK_BINARY_DIR}"
456+
-D BLAS_LIBRARIES="${BLAS_LIBS}"
457+
-D LAPACK_LIBRARIES="${LAPACK_LIBS}"
458+
-D build_tests=OFF
459+
-D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
460+
-D BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
461+
487462
COMMAND ${CMAKE_COMMAND}
488463
--build "${blaspp_BINARY_DIR}"
464+
--config ${CMAKE_BUILD_TYPE}
489465
--target install
490466
)
491467

@@ -499,7 +475,7 @@ if (BLAS++ OR LAPACK++)
499475
endif()
500476

501477
if (LAPACK++)
502-
_display_cpp_implementation_msg("LAPACK")
478+
message( STATUS "LAPACK++ enabled; for support, email [email protected]" )
503479

504480
# Check if population has already been performed
505481
FetchContent_GetProperties(lapackpp)
@@ -514,30 +490,20 @@ if (LAPACK++)
514490
WORKING_DIRECTORY "${lapackpp_SOURCE_DIR}"
515491
COMMENT "Building LAPACK++" )
516492

517-
# Set up information about the LAPACK library
518-
if(NOT LATESTLAPACK_FOUND)
519-
add_custom_command( OUTPUT lapackpp-cmd APPEND
520-
COMMAND ${CMAKE_COMMAND}
521-
-B "${lapackpp_BINARY_DIR}"
522-
-D LAPACK_LIBRARIES="$<TARGET_FILE:${LAPACKLIB}>${BLAS_Fortran_LIB}" )
523-
else()
524-
add_custom_command( OUTPUT lapackpp-cmd APPEND
525-
COMMAND ${CMAKE_COMMAND}
526-
-B "${lapackpp_BINARY_DIR}"
527-
-D LAPACK_LIBRARIES="${LAPACK_LIBRARIES}" )
528-
endif()
529-
530493
# Setup remaining configuration options and installation
531494
add_custom_command( OUTPUT lapackpp-cmd APPEND
532495
COMMAND ${CMAKE_COMMAND}
533-
-B "${lapackpp_BINARY_DIR}"
534-
-D CMAKE_INSTALL_PREFIX="${lapackpp_BINARY_DIR}"
535-
-D CMAKE_INSTALL_LIBDIR="${PROJECT_BINARY_DIR}/lib"
536-
-D lapack_libraries_cached=""
537-
-D build_tests=OFF
538-
-D BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
496+
-B "${lapackpp_BINARY_DIR}"
497+
-D CMAKE_INSTALL_PREFIX="${LAPACK_BINARY_DIR}"
498+
-D blaspp_DIR="${PROJECT_BINARY_DIR}/lib/cmake/blaspp"
499+
-D LAPACK_LIBRARIES="${LAPACK_LIBS}"
500+
-D build_tests=OFF
501+
-D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
502+
-D BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
503+
539504
COMMAND ${CMAKE_COMMAND}
540505
--build "${lapackpp_BINARY_DIR}"
506+
--config ${CMAKE_BUILD_TYPE}
541507
--target install
542508
)
543509

@@ -650,37 +616,26 @@ install(FILES
650616
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${LAPACKLIB}-${LAPACK_VERSION}
651617
COMPONENT Development
652618
)
619+
653620
if (LAPACK++)
654621
install(
655622
DIRECTORY "${LAPACK_BINARY_DIR}/lib/"
656623
DESTINATION "${CMAKE_INSTALL_LIBDIR}${LAPACK_BINARY_PATH_SUFFIX}"
657-
FILES_MATCHING REGEX "liblapackpp.(a|so)$"
658-
)
659-
install(
660-
DIRECTORY "${lapackpp_BINARY_DIR}/include/"
661-
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
662-
FILES_MATCHING REGEX "\\.(h|hh)$"
663-
)
664-
install(
665-
FILES "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/lapackpp/lapackppConfig.cmake"
666-
"${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/lapackpp/lapackppConfigVersion.cmake"
667-
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/"
624+
FILES_MATCHING REGEX "lapackpp"
668625
)
669-
670626
endif()
627+
671628
if (BLAS++)
672-
install(
673-
FILES "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/blaspp/blasppConfig.cmake"
674-
"${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/blaspp/blasppConfigVersion.cmake"
675-
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/"
676-
)
677629
install(
678630
DIRECTORY "${LAPACK_BINARY_DIR}/lib/"
679631
DESTINATION ${CMAKE_INSTALL_LIBDIR}
680-
FILES_MATCHING REGEX "libblaspp.(a|so)$"
632+
FILES_MATCHING REGEX "blaspp"
681633
)
634+
endif()
635+
636+
if (BLAS++ OR LAPACK++)
682637
install(
683-
DIRECTORY "${blaspp_BINARY_DIR}/include/"
638+
DIRECTORY "${LAPACK_BINARY_DIR}/include/"
684639
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
685640
FILES_MATCHING REGEX "\\.(h|hh)$"
686641
)

0 commit comments

Comments
 (0)