diff options
author | Markus Mützel <markus.muetzel@gmx.de> | 2022-06-21 14:12:11 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-06-21 16:38:30 (GMT) |
commit | a6066094991bb356ad21d2c59cb8ed614f9abc2f (patch) | |
tree | a7db1e32f8c39be858daab90b7d26b55e6b15843 /Modules | |
parent | 27874273061fa74d3bcc860769fb1eae42eba0fe (diff) | |
download | CMake-a6066094991bb356ad21d2c59cb8ed614f9abc2f.zip CMake-a6066094991bb356ad21d2c59cb8ed614f9abc2f.tar.gz CMake-a6066094991bb356ad21d2c59cb8ed614f9abc2f.tar.bz2 |
FindMPI: Parse '-l:' flags in pkg-config output
With the msmpi package in MSYS2:
$ pkg-config --libs msmpi
-LC:/msys64/mingw64/lib -l:libmsmpi.dll.a
MSYS2-Issue: https://github.com/msys2/MINGW-packages/pull/11839
Fixes: #23620
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/FindMPI.cmake | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index 6b60deb..bca0c10 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -775,7 +775,8 @@ function (_MPI_interrogate_compiler LANG) MPI_LIBNAMES "${MPI_LINK_CMDLINE}") foreach(_MPI_LIB_NAME IN LISTS MPI_LIBNAMES) - string(REGEX REPLACE "^ ?${CMAKE_LINK_LIBRARY_FLAG}" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") + # also match flags starting with "-l:" here + string(REGEX REPLACE "^ ?${CMAKE_LINK_LIBRARY_FLAG}(:lib|:)?" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") string(REPLACE "\"" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}") endforeach() @@ -788,7 +789,7 @@ function (_MPI_interrogate_compiler LANG) set(_MPI_LIB_SUFFIX_REGEX "${CMAKE_STATIC_LIBRARY_SUFFIX}") if(DEFINED CMAKE_IMPORT_LIBRARY_SUFFIX) if(NOT ("${CMAKE_IMPORT_LIBRARY_SUFFIX}" STREQUAL "${CMAKE_STATIC_LIBRARY_SUFFIX}")) - string(APPEND _MPI_SUFFIX_REGEX "|${CMAKE_IMPORT_LIBRARY_SUFFIX}") + string(APPEND _MPI_LIB_SUFFIX_REGEX "|${CMAKE_IMPORT_LIBRARY_SUFFIX}") endif() else() string(APPEND _MPI_LIB_SUFFIX_REGEX "|${CMAKE_SHARED_LIBRARY_SUFFIX}") @@ -798,12 +799,16 @@ function (_MPI_interrogate_compiler LANG) string(REGEX MATCHALL "${_MPI_LIB_NAME_REGEX}" MPI_LIBNAMES "${MPI_LINK_CMDLINE}") foreach(_MPI_LIB_NAME IN LISTS MPI_LIBNAMES) - string(REGEX REPLACE "^ +\"?|\"? +$" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") - get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY) - if(NOT "${_MPI_LIB_PATH}" STREQUAL "") - list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}") - else() - list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}") + # Do not match "-l:" flags + string(REGEX MATCH "^ ?${CMAKE_LINK_LIBRARY_FLAG}:" _MPI_LIB_NAME_TEST "${_MPI_LIB_NAME}") + if(_MPI_LIB_NAME_TEST STREQUAL "") + string(REGEX REPLACE "^ +\"?|\"? +$" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") + get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY) + if(NOT "${_MPI_LIB_PATH}" STREQUAL "") + list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}") + else() + list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}") + endif() endif() endforeach() |