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 71821089a8a701c3
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
     1.1 --- a/cmake/macros.cmake	Thu May 16 00:48:20 2013 -0700
     1.2 +++ b/cmake/macros.cmake	Thu May 16 00:52:33 2013 -0700
     1.3 @@ -63,3 +63,11 @@
     1.4      set(${_OUTPUT} "${_LPREFIX}${_ITEM} ${${_OUTPUT}}")
     1.5    endforeach()
     1.6  endmacro()
     1.7 +
     1.8 +macro(CHECK_OBJC_SOURCE_COMPILES SOURCE VAR)
     1.9 +  set(PREV_REQUIRED_DEFS "${CMAKE_REQUIRED_DEFINITIONS}")
    1.10 +  set(CMAKE_REQUIRED_DEFINITIONS "-ObjC ${PREV_REQUIRED_DEFS}")
    1.11 +  CHECK_C_SOURCE_COMPILES(${SOURCE} ${VAR})
    1.12 +  set(CMAKE_REQUIRED_DEFINITIONS "${PREV_REQUIRED_DEFS}")
    1.13 +endmacro()
    1.14 +
     2.1 --- a/cmake/sdlchecks.cmake	Thu May 16 00:48:20 2013 -0700
     2.2 +++ b/cmake/sdlchecks.cmake	Thu May 16 00:52:33 2013 -0700
     2.3 @@ -449,11 +449,12 @@
     2.4  #
     2.5  macro(CheckCOCOA)
     2.6    if(VIDEO_COCOA)
     2.7 -    check_c_source_compiles("
     2.8 +    check_objc_source_compiles("
     2.9          #import <Cocoa/Cocoa.h>
    2.10          int main (int argc, char** argv) {}" HAVE_VIDEO_COCOA)
    2.11      if(HAVE_VIDEO_COCOA)
    2.12        file(GLOB COCOA_SOURCES ${SDL2_SOURCE_DIR}/src/video/cocoa/*.m)
    2.13 +      set_source_files_properties(${COCOA_SOURCES} PROPERTIES LANGUAGE C)
    2.14        set(SOURCE_FILES ${SOURCE_FILES} ${COCOA_SOURCES})
    2.15        set(SDL_VIDEO_DRIVER_COCOA 1)
    2.16        set(HAVE_SDL_VIDEO TRUE)