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

CMakeDeps: remove warning about existing alias #14644

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions conan/tools/cmake/cmakedeps/templates/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand All @@ -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 %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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