Skip to content

Commit cf04da7

Browse files
Robert Maynardbradking
Robert Maynard
authored andcommitted
FindMPI: make sure computed link flags are not de-duplicated
In commit f7eaa34 (FindMPI: Store imported target link flags as a list instead of a string, 2019-06-14, v3.15.0-rc2~2^2) we used `separate_arguments` to parse the extracted link flags and add them to `INTERFACE_LINK_LIBRARIES`. That property is not meant for link flags and CMake may de-duplicate them. This is particularly problematic for flags like `-Wl,-rpath -Wl,/path1 -Wl,-rpath -Wl,/path2`. In commit 39c572c (FindMPI: Updated to use INTERFACE_LINK_OPTIONS, 2019-06-24) we moved the parsed flags over to `INTERFACE_LINK_OPTIONS`, but that may still perform de-duplication. Avoid the parsing and de-duplication of flags by passing the original string via `SHELL:` instead. Fixes: #19516
1 parent 39c572c commit cf04da7

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

Modules/FindMPI.cmake

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,9 +1143,7 @@ macro(_MPI_create_imported_target LANG)
11431143
set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_DEFINITIONS "${MPI_${LANG}_COMPILE_DEFINITIONS}")
11441144

11451145
if(MPI_${LANG}_LINK_FLAGS)
1146-
separate_arguments(_MPI_${LANG}_LINK_FLAGS NATIVE_COMMAND "${MPI_${LANG}_LINK_FLAGS}")
1147-
set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_LINK_OPTIONS "${_MPI_${LANG}_LINK_FLAGS}")
1148-
unset(_MPI_${LANG}_LINK_FLAGS)
1146+
set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_LINK_OPTIONS "SHELL:${MPI_${LANG}_LINK_FLAGS}")
11491147
endif()
11501148
# If the compiler links MPI implicitly, no libraries will be found as they're contained within
11511149
# CMAKE_<LANG>_IMPLICIT_LINK_LIBRARIES already.

0 commit comments

Comments
 (0)