Skip to content
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

Merged
merged 1 commit into from
Nov 3, 2024

Conversation

dpogue
Copy link
Member

@dpogue dpogue commented Aug 6, 2024

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

@dpogue dpogue requested review from colincornaby and Hoikas August 6, 2024 07:39
@dpogue dpogue force-pushed the cmake-metal branch 3 times, most recently from ec7390f to 72e3295 Compare August 6, 2024 08:44
Copy link
Member

@Hoikas Hoikas left a 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.

CMakeLists.txt Show resolved Hide resolved
cmake/CMakeDetermineMetalCompiler.cmake Outdated Show resolved Hide resolved
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})
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of the other language support files built-in to CMake seem to quote the CMAKE_whatever_COMPILER_INIT stuff when they test it 🤷🏼‍♂️

It should be a filepath to a compiler executable, as I understand it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason it should probably be quoted is without the quotes, CMake generally just inserts the contents of the variable directly into the if command. This means if you have a semicolon, CMake starts thinking about lists, and if you have a space, you've begun a new argument to the if command. If the variable is quoted, then none of that applies, and CMake will just test if the path exists.

Welcome to the world of CMake's idiosyncrasies.

cmake/CMakeMetalInformation.cmake Outdated Show resolved Hide resolved
cmake/CMakeMetalInformation.cmake Outdated Show resolved Hide resolved
cmake/CMakeTestMetalCompiler.cmake Outdated Show resolved Hide resolved
cmake/CMakeTestMetalCompiler.cmake Outdated Show resolved Hide resolved
cmake/CMakeTestMetalCompiler.cmake Outdated Show resolved Hide resolved
cmake/CMakeTestMetalCompiler.cmake Outdated Show resolved Hide resolved
@dpogue
Copy link
Member Author

dpogue commented Aug 7, 2024

@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.

@dpogue dpogue force-pushed the cmake-metal branch 2 times, most recently from 0324899 to 7ce9730 Compare August 7, 2024 03:46
@colincornaby
Copy link
Contributor

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.

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.
@dpogue
Copy link
Member Author

dpogue commented Oct 8, 2024

I believe I've resolved all the formatting concerns in the CMake scripts now

@Hoikas Hoikas merged commit 97095e0 into H-uru:master Nov 3, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants