We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2056

Summary: Cmake test for Cocoa fails.
Product: SDL Reporter: MakoEnergy02
Component: videoAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: major    
Priority: P2 CC: icculus, nclack, tn0502, ttimo
Version: 2.0.0   
Hardware: x86_64   
OS: Mac OS X 10.6   
See Also: https://bugzilla.libsdl.org/show_bug.cgi?id=1651
Attachments: small change to fix CHECK_OBJC_SOURCE_COMPILES
Patch for failing to detect Cocoa

Description MakoEnergy02 2013-08-22 23:47:18 UTC
This is related to a post I made on the forums a while back:

http://forums.libsdl.org/viewtopic.php?t=9100&highlight=

I finally got around to trying to troubleshoot this some more and managed to track down the cause of the linker issue being that simply all the files for Cocoa in the video subsystem weren't being added to the project.  Further digging showed it was failing the test that includes "Cocoa/Cocoa.h" to check if it is available.

On a random hunch I tried adding the compile flags to make it play nice with objective-c manually and it worked.  I made the changes to a copy of SDL in my local project repo and they can be seen here:

https://github.com/BlackToppStudios/Mezzanine/commit/c68e480ab6584b8e8b85ba9136d2c169bf92e9d5

I was a little over the top cautious regarding what was in "CMAKE_REQUIRED_FLAGS" at the time and that may not be necessary.  Also I didn't notice until after I made these changes that the function being used to test is "check_objc_source_compiles" and not "check_c_source_compiles" which raises some questions about that cmake methods stability/utilty.

TL;DR: Add "set(CMAKE_REQUIRED_FLAGS "-x objective-c")" prior to the cocoa check in SDL/cmake/sdlchecks.cmake around line 452 and all is good.
Comment 1 Nathan Clack 2013-08-27 00:59:38 UTC
Created attachment 1307 [details]
small change to fix CHECK_OBJC_SOURCE_COMPILES

This fixes Cocoa detection on my system (osx 10.8).  The test was failing due to a linker error; the objc runtime library wasn't being linked in.
Comment 2 Timothee Besset 2013-09-10 15:52:11 UTC
Running into the same problem, Cocoa not detected on OSX 10.8

I applied the fix to the CHECK_OBJC_SOURCE_COMPILES macro that you attached, but the problem persists.
Comment 3 tn0502 2013-10-22 07:32:58 UTC
Created attachment 1391 [details]
Patch for failing to detect Cocoa

I'm attached a patch that fixed the problem for me.
Comment 4 Ryan C. Gordon 2014-02-23 03:30:47 UTC
Taking this bug.

--ryan.
Comment 5 Ryan C. Gordon 2014-02-23 06:12:16 UTC
Fixed this in...

    https://hg.libsdl.org/SDL/rev/bfea1a568a0a

...by removing the Objective-C test entirely. It's a Mac, it has Cocoa, let's not get crazy here.  :)

--ryan.