diff --git a/conan/tools/cmake/cmakedeps/templates/targets.py b/conan/tools/cmake/cmakedeps/templates/targets.py index 42d8d7f9c66..a902bdf76f0 100644 --- a/conan/tools/cmake/cmakedeps/templates/targets.py +++ b/conan/tools/cmake/cmakedeps/templates/targets.py @@ -80,8 +80,6 @@ def template(self): if(NOT TARGET {{alias}}) add_library({{alias}} INTERFACE IMPORTED) set_property(TARGET {{ alias }} PROPERTY INTERFACE_LINK_LIBRARIES {{target}}) - else() - message(WARNING "Target name '{{alias}}' already exists.") endif() {%- endfor %} @@ -93,8 +91,6 @@ def template(self): if(NOT TARGET {{alias}}) add_library({{alias}} INTERFACE IMPORTED) set_property(TARGET {{ alias }} PROPERTY INTERFACE_LINK_LIBRARIES {{target}}) - else() - message(WARNING "Target name '{{alias}}' already exists.") endif() {%- endfor %} diff --git a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_aliases.py b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_aliases.py index 8548640c4f0..f27f18abd99 100644 --- a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_aliases.py +++ b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_aliases.py @@ -126,6 +126,10 @@ def package_info(self): @pytest.mark.tool("cmake") def test_collide_global_alias(): + """ + FIXME: right now, having multiple aliases with same name doesn't emit any warning/error. + Possible alias collisions should be checked in CMakeDeps generator + """ conanfile = textwrap.dedent(""" from conan import ConanFile @@ -153,11 +157,15 @@ def package_info(self): client.save({"conanfile.py": consumer, "CMakeLists.txt": cmakelists}) client.run("create .") - assert "Target name 'hello::hello' already exists." in client.out + # assert "Target name 'hello::hello' already exists." in client.out @pytest.mark.tool("cmake") def test_collide_component_alias(): + """ + FIXME: right now, having multiple aliases with same name doesn't emit any warning/error. + Possible alias collisions should be checked in CMakeDeps generator + """ conanfile = textwrap.dedent(""" from conan import ConanFile @@ -184,4 +192,4 @@ def package_info(self): client.save({"conanfile.py": consumer, "CMakeLists.txt": cmakelists}) client.run("create .") - assert "Target name 'hello::buy' already exists." in client.out + # assert "Target name 'hello::buy' already exists." in client.out