-
Notifications
You must be signed in to change notification settings - Fork 81
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
Allow building macOS client with Makefiles/Ninja #1611
base: master
Are you sure you want to change the base?
Conversation
ec7390f
to
72e3295
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense and looks good to me, just some formatting nitpicks.
|
||
execute_process(COMMAND xcrun --find metal | ||
OUTPUT_VARIABLE _xcrun_out OUTPUT_STRIP_TRAILING_WHITESPACE | ||
ERROR_VARIABLE _xcrun_err RESULT_VARIABLE _xcrun_result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slight preference for the closing )
to be on a newline.
if(CMAKE_Metal_FLAGS_ENV_INIT) | ||
set(CMAKE_Metal_COMPILER_ARG1 "${CMAKE_Metal_FLAGS_ENV_INIT}" CACHE STRING "Arguments to the Metal compiler") | ||
endif() | ||
if(NOT EXISTS ${CMAKE_Metal_COMPILER_INIT}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if ${CMAKE_Metal_COMPILER_INIT}
should be quoted?
# CMAKE_(LANG)_COMPILE_OBJECT | ||
# CMAKE_(LANG)_LINK_EXECUTABLE | ||
|
||
include (CMakeCommonLanguageInclude) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include (CMakeCommonLanguageInclude) | |
include(CMakeCommonLanguageInclude) |
|
||
if(NOT CMAKE_Metal_COMPILE_OBJECT) | ||
set(CMAKE_Metal_COMPILE_OBJECT | ||
"<CMAKE_Metal_COMPILER> -c <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> <SOURCE>") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slight preference for the closing )
to be on a newline.
return() | ||
endif() | ||
|
||
include (CMakeTestCompilerCommon) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include (CMakeTestCompilerCommon) | |
include(CMakeTestCompilerCommon) |
"# error \"The CMAKE_Metal_COMPILER is not a Metal compiler\"\n" | ||
"#endif\n" | ||
"#import <metal_stdlib>\n" | ||
"using namespace metal;\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slight preference for the closing )
to be on a newline.
# Puts test result in cache variable. | ||
try_compile(CMAKE_Metal_COMPILER_WORKS | ||
SOURCE_FROM_VAR testMetalCompiler.metal __TestCompiler_testMetalCompilerSource | ||
OUTPUT_VARIABLE __CMAKE_Metal_COMPILER_OUTPUT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slight preference for the closing )
to be on a newline.
message(FATAL_ERROR "The Metal compiler\n \"${CMAKE_Metal_COMPILER}\"\n" | ||
"is not able to compile a simple test program.\nIt fails " | ||
"with the following output:\n ${_output}\n\n" | ||
"CMake will not be able to correctly generate this project.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slight preference for the closing )
to be on a newline.
@Hoikas The 5 new CMake files are from my https://github.com/dpogue/CMake-MetalShaderSupport project, and are based on files used internally by CMake for language detection/support (and the inconsistent formatting that CMake uses internally). If we feel strongly about the code style here, I can update them, but I'd like to also make those changes in my "upstream" repo to keep things consistent for updating/diffing. I didn't see a good way to bring these over without just copying them, and I don't think it's worth the hassle of another git submodule for them. |
This removes the strict requirement to use the Xcode project generator, but still requires the Xcode build tools (and specifically the Metal compiler) to be installed. I expect that our official stance will always be that the Xcode project generator is the recommended and supported way to do macOS builds, but any day I don't have to launch Xcode is a good day.
I pulled this down, checked the Xcode output, and built. Looks good to me. |
This removes the strict requirement to use the Xcode project generator, but still requires the Xcode build tools (and specifically the Metal compiler) to be installed. With these changes, I was able to build and launch plClient.app locally with a Makefile build, and it rendered as expected (so I'm assuming the Metal shaders are working).
I expect that our official stance will always be that the Xcode project generator is the recommended and supported way to do macOS builds, but any day I don't have to launch Xcode is a good day.
Note: the new CMake files came from https://github.com/dpogue/CMake-MetalShaderSupport