Skip to content

Commit

Permalink
buildscript: Only add Rust module deps manually for MSVC debug builds
Browse files Browse the repository at this point in the history
  • Loading branch information
caseif committed Aug 13, 2024
1 parent de1f5fa commit 1a31f19
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions cmake/ConfigureModule.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -330,35 +330,37 @@ function(_argus_configure_module MODULE_PROJECT_DIR ROOT_DIR
# for some reason transitive linker dependencies don't get applied
# correctly specifically in MSVC debug builds, so we manually add them
# as dependencies here via Corrosion
set(seen_libs "")
set(dep_stack "${MODULE_LINKER_DEPS}")
while(NOT "${dep_stack}" STREQUAL "")
list(POP_FRONT dep_stack lib)
if("${lib}" STREQUAL "")
continue()
endif()
if(MSVC AND CMAKE_BUILD_TYPE STREQUAL "Debug")
set(seen_libs "")
set(dep_stack "${MODULE_LINKER_DEPS}")
while(NOT "${dep_stack}" STREQUAL "")
list(POP_FRONT dep_stack lib)
if("${lib}" STREQUAL "")
continue()
endif()

list(FIND seen_libs ${lib} seen_index)
if(NOT seen_index EQUAL -1)
continue()
endif()
list(FIND seen_libs ${lib} seen_index)
if(NOT seen_index EQUAL -1)
continue()
endif()

list(APPEND seen_libs ${lib})
list(APPEND seen_libs ${lib})

if(TARGET ${lib})
get_target_property(target_type ${lib} TYPE)
if(${target_type} STREQUAL "INTERFACE_LIBRARY")
get_target_property(lib_linker_libs ${lib} INTERFACE_LINK_LIBRARIES)
else()
get_target_property(lib_linker_libs ${lib} LINK_LIBRARIES)
endif()
if(NOT "${lib_linker_libs}" STREQUAL "lib_link_libs-NOTFOUND")
list(APPEND dep_stack ${lib_linker_libs})
endif()
if(TARGET ${lib})
get_target_property(target_type ${lib} TYPE)
if(${target_type} STREQUAL "INTERFACE_LIBRARY")
get_target_property(lib_linker_libs ${lib} INTERFACE_LINK_LIBRARIES)
else()
get_target_property(lib_linker_libs ${lib} LINK_LIBRARIES)
endif()
if(NOT "${lib_linker_libs}" STREQUAL "lib_link_libs-NOTFOUND")
list(APPEND dep_stack ${lib_linker_libs})
endif()

corrosion_link_libraries(${PROJECT_NAME} ${lib})
endif()
endwhile()
corrosion_link_libraries(${PROJECT_NAME} ${lib})
endif()
endwhile()
endif()
else()
message(FATAL_ERROR "Only Rust projects are supported as external projects at this time")
endif()
Expand Down

0 comments on commit 1a31f19

Please sign in to comment.