shithub: cstory

Download patch

ref: 09fa34cbc77e0c511052037cffe71e0ffa6ec899
parent: bcd883e767526e7e5f4a8fae0c68853ee8ea1e00
author: Clownacy <[email protected]>
date: Sun Apr 5 16:13:24 EDT 2020

Do not link libSDL2main.a

Causes stupid annoying errors and CSE2 doesn't even need it anyway so
wtf

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -474,10 +474,18 @@
 		# pkg-config
 		if (PKG_CONFIG_STATIC_LIBS)
 			message(STATUS "Using system SDL2 (pkg-config, static)")
+			# Do not link libSDL3main.a, otherwise we get weird linker errors about SDL_main not being found.
+			# We don't need SDL2's WinMain->main shim anyway, so we can just ignore it.
+			list(REMOVE_ITEM sdl2_STATIC_CFLAGS "-Dmain=SDL_main")
+			list(REMOVE_ITEM sdl2_STATIC_LDFLAGS "-lSDLmain")
 			target_compile_options(CSE2 PRIVATE ${sdl2_STATIC_CFLAGS})
 			target_link_libraries(CSE2 PRIVATE ${sdl2_STATIC_LDFLAGS})
 		else()
 			message(STATUS "Using system SDL2 (pkg-config, dynamic)")
+			# Do not link libSDL3main.a, otherwise we get weird linker errors about SDL_main not being found.
+			# We don't need SDL2's WinMain->main shim anyway, so we can just ignore it.
+			list(REMOVE_ITEM sdl2_CFLAGS "-Dmain=SDL_main")
+			list(REMOVE_ITEM sdl2_LDFLAGS "-lSDLmain")
 			target_compile_options(CSE2 PRIVATE ${sdl2_CFLAGS})
 			target_link_libraries(CSE2 PRIVATE ${sdl2_LDFLAGS})
 		endif()