Skip to content

Commit

Permalink
Combine -framework arg flags to avoid linker errors
Browse files Browse the repository at this point in the history
  • Loading branch information
russelltg authored and jschwe committed Nov 15, 2023
1 parent b72c8ce commit 21ad90a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cmake/FindRust.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,19 @@ function(_corrosion_determine_libs_new target_triple out_libs)
if(cargo_build_error_message MATCHES "native-static-libs: ([^\r\n]+)\r?\n")
string(REPLACE " " ";" "libs_list" "${CMAKE_MATCH_1}")
set(stripped_lib_list "")

set(was_last_framework OFF)
foreach(lib ${libs_list})
# merge -framework;lib -> "-framework lib" as CMake does de-duplication of link libraries, and -framework prefix is required
if (lib STREQUAL "-framework")
set(was_last_framework ON)
continue()
endif()
if (was_last_framework)
list(APPEND stripped_lib_list "-framework ${lib}")
set(was_last_framework OFF)
continue()
endif()
# Strip leading `-l` (unix) and potential .lib suffix (windows)
string(REGEX REPLACE "^-l" "" "stripped_lib" "${lib}")
string(REGEX REPLACE "\.lib$" "" "stripped_lib" "${stripped_lib}")
Expand Down

0 comments on commit 21ad90a

Please sign in to comment.