diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index db59071ab..3fd8509f3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -264,11 +264,6 @@ jobs: else CMAKE_EXTRA_ARGS+=('-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded') fi - - # Fix SDL static linking (see linked issues in patch file) - pushd extern/SDL - env EMAIL=root@localhost git am ../SDL-Fix-MSVC-static-runtime-linking.patch - popd elif [ '${{ matrix.config.compiler }}' == 'mingw' ]; then CMAKE_EXTRA_ARGS+=('-DCMAKE_TOOLCHAIN_FILE=scripts/Cross-MinGW-${{ steps.windows-identify.outputs.mingw-target }}.cmake') elif [ '${{ runner.os }}' == 'macOS' ]; then diff --git a/CMakeLists.txt b/CMakeLists.txt index c5fc06e70..769842f33 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -167,8 +167,13 @@ if (SYSTEM_SDL2) endif() message(STATUS "Using system-installed SDL2") else() - set(SDL_SHARED OFF) - set(SDL_STATIC ON) + set(SDL_SHARED OFF CACHE BOOL "Force no dynamically-linked SDL" FORCE) + set(SDL_STATIC ON CACHE BOOL "Force statically-linked SDL" FORCE) + # https://github.com/libsdl-org/SDL/issues/1481 + # On 2014-06-22 17:15:50 +0000, Sam Lantinga wrote: + # If you link SDL statically, you also need to define HAVE_LIBC so it builds with the C runtime that your application uses. + # This should probably go in a FAQ. + set(SDL_LIBC ON CACHE BOOL "Tell SDL that we want it to use our C runtime (required for proper static linking)" FORCE) add_subdirectory(extern/SDL EXCLUDE_FROM_ALL) list(APPEND DEPENDENCIES_INCLUDE_DIRS extern/SDL/include) list(APPEND DEPENDENCIES_LIBRARIES SDL2-static) diff --git a/extern/SDL-Fix-MSVC-static-runtime-linking.patch b/extern/SDL-Fix-MSVC-static-runtime-linking.patch deleted file mode 100644 index 31b9ea619..000000000 --- a/extern/SDL-Fix-MSVC-static-runtime-linking.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 34d3dcd98697af081625ccea7a41a3c47806c4ff Mon Sep 17 00:00:00 2001 -From: OPNA2608 -Date: Mon, 28 Mar 2022 16:43:16 +0200 -Subject: [PATCH] SDL: Fix MSVC static runtime linking - -See https://github.com/libsdl-org/SDL/issues/3662, https://github.com/libsdl-org/SDL/issues/4258. ---- - src/stdlib/SDL_stdlib.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/stdlib/SDL_stdlib.c b/src/stdlib/SDL_stdlib.c -index 9d785aad5..dfac4d7c3 100644 ---- a/src/stdlib/SDL_stdlib.c -+++ b/src/stdlib/SDL_stdlib.c -@@ -550,7 +550,7 @@ __declspec(selectany) int _fltused = 1; - #endif - - /* The optimizer on Visual Studio 2005 and later generates memcpy() and memset() calls */ --#if _MSC_VER >= 1400 -+#if (_MSC_VER >= 1400) && !defined(_MT) - extern void *memcpy(void* dst, const void* src, size_t len); - #pragma intrinsic(memcpy) - -@@ -570,7 +570,7 @@ memset(void *dst, int c, size_t len) - { - return SDL_memset(dst, c, len); - } --#endif /* _MSC_VER >= 1400 */ -+#endif /* (_MSC_VER >= 1400) && !defined(_MT) */ - - #ifdef _M_IX86 - --- -2.33.1 -