Fixed bug 1839 - SDL2 Cmake: VIDEO_COCOA check fails on OS X; VIDEO_COCOA sources aren't compiled.
authorSam Lantinga <slouken@libsdl.org>
Thu, 16 May 2013 00:52:33 -0700
changeset 7182 1089a8a701c3
parent 7181 d35a0936c674
child 7183 5f13cca29fc1
Fixed bug 1839 - SDL2 Cmake: VIDEO_COCOA check fails on OS X; VIDEO_COCOA sources aren't compiled.
cmake/macros.cmake
cmake/sdlchecks.cmake
--- a/cmake/macros.cmake	Thu May 16 00:48:20 2013 -0700
+++ b/cmake/macros.cmake	Thu May 16 00:52:33 2013 -0700
@@ -63,3 +63,11 @@
     set(${_OUTPUT} "${_LPREFIX}${_ITEM} ${${_OUTPUT}}")
   endforeach()
 endmacro()
+
+macro(CHECK_OBJC_SOURCE_COMPILES SOURCE VAR)
+  set(PREV_REQUIRED_DEFS "${CMAKE_REQUIRED_DEFINITIONS}")
+  set(CMAKE_REQUIRED_DEFINITIONS "-ObjC ${PREV_REQUIRED_DEFS}")
+  CHECK_C_SOURCE_COMPILES(${SOURCE} ${VAR})
+  set(CMAKE_REQUIRED_DEFINITIONS "${PREV_REQUIRED_DEFS}")
+endmacro()
+
--- a/cmake/sdlchecks.cmake	Thu May 16 00:48:20 2013 -0700
+++ b/cmake/sdlchecks.cmake	Thu May 16 00:52:33 2013 -0700
@@ -449,11 +449,12 @@
 #
 macro(CheckCOCOA)
   if(VIDEO_COCOA)
-    check_c_source_compiles("
+    check_objc_source_compiles("
         #import <Cocoa/Cocoa.h>
         int main (int argc, char** argv) {}" HAVE_VIDEO_COCOA)
     if(HAVE_VIDEO_COCOA)
       file(GLOB COCOA_SOURCES ${SDL2_SOURCE_DIR}/src/video/cocoa/*.m)
+      set_source_files_properties(${COCOA_SOURCES} PROPERTIES LANGUAGE C)
       set(SOURCE_FILES ${SOURCE_FILES} ${COCOA_SOURCES})
       set(SDL_VIDEO_DRIVER_COCOA 1)
       set(HAVE_SDL_VIDEO TRUE)