Skip to content

Commit

Permalink
CMakeDeps: remove warning about existing alias (#14644)
Browse files Browse the repository at this point in the history
CMakeDeps: remove warning about existing alias
  • Loading branch information
BobIsOnFire authored Sep 5, 2023
1 parent fe88e4f commit 21029be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
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

0 comments on commit 21029be

Please sign in to comment.