Skip to content

Remove cmake_target_namespace and cmake_module_target_namespace properties in CMakeDeps generator - #10099

Merged
memsharded merged 31 commits into
conan-io:developfrom
czoido:cmakedeps_target_name_freedom
Dec 1, 2021
Merged

memsharded merged 31 commits into
conan-io:developfrom
czoido:cmakedeps_target_name_freedom

Conversation

@czoido

@czoido czoido commented Nov 29, 2021

Copy link
Copy Markdown
Contributor

Changelog: Feature: Remove cmake_target_namespace and cmake_module_target_namespace properties.
Changelog: Feature: Allow CMakeDeps to set cmake_target_name property as an absolute target.
Changelog: Feature: Add warning in CMakeDeps generated CMake files when target names collide.
Docs: conan-io/docs#2316

Now CMakeDeps will allow setting an absolute name for the targets. It's also possible to name the target for the root cpp_info and components without namespaces.
If no cmake_target_name is set, then the default generated target is: pkg_name::pkg_name for the root cpp_info and pkg_name::component_name for components (note it will not try to extract the namespace from the root cpp_info to compose the component target name)

supersedes: #10077

#TAGS: slow

Comment thread conan/tools/cmake/cmakedeps/templates/__init__.py Outdated
Comment thread conan/tools/cmake/cmakedeps/templates/__init__.py Outdated
Comment thread conan/tools/cmake/cmakedeps/templates/__init__.py Outdated
Comment thread conan/tools/cmake/cmakedeps/templates/__init__.py
Comment thread conan/tools/cmake/cmakedeps/templates/target_configuration.py Outdated
@lasote

lasote commented Nov 30, 2021

Copy link
Copy Markdown
Contributor

I was reviewing this pull request proposing to remove the restriction of having a component with the name of the package, and I have some related questions:
What would happen if a user declares a component with a cmake_target_name and the target name collides with the root one? Or with another component? What about the aliases? Do we have tests? Is it undefined behavior?

@czoido

czoido commented Nov 30, 2021

Copy link
Copy Markdown
Contributor Author

I was reviewing this pull request proposing to remove the restriction of having a component with the name of the package, and I have some related questions: What would happen if a user declares a component with a cmake_target_name and the target name collides with the root one? Or with another component? What about the aliases? Do we have tests? Is it undefined behavior?

For the aliases there's a check and a warning that the alias won't be declared if already declared: https://github.com/SSE4/conan/blob/16556f34e1e70e07e6d20188193df16adaed7c59/conan/tools/cmake/cmakedeps/templates/targets.py#L85

For cmake_target_name I think we should probably raise if the target names collide

@lasote

lasote commented Nov 30, 2021

Copy link
Copy Markdown
Contributor

I would say, Let's raise in both cases. We can always revert if we realize later that something is being re-declared or something like that.

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.

4 participants