Skip to content

CMake: XCode dependency chain fixes #1730

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

Merged
merged 1 commit into from
Mar 14, 2025
Merged

Conversation

enetheru
Copy link
Collaborator

@enetheru enetheru commented Mar 6, 2025

This has been rebased onto #1733

I was working on the github CI and XCode was failing to compile due to the target dependency chain not meeting their requirements.

Turns out it has other implications for dependency generation that I found when compiling a real extension.

This PR brings the dependency chain inline with XCode's expectations, and simplifies some things.

Fixes #1739

@enetheru enetheru added the cmake label Mar 10, 2025
@enetheru enetheru requested a review from a team as a code owner March 11, 2025 02:27
@enetheru enetheru added the bug This has been identified as a bug label Mar 11, 2025
@enetheru enetheru force-pushed the XCode branch 2 times, most recently from a5d2e9c to 4cf611b Compare March 11, 2025 22:38
Copy link
Collaborator

@dsnopek dsnopek left a comment

Choose a reason for hiding this comment

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

Thanks!

I don't really understand these changes, but I did test them on my M1 Mac Mini using the "Xcode" generator, and it was able to successfully build, both using cmake --build and loading the project in Xcode and building from there

When attempting to generate XCode projects it would fail due to the target dependency chain not meeting expectations.

This PR, adds the required dependency infomation so that the XCode generator works.
@enetheru
Copy link
Collaborator Author

I don't really understand these changes

I'll break it down now that I've re-based it.

XCode generator cannot have two independent targets rely on a generated source file, I think due to a race condition on which target triggers the file generation task, or a trigger when the task is already in progress, or some such.

Both generate_bindings and godot-cpp rely on the same generated files and similarly with generate_doc_source and godot-cpp.

These two extra targets( generate_bindings, generated_doc_source ) are not required to build the code, as the dependency chain from source code generation to library is well defined. But they are handy to have so that the sources can be generated manually. similar to SCons build_library=no but it isnt forced like generate_bindings=yes, I have to figure that one out still if its even necessary.

To satisfy the XCode generator add_dependencies(godot-cpp generate_bindings) creates an explicit dependency between the targets. there is an equal one for the doc_source code.

The remaining changes are simplifications after having grasped this:

  • in godot-cpp.cmake I moved the custom target generation into the generate_bindings function, and added the explicit dependency
  • In the cmake/GodotCPPModule.cmake, other than the above move I move and simplify the definition of the doc_source custom_target generation.
  • In the test/CMakeLists I use the helper function to simplify adding the sources to the godot-cpp-test target.

I hope that helps.

@dsnopek dsnopek merged commit e4bd867 into godotengine:master Mar 14, 2025
11 checks passed
@enetheru enetheru deleted the XCode branch March 14, 2025 22:39
@dsnopek
Copy link
Collaborator

dsnopek commented Mar 17, 2025

Cherry-picked for 4.4 in PR #1745

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This has been identified as a bug cmake
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CMake completely broken when trying to migrate from 4.3 to 4.4
4 participants