shithub: cstory

Download patch

ref: cf0ee89e93427a69669c34523054d70b4e2701d5
parent: 96f46f33878942bc3187bf7c0b971ab5bf700a88
author: Clownacy <Clownacy@users.noreply.github.com>
date: Wed Apr 1 20:16:43 EDT 2020

Avoid WinMain on Windows

This is a better for GLFW on Windows, and it might have fixed the
long-standing bug where FORCE_LOCAL_LIBS on MSYS2 wouldn't work
because SDL2 would mysteriously fail because of something involving
WinMain.

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,7 +33,7 @@
 
 project(CSE2 LANGUAGES C CXX)
 
-add_executable(CSE2
+add_executable(CSE2 WIN32
 	"${ASSETS_DIRECTORY}/resources/CSE2.rc"
 	"src/ArmsItem.cpp"
 	"src/ArmsItem.h"
@@ -358,6 +358,9 @@
 
 	# Make it so source files are recognized as UTF-8 by MSVC
 	target_compile_options(CSE2 PRIVATE "/utf-8")
+
+	# Use `main` instead of `WinMain`
+	set_target_properties(CSE2 PROPERTIES LINK_FLAGS "/ENTRY:mainCRTStartup")
 endif()
 
 # On Windows, we use native icons instead
@@ -464,11 +467,11 @@
 	elseif(TARGET SDL2::SDL2)
 		# CMake-generated config (Arch, vcpkg, Raspbian)
 		message(STATUS "Using system SDL2 (CMake, dynamic)")
-		target_link_libraries(CSE2 PRIVATE SDL2::SDL2 SDL2::SDL2main)
+		target_link_libraries(CSE2 PRIVATE SDL2::SDL2)
 	elseif(TARGET SDL2::SDL2-static)
 		# CMake-generated config (Arch, vcpkg, Raspbian)
 		message(STATUS "Using system SDL2 (CMake, static)")
-		target_link_libraries(CSE2 PRIVATE SDL2::SDL2-static SDL2::SDL2main)
+		target_link_libraries(CSE2 PRIVATE SDL2::SDL2-static)
 	elseif(SDL2_FOUND)
 		# Autotools-generated config (MSYS2)
 		message(STATUS "Using system SDL2 (Autotools)")
@@ -482,7 +485,7 @@
 				set(LIBC ON CACHE INTERNAL "" FORCE)	# Needed to prevent possible 'symbol already defined' errors
 		endif()
 		add_subdirectory("external/SDL2" EXCLUDE_FROM_ALL)
-		target_link_libraries(CSE2 PRIVATE SDL2-static SDL2main)
+		target_link_libraries(CSE2 PRIVATE SDL2-static)
 	endif()
 endif()