From 44bcec240bed6980fdc6f38e7238371d7d3c1f1b Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 14 Apr 2021 13:58:47 -0400 Subject: ci: factor out Intel Compiler common configure script Share common content between the intelclassic and inteloneapi variants. --- .gitlab/ci/configure_intelclassic_makefiles.cmake | 2 +- .gitlab/ci/configure_intelcompiler_common.cmake | 1 + .gitlab/ci/configure_inteloneapi_makefiles.cmake | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 .gitlab/ci/configure_intelcompiler_common.cmake diff --git a/.gitlab/ci/configure_intelclassic_makefiles.cmake b/.gitlab/ci/configure_intelclassic_makefiles.cmake index 20863a2..469b825 100644 --- a/.gitlab/ci/configure_intelclassic_makefiles.cmake +++ b/.gitlab/ci/configure_intelclassic_makefiles.cmake @@ -1 +1 @@ -include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/configure_intelcompiler_common.cmake") diff --git a/.gitlab/ci/configure_intelcompiler_common.cmake b/.gitlab/ci/configure_intelcompiler_common.cmake new file mode 100644 index 0000000..20863a2 --- /dev/null +++ b/.gitlab/ci/configure_intelcompiler_common.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") diff --git a/.gitlab/ci/configure_inteloneapi_makefiles.cmake b/.gitlab/ci/configure_inteloneapi_makefiles.cmake index 20863a2..469b825 100644 --- a/.gitlab/ci/configure_inteloneapi_makefiles.cmake +++ b/.gitlab/ci/configure_inteloneapi_makefiles.cmake @@ -1 +1 @@ -include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/configure_intelcompiler_common.cmake") -- cgit v0.12 From 116edb5c04790e5d9127b5cfb51943eebd5d33d8 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 14 Apr 2021 13:33:42 -0400 Subject: Find{BLAS,LAPACK}: Revert bad refactoring of internal CHECK_*_LIBRARIES Refactoring in commit 4c74c86f40 (FindBLAS/LAPACK: Add support for the Fujitsu SSL2 library, 2021-01-27) was done in order to support calling `find_library` on the dependencies as well as the candidate libraries. However, it broke a few things: * Intel MKL's BLAS/LAPACK are no longer found. We specify their dependencies using `-l...` flags, so we should not try to use `find_library` for them. * The dependencies are repeated because we accumulate them in the `find_library` search loop and then append them at the end too. Revert the incorrect part of the refactoring. Retain the flags part needed for the Fujitsu vendor. Fixes: #22056 --- Modules/FindBLAS.cmake | 16 +++++++++------- Modules/FindLAPACK.cmake | 16 +++++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 510f47d..fafbc0f 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -236,23 +236,25 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _add endif() list(APPEND _extaddlibdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - foreach(_library ${_list} ${_threadlibs}) + foreach(_library ${_list}) if(_library MATCHES "^-Wl,--(start|end)-group$") # Respect linker flags like --start/end-group (required by MKL) set(${LIBRARIES} ${${LIBRARIES}} "${_library}") else() - string(REGEX REPLACE "[^A-Za-z0-9]" "_" _lib_var "${_library}") - set(_combined_name ${_combined_name}_${_lib_var}) + set(_combined_name ${_combined_name}_${_library}) + if(NOT "${_threadlibs}" STREQUAL "") + set(_combined_name ${_combined_name}_threadlibs) + endif() if(_libraries_work) - find_library(${_prefix}_${_lib_var}_LIBRARY + find_library(${_prefix}_${_library}_LIBRARY NAMES ${_library} NAMES_PER_DIR PATHS ${_extaddlibdir} PATH_SUFFIXES ${_subdirs} ) - mark_as_advanced(${_prefix}_${_lib_var}_LIBRARY) - set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_lib_var}_LIBRARY}) - set(_libraries_work ${${_prefix}_${_lib_var}_LIBRARY}) + mark_as_advanced(${_prefix}_${_library}_LIBRARY) + set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) + set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) endif() endif() endforeach() diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index a5b16ca..74e1c5d 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -218,23 +218,25 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _a endif() list(APPEND _extaddlibdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - foreach(_library ${_list} ${_threadlibs}) + foreach(_library ${_list}) if(_library MATCHES "^-Wl,--(start|end)-group$") # Respect linker flags like --start/end-group (required by MKL) set(${LIBRARIES} ${${LIBRARIES}} "${_library}") else() - string(REGEX REPLACE "[^A-Za-z0-9]" "_" _lib_var "${_library}") - set(_combined_name ${_combined_name}_${_lib_var}) + set(_combined_name ${_combined_name}_${_library}) + if(NOT "${_threadlibs}" STREQUAL "") + set(_combined_name ${_combined_name}_threadlibs) + endif() if(_libraries_work) - find_library(${_prefix}_${_lib_var}_LIBRARY + find_library(${_prefix}_${_library}_LIBRARY NAMES ${_library} NAMES_PER_DIR PATHS ${_extaddlibdir} PATH_SUFFIXES ${_subdirs} ) - mark_as_advanced(${_prefix}_${_lib_var}_LIBRARY) - set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_lib_var}_LIBRARY}) - set(_libraries_work ${${_prefix}_${_lib_var}_LIBRARY}) + mark_as_advanced(${_prefix}_${_library}_LIBRARY) + set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) + set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) endif() endif() endforeach() -- cgit v0.12 From e4649d1d159de9c1a6f4833d6f9a5a44e5c4781b Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 14 Apr 2021 13:53:03 -0400 Subject: Find{BLAS,LAPACK}: Add test case covering Intel MKL --- .gitlab/ci/configure_debian10_aarch64_ninja.cmake | 4 ++-- .gitlab/ci/configure_debian10_ninja.cmake | 4 ++-- .gitlab/ci/configure_fedora33_makefiles.cmake | 4 ++-- .gitlab/ci/configure_intelcompiler_common.cmake | 3 +++ Tests/FindBLAS/CMakeLists.txt | 22 ++++++++++++---------- Tests/FindBLAS/Test/CMakeLists.txt | 6 ++++++ Tests/FindLAPACK/CMakeLists.txt | 22 ++++++++++++---------- Tests/FindLAPACK/Test/CMakeLists.txt | 6 ++++++ 8 files changed, 45 insertions(+), 26 deletions(-) diff --git a/.gitlab/ci/configure_debian10_aarch64_ninja.cmake b/.gitlab/ci/configure_debian10_aarch64_ninja.cmake index 1ad3ac4..f665f7d 100644 --- a/.gitlab/ci/configure_debian10_aarch64_ninja.cmake +++ b/.gitlab/ci/configure_debian10_aarch64_ninja.cmake @@ -1,5 +1,5 @@ set(CMake_TEST_FindALSA "ON" CACHE BOOL "") -set(CMake_TEST_FindBLAS "ON" CACHE BOOL "") +set(CMake_TEST_FindBLAS "All" CACHE STRING "") set(CMake_TEST_FindBoost "ON" CACHE BOOL "") set(CMake_TEST_FindBoost_Python "ON" CACHE BOOL "") set(CMake_TEST_FindBZip2 "ON" CACHE BOOL "") @@ -23,7 +23,7 @@ set(CMake_TEST_FindIconv "ON" CACHE BOOL "") set(CMake_TEST_FindIntl "ON" CACHE BOOL "") set(CMake_TEST_FindJPEG "ON" CACHE BOOL "") set(CMake_TEST_FindJsonCpp "ON" CACHE BOOL "") -set(CMake_TEST_FindLAPACK "ON" CACHE BOOL "") +set(CMake_TEST_FindLAPACK "All" CACHE STRING "") set(CMake_TEST_FindLibArchive "ON" CACHE BOOL "") set(CMake_TEST_FindLibinput "ON" CACHE BOOL "") set(CMake_TEST_FindLibLZMA "ON" CACHE BOOL "") diff --git a/.gitlab/ci/configure_debian10_ninja.cmake b/.gitlab/ci/configure_debian10_ninja.cmake index d925387..9de3013 100644 --- a/.gitlab/ci/configure_debian10_ninja.cmake +++ b/.gitlab/ci/configure_debian10_ninja.cmake @@ -1,5 +1,5 @@ set(CMake_TEST_FindALSA "ON" CACHE BOOL "") -set(CMake_TEST_FindBLAS "ON" CACHE BOOL "") +set(CMake_TEST_FindBLAS "All" CACHE STRING "") set(CMake_TEST_FindBoost "ON" CACHE BOOL "") set(CMake_TEST_FindBoost_Python "ON" CACHE BOOL "") set(CMake_TEST_FindBZip2 "ON" CACHE BOOL "") @@ -23,7 +23,7 @@ set(CMake_TEST_FindIconv "ON" CACHE BOOL "") set(CMake_TEST_FindIntl "ON" CACHE BOOL "") set(CMake_TEST_FindJPEG "ON" CACHE BOOL "") set(CMake_TEST_FindJsonCpp "ON" CACHE BOOL "") -set(CMake_TEST_FindLAPACK "ON" CACHE BOOL "") +set(CMake_TEST_FindLAPACK "All" CACHE STRING "") set(CMake_TEST_FindLibArchive "ON" CACHE BOOL "") set(CMake_TEST_FindLibinput "ON" CACHE BOOL "") set(CMake_TEST_FindLibLZMA "ON" CACHE BOOL "") diff --git a/.gitlab/ci/configure_fedora33_makefiles.cmake b/.gitlab/ci/configure_fedora33_makefiles.cmake index 882ffcd..4143134 100644 --- a/.gitlab/ci/configure_fedora33_makefiles.cmake +++ b/.gitlab/ci/configure_fedora33_makefiles.cmake @@ -1,5 +1,5 @@ set(CMake_TEST_FindALSA "ON" CACHE BOOL "") -set(CMake_TEST_FindBLAS "ON" CACHE BOOL "") +set(CMake_TEST_FindBLAS "All" CACHE STRING "") set(CMake_TEST_FindBoost "ON" CACHE BOOL "") set(CMake_TEST_FindBoost_Python "ON" CACHE BOOL "") set(CMake_TEST_FindBZip2 "ON" CACHE BOOL "") @@ -23,7 +23,7 @@ set(CMake_TEST_FindIconv "ON" CACHE BOOL "") set(CMake_TEST_FindIntl "ON" CACHE BOOL "") set(CMake_TEST_FindJPEG "ON" CACHE BOOL "") set(CMake_TEST_FindJsonCpp "ON" CACHE BOOL "") -set(CMake_TEST_FindLAPACK "ON" CACHE BOOL "") +set(CMake_TEST_FindLAPACK "All" CACHE STRING "") set(CMake_TEST_FindLibArchive "ON" CACHE BOOL "") set(CMake_TEST_FindLibinput "ON" CACHE BOOL "") set(CMake_TEST_FindLibLZMA "ON" CACHE BOOL "") diff --git a/.gitlab/ci/configure_intelcompiler_common.cmake b/.gitlab/ci/configure_intelcompiler_common.cmake index 20863a2..be3d15b 100644 --- a/.gitlab/ci/configure_intelcompiler_common.cmake +++ b/.gitlab/ci/configure_intelcompiler_common.cmake @@ -1 +1,4 @@ +set(CMake_TEST_FindBLAS "Intel10_64lp" CACHE STRING "") +set(CMake_TEST_FindLAPACK "Intel10_64lp" CACHE STRING "") + include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") diff --git a/Tests/FindBLAS/CMakeLists.txt b/Tests/FindBLAS/CMakeLists.txt index 667195d..47ec568 100644 --- a/Tests/FindBLAS/CMakeLists.txt +++ b/Tests/FindBLAS/CMakeLists.txt @@ -1,10 +1,12 @@ -add_test(NAME FindBLAS.Test COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindBLAS/Test" - "${CMake_BINARY_DIR}/Tests/FindBLAS/Test" - ${build_generator_args} - --build-project TestFindBLAS - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) +foreach(vendor IN LISTS CMake_TEST_FindBLAS) + add_test(NAME FindBLAS.Test_${vendor} COMMAND + ${CMAKE_CTEST_COMMAND} -C $ + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindBLAS/Test" + "${CMake_BINARY_DIR}/Tests/FindBLAS/Test_${vendor}" + ${build_generator_args} + --build-project TestFindBLAS + --build-options ${build_options} -DBLA_VENDOR=${vendor} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $ + ) +endforeach() diff --git a/Tests/FindBLAS/Test/CMakeLists.txt b/Tests/FindBLAS/Test/CMakeLists.txt index 59418f3..1bebf8e 100644 --- a/Tests/FindBLAS/Test/CMakeLists.txt +++ b/Tests/FindBLAS/Test/CMakeLists.txt @@ -11,3 +11,9 @@ add_test(NAME test_tgt COMMAND test_tgt) add_executable(test_var main.c) target_link_libraries(test_var PRIVATE ${BLAS_LIBRARIES}) add_test(NAME test_var COMMAND test_var) + +if(BLA_VENDOR STREQUAL "Intel10_64lp") + if(NOT BLAS_LIBRARIES MATCHES "^[^;]*mkl_intel_lp64") + message(FATAL_ERROR "BLAS_LIBRARIES does not start in mkl_intel_lp64:\n ${BLAS_LIBRARIES}") + endif() +endif() diff --git a/Tests/FindLAPACK/CMakeLists.txt b/Tests/FindLAPACK/CMakeLists.txt index 2081d59..5e2ea7a 100644 --- a/Tests/FindLAPACK/CMakeLists.txt +++ b/Tests/FindLAPACK/CMakeLists.txt @@ -1,10 +1,12 @@ -add_test(NAME FindLAPACK.Test COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindLAPACK/Test" - "${CMake_BINARY_DIR}/Tests/FindLAPACK/Test" - ${build_generator_args} - --build-project TestFindLAPACK - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) +foreach(vendor IN LISTS CMake_TEST_FindLAPACK) + add_test(NAME FindLAPACK.Test_${vendor} COMMAND + ${CMAKE_CTEST_COMMAND} -C $ + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindLAPACK/Test" + "${CMake_BINARY_DIR}/Tests/FindLAPACK/Test_${vendor}" + ${build_generator_args} + --build-project TestFindLAPACK + --build-options ${build_options} -DBLA_VENDOR=${vendor} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $ + ) +endforeach() diff --git a/Tests/FindLAPACK/Test/CMakeLists.txt b/Tests/FindLAPACK/Test/CMakeLists.txt index 8afa36a..67fb9bd 100644 --- a/Tests/FindLAPACK/Test/CMakeLists.txt +++ b/Tests/FindLAPACK/Test/CMakeLists.txt @@ -11,3 +11,9 @@ add_test(NAME test_tgt COMMAND test_tgt) add_executable(test_var main.c) target_link_libraries(test_var PRIVATE ${LAPACK_LIBRARIES}) add_test(NAME test_var COMMAND test_var) + +if(BLA_VENDOR STREQUAL "Intel10_64lp") + if(NOT LAPACK_LIBRARIES MATCHES "^[^;]*mkl_intel_lp64") + message(FATAL_ERROR "LAPACK_LIBRARIES does not start in mkl_intel_lp64:\n ${LAPACK_LIBRARIES}") + endif() +endif() -- cgit v0.12 From d248401d12a4766dad7ddd69ee3f2947960f6f5f Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 14 Apr 2021 14:11:39 -0400 Subject: Find{BLAS,LAPACK}: Simplify appending to list of libraries --- Modules/FindBLAS.cmake | 6 +++--- Modules/FindLAPACK.cmake | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index fafbc0f..84d7074 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -239,7 +239,7 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _add foreach(_library ${_list}) if(_library MATCHES "^-Wl,--(start|end)-group$") # Respect linker flags like --start/end-group (required by MKL) - set(${LIBRARIES} ${${LIBRARIES}} "${_library}") + list(APPEND ${LIBRARIES} "${_library}") else() set(_combined_name ${_combined_name}_${_library}) if(NOT "${_threadlibs}" STREQUAL "") @@ -253,7 +253,7 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _add PATH_SUFFIXES ${_subdirs} ) mark_as_advanced(${_prefix}_${_library}_LIBRARY) - set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) + list(APPEND ${LIBRARIES} ${${_prefix}_${_library}_LIBRARY}) set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) endif() endif() @@ -279,7 +279,7 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _add if("${_list}" STREQUAL "") set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES") else() - set(${LIBRARIES} ${${LIBRARIES}} ${_threadlibs}) + list(APPEND ${LIBRARIES} ${_threadlibs}) endif() else() set(${LIBRARIES} FALSE) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 74e1c5d..ea49629 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -221,7 +221,7 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _a foreach(_library ${_list}) if(_library MATCHES "^-Wl,--(start|end)-group$") # Respect linker flags like --start/end-group (required by MKL) - set(${LIBRARIES} ${${LIBRARIES}} "${_library}") + list(APPEND ${LIBRARIES} "${_library}") else() set(_combined_name ${_combined_name}_${_library}) if(NOT "${_threadlibs}" STREQUAL "") @@ -235,7 +235,7 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _a PATH_SUFFIXES ${_subdirs} ) mark_as_advanced(${_prefix}_${_library}_LIBRARY) - set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) + list(APPEND ${LIBRARIES} ${${_prefix}_${_library}_LIBRARY}) set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) endif() endif() @@ -262,7 +262,7 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _a if("${_list}${_blas}" STREQUAL "") set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES") else() - set(${LIBRARIES} ${${LIBRARIES}} ${_blas} ${_threadlibs}) + list(APPEND ${LIBRARIES} ${_blas} ${_threadlibs}) endif() else() set(${LIBRARIES} FALSE) -- cgit v0.12 From a5a6ac7033f107626e76eb09ccd86bf49ccdbecd Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 14 Apr 2021 14:12:33 -0400 Subject: Find{BLAS,LAPACK}: Clarify name of internal argument for dependencies --- Modules/FindBLAS.cmake | 10 +++++----- Modules/FindLAPACK.cmake | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 84d7074..a61d71f 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -208,7 +208,7 @@ endif() # TODO: move this stuff to a separate module -macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _addlibdir _subdirs) +macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir _subdirs) # This macro checks for the existence of the combination of fortran libraries # given by _list. If the combination is found, this macro checks (using the # Check_Fortran_Function_Exists macro) whether can link against that library @@ -242,8 +242,8 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _add list(APPEND ${LIBRARIES} "${_library}") else() set(_combined_name ${_combined_name}_${_library}) - if(NOT "${_threadlibs}" STREQUAL "") - set(_combined_name ${_combined_name}_threadlibs) + if(NOT "${_deps}" STREQUAL "") + set(_combined_name ${_combined_name}_deps) endif() if(_libraries_work) find_library(${_prefix}_${_library}_LIBRARY @@ -265,7 +265,7 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _add endforeach() if(_libraries_work) # Test this combination of libraries. - set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_threadlibs}) + set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_deps}) if(CMAKE_Fortran_COMPILER_LOADED) check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS) else() @@ -279,7 +279,7 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _add if("${_list}" STREQUAL "") set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES") else() - list(APPEND ${LIBRARIES} ${_threadlibs}) + list(APPEND ${LIBRARIES} ${_deps}) endif() else() set(${LIBRARIES} FALSE) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index ea49629..239a438 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -190,7 +190,7 @@ endmacro() # TODO: move this stuff to a separate module -macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _addlibdir _subdirs _blas) +macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir _subdirs _blas) # This macro checks for the existence of the combination of fortran libraries # given by _list. If the combination is found, this macro checks (using the # Check_Fortran_Function_Exists macro) whether can link against that library @@ -224,8 +224,8 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _a list(APPEND ${LIBRARIES} "${_library}") else() set(_combined_name ${_combined_name}_${_library}) - if(NOT "${_threadlibs}" STREQUAL "") - set(_combined_name ${_combined_name}_threadlibs) + if(NOT "${_deps}" STREQUAL "") + set(_combined_name ${_combined_name}_deps) endif() if(_libraries_work) find_library(${_prefix}_${_library}_LIBRARY @@ -248,7 +248,7 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _a endforeach() if(_libraries_work) # Test this combination of libraries. - set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas} ${_threadlibs}) + set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas} ${_deps}) if(CMAKE_Fortran_COMPILER_LOADED) check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS) else() @@ -262,7 +262,7 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _a if("${_list}${_blas}" STREQUAL "") set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES") else() - list(APPEND ${LIBRARIES} ${_blas} ${_threadlibs}) + list(APPEND ${LIBRARIES} ${_blas} ${_deps}) endif() else() set(${LIBRARIES} FALSE) -- cgit v0.12 From a57c4eef76d623078fe7ff718951a71da000a499 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 14 Apr 2021 14:14:46 -0400 Subject: Find{BLAS,LAPACK}: Convert internal CHECK_*_LIBRARIES to functions --- Modules/FindBLAS.cmake | 37 ++++++++++++++++--------------------- Modules/FindLAPACK.cmake | 42 ++++++++++++++++-------------------------- 2 files changed, 32 insertions(+), 47 deletions(-) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index a61d71f..0ad5d8c 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -208,22 +208,16 @@ endif() # TODO: move this stuff to a separate module -macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir _subdirs) - # This macro checks for the existence of the combination of fortran libraries - # given by _list. If the combination is found, this macro checks (using the - # Check_Fortran_Function_Exists macro) whether can link against that library - # combination using the name of a routine given by _name using the linker - # flags given by _flags. If the combination of libraries is found and passes - # the link test, LIBRARIES is set to the list of complete library paths that - # have been found. Otherwise, LIBRARIES is set to FALSE. - - # N.B. _prefix is the prefix applied to the names of all cached variables that - # are generated internally and marked advanced by this macro. - # _addlibdir is a list of additional search paths. _subdirs is a list of path - # suffixes to be used by find_library(). +function(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir _subdirs) + # This function checks for the existence of the combination of libraries + # given by _list. If the combination is found, this checks whether can link + # against that library combination using the name of a routine given by _name + # using the linker flags given by _flags. If the combination of libraries is + # found and passes the link test, ${LIBRARIES} is set to the list of complete + # library paths that have been found. Otherwise, ${LIBRARIES} is set to FALSE. set(_libraries_work TRUE) - set(${LIBRARIES}) + set(_libraries) set(_combined_name) set(_extaddlibdir "${_addlibdir}") @@ -239,7 +233,7 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir foreach(_library ${_list}) if(_library MATCHES "^-Wl,--(start|end)-group$") # Respect linker flags like --start/end-group (required by MKL) - list(APPEND ${LIBRARIES} "${_library}") + list(APPEND _libraries "${_library}") else() set(_combined_name ${_combined_name}_${_library}) if(NOT "${_deps}" STREQUAL "") @@ -253,7 +247,7 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir PATH_SUFFIXES ${_subdirs} ) mark_as_advanced(${_prefix}_${_library}_LIBRARY) - list(APPEND ${LIBRARIES} ${${_prefix}_${_library}_LIBRARY}) + list(APPEND _libraries ${${_prefix}_${_library}_LIBRARY}) set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) endif() endif() @@ -265,7 +259,7 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir endforeach() if(_libraries_work) # Test this combination of libraries. - set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_deps}) + set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${_libraries} ${_deps}) if(CMAKE_Fortran_COMPILER_LOADED) check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS) else() @@ -277,14 +271,15 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir if(_libraries_work) if("${_list}" STREQUAL "") - set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES") + set(_libraries "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES") else() - list(APPEND ${LIBRARIES} ${_deps}) + list(APPEND _libraries ${_deps}) endif() else() - set(${LIBRARIES} FALSE) + set(_libraries FALSE) endif() -endmacro() + set(${LIBRARIES} "${_libraries}" PARENT_SCOPE) +endfunction() set(BLAS_LINKER_FLAGS) set(BLAS_LIBRARIES) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 239a438..2c74c6e 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -190,22 +190,16 @@ endmacro() # TODO: move this stuff to a separate module -macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir _subdirs _blas) - # This macro checks for the existence of the combination of fortran libraries - # given by _list. If the combination is found, this macro checks (using the - # Check_Fortran_Function_Exists macro) whether can link against that library - # combination using the name of a routine given by _name using the linker - # flags given by _flags. If the combination of libraries is found and passes - # the link test, LIBRARIES is set to the list of complete library paths that - # have been found. Otherwise, LIBRARIES is set to FALSE. - - # N.B. _prefix is the prefix applied to the names of all cached variables that - # are generated internally and marked advanced by this macro. - # _addlibdir is a list of additional search paths. _subdirs is a list of path - # suffixes to be used by find_library(). +function(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir _subdirs _blas) + # This function checks for the existence of the combination of libraries + # given by _list. If the combination is found, this checks whether can link + # against that library combination using the name of a routine given by _name + # using the linker flags given by _flags. If the combination of libraries is + # found and passes the link test, ${LIBRARIES} is set to the list of complete + # library paths that have been found. Otherwise, ${LIBRARIES} is set to FALSE. set(_libraries_work TRUE) - set(${LIBRARIES}) + set(_libraries) set(_combined_name) set(_extaddlibdir "${_addlibdir}") @@ -221,7 +215,7 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibd foreach(_library ${_list}) if(_library MATCHES "^-Wl,--(start|end)-group$") # Respect linker flags like --start/end-group (required by MKL) - list(APPEND ${LIBRARIES} "${_library}") + list(APPEND _libraries "${_library}") else() set(_combined_name ${_combined_name}_${_library}) if(NOT "${_deps}" STREQUAL "") @@ -235,12 +229,11 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibd PATH_SUFFIXES ${_subdirs} ) mark_as_advanced(${_prefix}_${_library}_LIBRARY) - list(APPEND ${LIBRARIES} ${${_prefix}_${_library}_LIBRARY}) + list(APPEND _libraries ${${_prefix}_${_library}_LIBRARY}) set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) endif() endif() endforeach() - unset(_library) foreach(_flag ${_flags}) string(REGEX REPLACE "[^A-Za-z0-9]" "_" _flag_var "${_flag}") @@ -248,7 +241,7 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibd endforeach() if(_libraries_work) # Test this combination of libraries. - set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas} ${_deps}) + set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${_libraries} ${_blas} ${_deps}) if(CMAKE_Fortran_COMPILER_LOADED) check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS) else() @@ -260,18 +253,15 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibd if(_libraries_work) if("${_list}${_blas}" STREQUAL "") - set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES") + set(_libraries "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES") else() - list(APPEND ${LIBRARIES} ${_blas} ${_deps}) + list(APPEND _libraries ${_blas} ${_deps}) endif() else() - set(${LIBRARIES} FALSE) + set(_libraries FALSE) endif() - - unset(_extaddlibdir) - unset(_libraries_work) - unset(_combined_name) -endmacro() + set(${LIBRARIES} "${_libraries}" PARENT_SCOPE) +endfunction() macro(_lapack_find_dependency dep) set(_lapack_quiet_arg) -- cgit v0.12 From 98ef6632d9f7de15472246ccde76a749be0d37ca Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 14 Apr 2021 14:18:25 -0400 Subject: Find{BLAS,LAPACK}: Generalize recognition of dependencies as link flags --- Modules/FindBLAS.cmake | 4 ++-- Modules/FindLAPACK.cmake | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 0ad5d8c..61e92c9 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -231,8 +231,8 @@ function(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlib list(APPEND _extaddlibdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") foreach(_library ${_list}) - if(_library MATCHES "^-Wl,--(start|end)-group$") - # Respect linker flags like --start/end-group (required by MKL) + if(_library MATCHES "^-") + # Respect linker flags as-is (required by MKL) list(APPEND _libraries "${_library}") else() set(_combined_name ${_combined_name}_${_library}) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 2c74c6e..11bd411 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -213,8 +213,8 @@ function(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addl list(APPEND _extaddlibdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") foreach(_library ${_list}) - if(_library MATCHES "^-Wl,--(start|end)-group$") - # Respect linker flags like --start/end-group (required by MKL) + if(_library MATCHES "^-") + # Respect linker flags as-is (required by MKL) list(APPEND _libraries "${_library}") else() set(_combined_name ${_combined_name}_${_library}) -- cgit v0.12 From dcd604ee621e191acf9e91faab8e47507184d7e9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 14 Apr 2021 14:46:49 -0400 Subject: Find{BLAS,LAPACK}: Make library variable names more robust --- Modules/FindBLAS.cmake | 11 ++++++----- Modules/FindLAPACK.cmake | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 61e92c9..c23e41b 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -235,20 +235,21 @@ function(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlib # Respect linker flags as-is (required by MKL) list(APPEND _libraries "${_library}") else() - set(_combined_name ${_combined_name}_${_library}) + string(REGEX REPLACE "[^A-Za-z0-9]" "_" _lib_var "${_library}") + set(_combined_name ${_combined_name}_${_lib_var}) if(NOT "${_deps}" STREQUAL "") set(_combined_name ${_combined_name}_deps) endif() if(_libraries_work) - find_library(${_prefix}_${_library}_LIBRARY + find_library(${_prefix}_${_lib_var}_LIBRARY NAMES ${_library} NAMES_PER_DIR PATHS ${_extaddlibdir} PATH_SUFFIXES ${_subdirs} ) - mark_as_advanced(${_prefix}_${_library}_LIBRARY) - list(APPEND _libraries ${${_prefix}_${_library}_LIBRARY}) - set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) + mark_as_advanced(${_prefix}_${_lib_var}_LIBRARY) + list(APPEND _libraries ${${_prefix}_${_lib_var}_LIBRARY}) + set(_libraries_work ${${_prefix}_${_lib_var}_LIBRARY}) endif() endif() endforeach() diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 11bd411..d89c40d 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -217,20 +217,21 @@ function(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addl # Respect linker flags as-is (required by MKL) list(APPEND _libraries "${_library}") else() - set(_combined_name ${_combined_name}_${_library}) + string(REGEX REPLACE "[^A-Za-z0-9]" "_" _lib_var "${_library}") + set(_combined_name ${_combined_name}_${_lib_var}) if(NOT "${_deps}" STREQUAL "") set(_combined_name ${_combined_name}_deps) endif() if(_libraries_work) - find_library(${_prefix}_${_library}_LIBRARY + find_library(${_prefix}_${_lib_var}_LIBRARY NAMES ${_library} NAMES_PER_DIR PATHS ${_extaddlibdir} PATH_SUFFIXES ${_subdirs} ) - mark_as_advanced(${_prefix}_${_library}_LIBRARY) - list(APPEND _libraries ${${_prefix}_${_library}_LIBRARY}) - set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) + mark_as_advanced(${_prefix}_${_lib_var}_LIBRARY) + list(APPEND _libraries ${${_prefix}_${_lib_var}_LIBRARY}) + set(_libraries_work ${${_prefix}_${_lib_var}_LIBRARY}) endif() endif() endforeach() -- cgit v0.12