mirror of https://github.com/encounter/SDL.git
Fixed bug 5366 - cmake build doesn't detect Metal on macOS
Tom Seddon
2nd time lucky, perhaps. patch 2 applies to current HEAD at time of writing - 4eb049c9bb1ca94efe3c40b57beda3169984d0cb from https://github.com/SDL-mirror/SDL.
This basically goes back to what was there originally, but now manually adding "-x objective-c" to the clang command line rather than "-ObjC". clang is then invoked without the "-x c" that was causing the problem, the snippet builds, and Metal is detected. (I had a quick trawl through the cmake code, but I couldn't see where this is handled.)
I was moved to try this after finding SDL's own CHECK_OBJC_SOURCE_COMPILES macro, and noting what it does: 4eb049c9bb/cmake/macros.cmake (L67)
An alternative fix of course would be to use CHECK_OBJC_SOURCE_COMPILES instead of cmake's check_objc_source_compiles - but that had the same problem of getting confused by "return 0;". (Maybe that's because it's a macro? I'll defer to a cmake expert on this one.)
I decided in the end to err on the side of leaving things looking basically the same as they were before my first patch.
This commit is contained in:
parent
475405e036
commit
42c5b4acde
|
@ -32,7 +32,6 @@ include(CheckIncludeFiles)
|
||||||
include(CheckIncludeFile)
|
include(CheckIncludeFile)
|
||||||
include(CheckSymbolExists)
|
include(CheckSymbolExists)
|
||||||
include(CheckCSourceCompiles)
|
include(CheckCSourceCompiles)
|
||||||
include(CheckOBJCSourceCompiles)
|
|
||||||
include(CheckCSourceRuns)
|
include(CheckCSourceRuns)
|
||||||
include(CheckCCompilerFlag)
|
include(CheckCCompilerFlag)
|
||||||
include(CheckTypeSize)
|
include(CheckTypeSize)
|
||||||
|
@ -1802,7 +1801,9 @@ elseif(APPLE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(VIDEO_VULKAN OR VIDEO_METAL OR RENDER_METAL)
|
if(VIDEO_VULKAN OR VIDEO_METAL OR RENDER_METAL)
|
||||||
check_objc_source_compiles("
|
set(ORIG_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
|
||||||
|
set(CMAKE_REQUIRED_FLAGS "-x objective-c ${CMAKE_REQUIRED_FLAGS}")
|
||||||
|
check_c_source_compiles("
|
||||||
#include <AvailabilityMacros.h>
|
#include <AvailabilityMacros.h>
|
||||||
#import <Metal/Metal.h>
|
#import <Metal/Metal.h>
|
||||||
#import <QuartzCore/CAMetalLayer.h>
|
#import <QuartzCore/CAMetalLayer.h>
|
||||||
|
@ -1812,8 +1813,10 @@ elseif(APPLE)
|
||||||
#endif
|
#endif
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
" HAVE_FRAMEWORK_METAL)
|
" HAVE_FRAMEWORK_METAL)
|
||||||
|
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
|
||||||
if(HAVE_FRAMEWORK_METAL)
|
if(HAVE_FRAMEWORK_METAL)
|
||||||
set(SDL_FRAMEWORK_METAL 1)
|
set(SDL_FRAMEWORK_METAL 1)
|
||||||
set(SDL_FRAMEWORK_QUARTZCORE 1)
|
set(SDL_FRAMEWORK_QUARTZCORE 1)
|
||||||
|
|
Loading…
Reference in New Issue