Implement proper DLL resolution for MXE builds

This commit is contained in:
OpenSauce04 2026-04-20 23:24:46 +01:00 committed by OpenSauce
parent 644a181aff
commit 0ce2a30d20
3 changed files with 16 additions and 8 deletions

3
.gitmodules vendored
View file

@ -106,3 +106,6 @@
[submodule "externals/libretro-common"]
path = externals/libretro-common/libretro-common
url = https://github.com/libretro/libretro-common.git
[submodule "dllwalker"]
path = externals/dllwalker
url = https://github.com/azahar-emu/dllwalker

1
externals/dllwalker vendored Submodule

@ -0,0 +1 @@
Subproject commit 0c35d5de533eb82480dce2a211112517f69010d4

View file

@ -49,19 +49,23 @@ if (APPLE)
endif()
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" AND WIN32 AND MINGW)
# TODO: This is placeholder bullshit, we need to find out a way to do actual dependency resolution.
# Can we use Wine maybe? -OS
set(EXTRA_LIBS /mxe/usr/x86_64-w64-mingw32.shared/bin/*.dll )
# TODO: Do this for all executables, not just citra_meta
# TODO: Don't hardcode MXE directory to root?
set(dllwalker_command "${CMAKE_SOURCE_DIR}/externals/dllwalker/dllwalker.rb"
$<TARGET_FILE:citra_meta>
/mxe/usr/x86_64-w64-mingw32.shared/bin/
/mxe/usr/x86_64-w64-mingw32.shared/qt6/bin/)
set(dll_list_filename "${CMAKE_CURRENT_BINARY_DIR}/required_dlls_list.txt")
add_custom_command(TARGET citra_meta POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:citra_meta> ${EXTRA_LIBS} $<TARGET_FILE_DIR:citra_meta>
COMMAND ${dllwalker_command} > ${dll_list_filename}
)
add_custom_command(TARGET citra_meta POST_BUILD
COMMAND cat ${dll_list_filename} | xargs -I {} ${CMAKE_COMMAND} -E copy {} $<TARGET_FILE_DIR:citra_meta>
COMMAND ${CMAKE_COMMAND} -E make_directory "$<TARGET_FILE_DIR:citra_meta>/plugins/"
COMMAND ${CMAKE_COMMAND} -E copy_directory /mxe/usr/x86_64-w64-mingw32.shared/qt6/plugins/ "$<TARGET_FILE_DIR:citra_meta>/plugins/"
COMMAND_EXPAND_LISTS
DEPENDS ${dll_list_filename}
)
add_custom_command(TARGET citra_meta POST_BUILD
COMMAND_EXPAND_LISTS
)
unset(EXTRA_LIBS)
endif()
target_link_libraries(citra_meta PRIVATE citra_common fmt)