File tree 2 files changed +9
-2
lines changed
2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -27,10 +27,14 @@ FetchContent_Declare(
27
27
28
28
# Only build the shared library for SDL2
29
29
set (BUILD_SHARED_LIBS ON )
30
- set (SDL2_DISABLE_SDL2MAIN ON CACHE BOOL "" FORCE)
31
30
set (SDL2_DISABLE_UNINSTALL ON CACHE BOOL "" FORCE)
32
31
set (SDL_TEST_ENABLED_BY_DEFAULT OFF )
33
32
33
+ # SDL main is only needed for desktop apps (more specifically Windows)
34
+ if (IOS OR ANDROID)
35
+ set (SDL2_DISABLE_SDL2MAIN ON CACHE BOOL "" FORCE)
36
+ endif ()
37
+
34
38
# Make sure debug libs have the same name as release ones
35
39
set (SDL_CMAKE_DEBUG_POSTFIX "" )
36
40
set (SDL2IMAGE_DEBUG_POSTFIX "" )
@@ -71,6 +75,7 @@ elseif(ANDROID)
71
75
add_library ( ${PROJECT_NAME} SHARED ${SOURCE_FILES} )
72
76
else ()
73
77
add_executable ( ${PROJECT_NAME} ${SOURCE_FILES} )
78
+ target_link_libraries ( ${PROJECT_NAME} SDL2main )
74
79
endif ()
75
80
76
81
target_link_libraries ( ${PROJECT_NAME} SDL2 SDL2_image )
Original file line number Diff line number Diff line change @@ -28,4 +28,6 @@ cmake ..
28
28
cmake --build .
29
29
cd ..
30
30
./build/hello_sdl2
31
- ```
31
+ ```
32
+
33
+ The binary might be under its specific configuration, like ` build/Debug/hello_sdl2 ` or ` build/Release/hello_sdl2 `
You can’t perform that action at this time.
0 commit comments