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

Fix pkgconfig name collision on Windows #14428

Open
wants to merge 2 commits into
base: release/2.0
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion conan/tools/gnu/pkgconfigdeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def _update_pc_files(info):
# if it does not already exist in components one
# Issue related: https://github.com/conan-io/conan/issues/10341
pkg_name = _get_package_name(self._dep, self._build_context_suffix)
if f"{pkg_name}.pc" not in pc_files:
if not f"{pkg_name}.pc".lower() in [x.lower() for x in pc_files]:
package_info = _PCInfo(pkg_name, pkg_requires, f"Conan package: {pkg_name}",
self._dep.cpp_info, _get_package_aliases(self._dep))
# It'll be enough creating a shortened PC file. This file will be like an alias
Expand Down
65 changes: 65 additions & 0 deletions conans/test/functional/toolchains/gnu/test_pkgconfigdeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,68 @@ def layout(self):
# Executing directly "meson test" fails if the bindir field does not exist
client.run_command("meson test -C test_package/build-release")
assert "1/1 ./src/example OK"


@pytest.mark.tool("meson")
@pytest.mark.tool("pkg_config")
def test_pkgconfigdeps_pc_name_conflict():
"""
This test checks that a pc file provided by component is not overwritten by
conan with pc file named after the package if the names collide.
Cases insensitive filesystems have to be taken into account.
"""
client = TestClient()
client.run("new meson_lib -d name=hello -d version=1.0")
client.run("create . -tf=\"\"")
conanfile = textwrap.dedent("""
import os
from conan import ConanFile
from conan.tools.meson import MesonToolchain, Meson
from conan.tools.layout import basic_layout
from conan.tools.files import copy

class helloConan(ConanFile):
name = "hello"
version = "1.0"
package_type = "library"

# Binary configuration
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}

# Sources are located in the same place as this recipe, copy them to the recipe
exports_sources = "meson.build", "src/*"

def config_options(self):
if self.settings.os == "Windows":
self.options.rm_safe("fPIC")

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")

def layout(self):
basic_layout(self)

def generate(self):
tc = MesonToolchain(self)
tc.generate()

def build(self):
meson = Meson(self)
meson.configure()
meson.build()

def package(self):
meson = Meson(self)
meson.install()

def package_info(self):
self.cpp_info.components["component"].set_property("pkg_config_name", "Hello")
self.cpp_info.components["component"].libs = ["hello"]
""")
client.save({"conanfile.py": conanfile})
client.run("build test_package/conanfile.py")
client.run_command("meson test -C test_package/build-release")
assert "1/1 ./src/example OK"