-
Notifications
You must be signed in to change notification settings - Fork 2.3k
cmake: fix Metal detection #5011
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Confirmed to work on: macOS 10.15.7 XCode Version 12.4 (12D4e)
So this has gone back and forth over the past few years, e.g. 42c5b4a Can you take a look at the history here and see what makes sense? |
Ahh ok, I will check the history on this. Regarding this comment from the 42c5b4a commit message:
I think I ran into the same problem - when I first tried changing the macro to
For some reason, collapsing the
So that's why I reformatted the |
Our CI seems to have no trouble detecting Metal, either with or without your fix. There must be something more complex going on. https://github.com/libsdl-org/SDL/runs/4338781399?check_suite_focus=true |
I can reproduce that on my mac -it's the i.e.
|
Looking over the history, the patch from #3893 is similar to what I did here, except it used CMake 3.16's The use of I think we're safe from that issue though, because I'm using SDL's internal SDL's
but the problematic Metal check fixed by e294639 was doing:
(Apparently, that had the issue where |
Okay, let's pull this in for 2.0.20. Thanks for researching this! |
Sorry to ask, will this be fixed in 2.0.20 or 2.0.22? Seems it is tagged as 2.0.22 mistakenly? |
This is pushed out to 2.0.22, so we have more time to catch issues with this change. 2.0.20 is going to be released shortly. |
Okay, this is in; we'll reopen if any concerns pop up during the 2.0.22 dev cycle! |
Maybe we also need the following? Otherwise, it is using our own macro instead diff --git a/cmake/macros.cmake b/cmake/macros.cmake
index 84cb4c6..b825676 100644
--- a/cmake/macros.cmake
+++ b/cmake/macros.cmake
@@ -92,12 +92,16 @@ macro(LISTTOSTRREV _LIST _OUTPUT)
endforeach()
endmacro()
+if(${CMAKE_VERSION} VERSION_LESS "3.16.0")
macro(CHECK_OBJC_SOURCE_COMPILES SOURCE VAR)
set(PREV_REQUIRED_DEFS "${CMAKE_REQUIRED_DEFINITIONS}")
set(CMAKE_REQUIRED_DEFINITIONS "-x objective-c ${PREV_REQUIRED_DEFS}")
CHECK_C_SOURCE_COMPILES(${SOURCE} ${VAR})
set(CMAKE_REQUIRED_DEFINITIONS "${PREV_REQUIRED_DEFS}")
endmacro()
+else()
+ include(CheckOBJCSourceCompiles)
+endif()
if(CMAKE_VERSION VERSION_LESS 3.13.0)
macro(target_link_directories _TARGET _SCOPE) |
PING? Is the patch above OK? |
Sorry, missed this before. Go ahead and commit that patch. |
Patch applied as 686a0f3 |
Hmph, failures in CI with:
Ideas about how to fix from cmake gurus? (Or should I just back it out?) |
Figured out and fixed in git. |
My project does not build for IOS since this change (MacOS build works). I get the following error:
The version just before works fine. |
As of libsdl-org#5011, iOS build started failing with the following error: CMake Error: Error required internal CMake variable not set, cmake may not be built correctly. Missing variable is: CMAKE_OBJC_COMPILE_OBJECT This works around the error by simply skipping the check for iOS, since all iOS devices released after 2013 support Metal. Fixes libsdl-org#5452
As of libsdl-org#5011, iOS build started failing with the following error: CMake Error: Error required internal CMake variable not set, cmake may not be built correctly. Missing variable is: CMAKE_OBJC_COMPILE_OBJECT This works around the error by simply skipping `check_objc_source_compiles` for iOS. Fixes libsdl-org#5452
As of libsdl-org#5011, iOS build started failing with the following error: CMake Error: Error required internal CMake variable not set, cmake may not be built correctly. Missing variable is: CMAKE_OBJC_COMPILE_OBJECT This works around the error by simply skipping `check_objc_source_compiles` for iOS. Fixes libsdl-org#5452
As of libsdl-org#5011, iOS build started failing with the following error: CMake Error: Error required internal CMake variable not set, cmake may not be built correctly. Missing variable is: CMAKE_OBJC_COMPILE_OBJECT This works around the error by simply skipping `check_objc_source_compiles` for iOS. Fixes libsdl-org#5452
Description
Without this change, I was getting errors about ObjC syntax from headers being used in the test program which was being compiled as C.
Confirmed to work on:
macOS 10.15.7
XCode Version 12.4 (12D4e)
Xcode generator (
cmake -GXcode ..
)Existing Issue(s)
Fixes #5010
(I think) fixes #3893