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

CMake: Possible name clashes when depending on godot-cpp through add_subdirectory or FetchContent #1657

Open
enetheru opened this issue Nov 27, 2024 · 0 comments
Labels
bug This has been identified as a bug cmake
Milestone

Comments

@enetheru
Copy link
Contributor

enetheru commented Nov 27, 2024

Godot version

Any

godot-cpp version

a42b363

System information

any

Issue description

CMake is the gift that keeps giving.
While running some testing by separating the godot-cpp-test target into its own repo and fetching the godot-cpp source using the cmake FetchContent mechanism, it was brought to my attention that CMake has no current project level namespace mechanism to prevent target name collisions with adjacent or downstream projects.

This means that any consumers of godot-cpp will have to avoid/manage the target names we have defined ie. template_debug, template_release, editor, and godot-cpp-test.

This stack overflow question summs up the issues and provides adequate reading and resources to understand in more depth.
https://stackoverflow.com/questions/72931527/how-can-i-avoid-clashes-with-targets-imported-with-fetchcontent-makeavailable

This of course isnt a nice way to play in an ecosystem. Godot also provides the target alias mechanism, which we already use for godot-cpp::

I think it would be prudent to change the naming of the internal CMake targets to avoid clashes, something like godot-cpp.<target_name> works nicely.

The test target should also be disabled by default.

Steps to reproduce

To re-produce the issue:
A cmake c++ project
That uses find_package, add_subdirectory, or FetchContent to consume godot-cpp
That names their build targets the same as ours
Or consumes another library with the same target names as ours.

Minimal reproduction project

This issue is encountered when building an extension using cmake, prior to the use of a godot project.

@dsnopek dsnopek added bug This has been identified as a bug cmake labels Nov 28, 2024
@dsnopek dsnopek added this to the 4.x milestone Nov 28, 2024
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

No branches or pull requests

2 participants