Commit b50e42935455f15baae7440e3270557d53711fab

Luca Lolli 2022-09-07T12:21:56

Fix compilation for .m files extension

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 15999d2..ecc74ca 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3224,6 +3224,15 @@ if(PS2)
   target_compile_options(sdl-build-options INTERFACE "-Wno-error=declaration-after-statement")
 endif()
 
+if(APPLE)
+  foreach(SOURCE_FILE ${SOURCE_FILES})
+    get_filename_component(FILE_EXTENSION ${SOURCE_FILE} EXT)
+    if(FILE_EXTENSION STREQUAL "m")
+      set_property(SOURCE ${SOURCE_FILE} APPEND_STRING PROPERTY COMPILE_FLAGS " -x objective-c")
+    endif()
+  endforeach()
+endif()
+
 if(SDL_SHARED)
   add_library(SDL2 SHARED ${SOURCE_FILES} ${VERSION_SOURCES})
   add_dependencies(SDL2 sdl_headers_copy)