Skip to content

macOS + cmake with Xcode generator: Metal not detected #5010

@ericwa

Description

@ericwa

macOS 10.15.7
XCode Version 12.4 (12D4e)
5f1558f

I did:

mkdir build
cd build
cmake .. -GXcode

Got the following in the cmake summary:

--   SDL_METAL                   (Wanted: 0): OFF
...
--   SDL_RENDER_METAL            (Wanted: 0): OFF

Excerpt from CMakeFiles/CMakeError.log:

Performing C SOURCE FILE Test HAVE_FRAMEWORK_METAL failed with the following output:
Change Dir: /Users/ericwa/dev/SDL/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/xcodebuild -project CMAKE_TRY_COMPILE.xcodeproj build -target cmTC_e5a6f -parallelizeTargets -configuration Debug -hideShellScriptEnvironment && Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project CMAKE_TRY_COMPILE.xcodeproj build -target cmTC_e5a6f -parallelizeTargets -configuration Debug -hideShellScriptEnvironment

User defaults from command line:
    HideShellScriptEnvironment = YES

note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
CreateBuildDirectory /Users/ericwa/dev/SDL/build/CMakeFiles/CMakeTmp (in target 'cmTC_e5a6f' from project 'CMAKE_TRY_COMPILE')
    cd /Users/ericwa/dev/SDL/build/CMakeFiles/CMakeTmp
    builtin-create-build-directory /Users/ericwa/dev/SDL/build/CMakeFiles/CMakeTmp

CompileC /Users/ericwa/dev/SDL/build/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_e5a6f.build/Objects-normal/x86_64/src.o /Users/ericwa/dev/SDL/build/CMakeFiles/CMakeTmp/src.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler (in target 'cmTC_e5a6f' from project 'CMAKE_TRY_COMPILE')
    cd /Users/ericwa/dev/SDL/build/CMakeFiles/CMakeTmp
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c -target x86_64-apple-macos10.15 -fmessage-length\=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wno-shorten-64-to-32 -Wpointer-sign -Wno-newline-eof -DCMAKE_INTDIR\=\"Debug\" -DHAVE_FRAMEWORK_METAL -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -g -Wno-sign-conversion -Wno-infinite-recursion -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-semicolon-before-method-body -I/Users/ericwa/dev/SDL/build/CMakeFiles/CMakeTmp/Debug/include -I/Users/ericwa/dev/SDL/build/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_e5a6f.build/DerivedSources-normal/x86_64 -I/Users/ericwa/dev/SDL/build/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_e5a6f.build/DerivedSources/x86_64 -I/Users/ericwa/dev/SDL/build/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_e5a6f.build/DerivedSources -F/Users/ericwa/dev/SDL/build/CMakeFiles/CMakeTmp/Debug -idirafter /Users/ericwa/dev/SDL/src/video/khronos -ObjC -MMD -MT dependencies -MF /Users/ericwa/dev/SDL/build/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_e5a6f.build/Objects-normal/x86_64/src.d --serialize-diagnostics /Users/ericwa/dev/SDL/build/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_e5a6f.build/Objects-normal/x86_64/src.dia -c /Users/ericwa/dev/SDL/build/CMakeFiles/CMakeTmp/src.c -o /Users/ericwa/dev/SDL/build/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.build/Debug/cmTC_e5a6f.build/Objects-normal/x86_64/src.o
clang: warning: argument unused during compilation: '-ObjC' [-Wunused-command-line-argument]
In file included from /Users/ericwa/dev/SDL/build/CMakeFiles/CMakeTmp/src.c:3:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.h:9:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLTypes.h:8:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:8:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:492:1: error: expected identifier or '('
@class NSString, Protocol;
^

Appears to be an issue where we're compiling ObjC headers as C.
Going to try changing the check_c_source_compiles to check_objc_source_compiles.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions