Commit 653e433c08eaf48648211bca5f4148db10fa8b19

Anonymous Maarten 2022-09-27T03:15:04

cmake: only add -Wl,--undefined=WinMain when building an executable

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
diff --git a/sdl2-config.cmake.in b/sdl2-config.cmake.in
index 446357f..5d6cf43 100644
--- a/sdl2-config.cmake.in
+++ b/sdl2-config.cmake.in
@@ -80,12 +80,12 @@ if(EXISTS "${_sdl2main_library}")
       if(CMAKE_SIZEOF_VOID_P EQUAL 4)
         set_target_properties(SDL2::SDL2main
           PROPERTIES
-            INTERFACE_LINK_OPTIONS "-Wl,--undefined=_WinMain@16"
+            INTERFACE_LINK_OPTIONS "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:-Wl,--undefined=_WinMain@16>"
         )
       else()
         set_target_properties(SDL2::SDL2main
           PROPERTIES
-            INTERFACE_LINK_OPTIONS "-Wl,--undefined=WinMain"
+            INTERFACE_LINK_OPTIONS "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:-Wl,--undefined=WinMain>"
         )
       endif()
     endif()