-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
libcap/2.65 + conan v2 compatibility #12241
Conversation
WARN: [INVALID TOPICS (KB-H064)] The topic 'conan' is invalid and should be removed from topics attribute.
WARN: [TOOLS CROSS BUILDING (KB-H062)] The 'tools.cross_building(self.settings)' syntax may not work correctly in some scenarios. Consider using tools.cross_building(self).
libcap natively supports .pc files. And a minimal test package should check that at least the pkg_config generator works correctly (because this is how other packages typically work with libcap).
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
||
def package_info(self): | ||
self.cpp_info.components["cap"].set_property("pkg_config_name", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I'm trying to build a test package with this line, I get a warning: "(test package): WARN: [libcap/2.65] The PC package name libcap.pc already exists and it matches with another component one. Please, review all the component's pkg_config_name defined. Skipping it!". But I don't know how to figure out what's wrong here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's because there's a global one by default for v1 generators.
You need to set a root level one like AFAIK (not an expert just say that in another PR I reviewed recently)
self.cpp_info.set_property("pkg_config_name", "libcap-all-do-not-use")
|
||
def generate(self): | ||
env = Environment() | ||
env.prepend_path("PKG_CONFIG_PATH", self.generators_folder) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason, pkg_check_modules
tries to find .pc
files not in the generator_folder
, but in the generator_folder/lib/pkgconfig
. I thought the PkgConfigDeps
generator should resolve that (via env vars maybe), but it doesn't. Not sure if I am doing something wrong or if it is a bug. I didn't find any examples of using CMakeToolchain
and PkgConfigDeps
generators together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👋 @franramirez688 @czoido is this the right way to use CMakeToolchain and PkgConfigDeps generators together?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason, pkg_check_modules tries to find .pc files not in the generator_folder, but in the generator_folder/lib/pkgconfig.
After digging deeper into it, I figured out that CMake is adding the suffix lib/pkgconfig
to the CMAKE_PREFIX_PATH
(pointing to the package_folder
where the *.pc
files are created). You can have a look at the issue https://gitlab.kitware.com/cmake/cmake/-/issues/18150
I thought the PkgConfigDeps generator should resolve that (via env vars maybe), but it doesn't
Yes, you're right, but it should not be necessary as far as CMake should use that CMAKE_PREFIX_PATH
by default. As I said above, CMake is adding that suffix, so it's getting failed because there are no PC files there.
is this the right way to use CMakeToolchain and PkgConfigDeps generators together?
Given that information, I tend to say that yes, it could be one way to solve that issue, and I think there could be another workaround like:
def build(self):
pkg_lib_folder = os.path.join(self.generators_folder, "lib", "pkgconfig")
copy(self, "*.pc", self.generators_folder, pkg_lib_folder)
cmake = CMake(self)
cmake.configure()
cmake.build()
Anyway, we could discuss if it could be a chance to create a mechanism to add the PKG_CONFIG_PATH
via CMake build helper or even CMakeToolchain to avoid those workarounds.
recipes/libcap/all/conanfile.py
Outdated
|
||
required_conan_version = ">=1.33.0" | ||
required_conan_version = ">=1.37.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
required_conan_version = ">=1.37.0" | |
required_conan_version = ">=1.47.0" |
recipes/libcap/all/conanfile.py
Outdated
@@ -26,82 +30,81 @@ class LibcapConan(ConanFile): | |||
"psx_syscals": False, | |||
} | |||
exports_sources = "patches/**" | |||
generators = "VirtualBuildEnv", "VirtualRunEnv" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I was sure that the migrating guide recommends adding them, because they are enabled by default in v2. But I checked it, and it looks like I just mixed it up.
I will delete it.
recipes/libcap/all/conanfile.py
Outdated
def validate(self): | ||
if self.info.settings.os != "Linux": | ||
raise ConanInvalidConfiguration("Only Linux supported") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after configure please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
find_package(PkgConfig REQUIRED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add pkgconf to build_requirements of test_package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
All green in build 4 (
|
Specify library name and version: libcap/2.65
libcap was updated to the latest release. And a few warnings from conan-center hooks were fixed.
Also, as I see it, there is ongoing refactoring in the repo. A lot of packages were rewritten to be compatible with conan v2. So I did a little refactoring of the recipe too (have a few concerns though).