diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index dd1b03a..1ad4e4e 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -47,7 +47,7 @@ jobs: - name: Install dependencies run: | sudo apt-get update - sudo apt-get install -y ninja-build xvfb xorg-dev libgl1-mesa-dev libglu1-mesa-dev libgl1-mesa-dri + sudo apt-get install -y xorg-dev libgl1-mesa-dev libglu1-mesa-dev libgl1-mesa-dri shell: bash - name: Install GCC 16 diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index 67207cc..2bca1f9 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -32,11 +32,6 @@ jobs: with: submodules: 'recursive' - - name: Install ninja-build - run: | - brew install ninja - shell: bash - - name: Setup ccache uses: hendrikmuhs/ccache-action@v1.2 with: diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml index 84c051e..945e0ad 100644 --- a/.github/workflows/ci-windows.yml +++ b/.github/workflows/ci-windows.yml @@ -130,15 +130,6 @@ jobs: working-directory: build/tests run: | set -o pipefail - if [ "${{ matrix.compiler }}" == "gcc" ]; then - # For MinGW - copy DLLs directly (no PATH manipulation) - GCC_DIR=$(dirname $(which gcc)) - echo "GCC directory: $GCC_DIR" - echo "Copying DLLs from $GCC_DIR" - cp "$GCC_DIR"/libgcc*.dll . 2>/dev/null || echo "No libgcc DLLs found" - cp "$GCC_DIR"/libstdc*.dll . 2>/dev/null || echo "No libstdc DLLs found" - cp "$GCC_DIR"/libwinpthread*.dll . 2>/dev/null || echo "No libwinpthread DLLs found" - fi echo "Running gamecoe tests" ./gamecoe_tests.exe | tee test_output.log # testcoe currently reports a skipped test as failed. Narrow this back to skips only diff --git a/cmake/utils.cmake b/cmake/utils.cmake index e1c7a2b..eed5abd 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -13,4 +13,46 @@ function(copy_gamecoe_assets_to_build_root exe) COMMENT "[gamecoe] Copying gamecoe assets to build root" WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) +endfunction() + +# Automatically copies required MinGW DLLs to target directory on Windows + +function(gamecoe_copy_mingw_dlls_to_target target_name) + if(WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + message(STATUS "[gamecoe] Setting up automatic MinGW DLL copying for ${target_name}") + + # Get the compiler directory + get_filename_component(COMPILER_DIR ${CMAKE_CXX_COMPILER} DIRECTORY) + + # List of DLLs that might be needed for MinGW + set(MINGW_DLLS + libgcc_s_seh-1.dll # 64-bit SEH exception handling + libgcc_s_dw2-1.dll # 32-bit Dwarf2 exception handling + libstdc++-6.dll # C++ standard library + libwinpthread-1.dll # Threading support + ) + + foreach(dll ${MINGW_DLLS}) + set(dll_path "${COMPILER_DIR}/${dll}") + if(EXISTS "${dll_path}") + message(STATUS "[gamecoe] Found ${dll} at ${dll_path}") + add_custom_command(TARGET ${target_name} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${dll_path}" + "$/${dll}" + COMMENT "[gamecoe] Copying MinGW DLL: ${dll}" + VERBATIM + ) + else() + message(STATUS "[gamecoe] ${dll} not found, skipping") + endif() + endforeach() + endif() +endfunction() + +# Alternative function for multiple targets +function(gamecoe_copy_mingw_dlls_to_targets) + foreach(target_name ${ARGN}) + gamecoe_copy_mingw_dlls_to_target(${target_name}) + endforeach() endfunction() \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0509841..c7b3d49 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -37,6 +37,8 @@ if(WIN32) COMMAND_EXPAND_LISTS) endif() +gamecoe_copy_mingw_dlls_to_target(gamecoe_tests) + # game::create() needs soundcoe's default audio root to exist next to the test binary if(GAMECOE_USE_SOUNDCOE) add_custom_command(TARGET gamecoe_tests POST_BUILD