Commit b6591200 authored by Brad King's avatar Brad King 💬 Committed by Kitware Robot
Browse files

Merge topic 'FindBLAS-FindLAPACK'

dcd604ee Find{BLAS,LAPACK}: Make library variable names more robust
98ef6632 Find{BLAS,LAPACK}: Generalize recognition of dependencies as link flags
a57c4eef Find{BLAS,LAPACK}: Convert internal CHECK_*_LIBRARIES to functions
a5a6ac70 Find{BLAS,LAPACK}: Clarify name of internal argument for dependencies
d248401d Find{BLAS,LAPACK}: Simplify appending to list of libraries
e4649d1d Find{BLAS,LAPACK}: Add test case covering Intel MKL
116edb5c Find{BLAS,LAPACK}: Revert bad refactoring of internal CHECK_*_LIBRARIES
44bcec24

 ci: factor out Intel Compiler common configure script
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !6005
parents c7edf432 dcd604ee
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 "")
......
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 "")
......
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 "")
......
include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/configure_intelcompiler_common.cmake")
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")
include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/configure_intelcompiler_common.cmake")
......@@ -208,22 +208,16 @@ endif()
# TODO: move this stuff to a separate module
macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _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}")
......@@ -236,13 +230,16 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _add
endif()
list(APPEND _extaddlibdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
foreach(_library ${_list} ${_threadlibs})
if(_library MATCHES "^-Wl,--(start|end)-group$")
# Respect linker flags like --start/end-group (required by MKL)
set(${LIBRARIES} ${${LIBRARIES}} "${_library}")
foreach(_library ${_list})
if(_library MATCHES "^-")
# Respect linker flags as-is (required by MKL)
list(APPEND _libraries "${_library}")
else()
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}_${_lib_var}_LIBRARY
NAMES ${_library}
......@@ -251,7 +248,7 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _add
PATH_SUFFIXES ${_subdirs}
)
mark_as_advanced(${_prefix}_${_lib_var}_LIBRARY)
set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_lib_var}_LIBRARY})
list(APPEND _libraries ${${_prefix}_${_lib_var}_LIBRARY})
set(_libraries_work ${${_prefix}_${_lib_var}_LIBRARY})
endif()
endif()
......@@ -263,7 +260,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()
......@@ -275,14 +272,15 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _add
if(_libraries_work)
if("${_list}" STREQUAL "")
set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES")
set(_libraries "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES")
else()
set(${LIBRARIES} ${${LIBRARIES}} ${_threadlibs})
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)
......
......@@ -190,22 +190,16 @@ endmacro()
# TODO: move this stuff to a separate module
macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _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}")
......@@ -218,13 +212,16 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _a
endif()
list(APPEND _extaddlibdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
foreach(_library ${_list} ${_threadlibs})
if(_library MATCHES "^-Wl,--(start|end)-group$")
# Respect linker flags like --start/end-group (required by MKL)
set(${LIBRARIES} ${${LIBRARIES}} "${_library}")
foreach(_library ${_list})
if(_library MATCHES "^-")
# Respect linker flags as-is (required by MKL)
list(APPEND _libraries "${_library}")
else()
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}_${_lib_var}_LIBRARY
NAMES ${_library}
......@@ -233,12 +230,11 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _a
PATH_SUFFIXES ${_subdirs}
)
mark_as_advanced(${_prefix}_${_lib_var}_LIBRARY)
set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_lib_var}_LIBRARY})
list(APPEND _libraries ${${_prefix}_${_lib_var}_LIBRARY})
set(_libraries_work ${${_prefix}_${_lib_var}_LIBRARY})
endif()
endif()
endforeach()
unset(_library)
foreach(_flag ${_flags})
string(REGEX REPLACE "[^A-Za-z0-9]" "_" _flag_var "${_flag}")
......@@ -246,7 +242,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()
......@@ -258,18 +254,15 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _a
if(_libraries_work)
if("${_list}${_blas}" STREQUAL "")
set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES")
set(_libraries "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES")
else()
set(${LIBRARIES} ${${LIBRARIES}} ${_blas} ${_threadlibs})
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)
......
add_test(NAME FindBLAS.Test COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--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 $<CONFIGURATION>
)
foreach(vendor IN LISTS CMake_TEST_FindBLAS)
add_test(NAME FindBLAS.Test_${vendor} COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--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 $<CONFIGURATION>
)
endforeach()
......@@ -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()
add_test(NAME FindLAPACK.Test COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--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 $<CONFIGURATION>
)
foreach(vendor IN LISTS CMake_TEST_FindLAPACK)
add_test(NAME FindLAPACK.Test_${vendor} COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--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 $<CONFIGURATION>
)
endforeach()
......@@ -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()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment