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

Improve to find system/3rd package for add_requires/find_package.lua in package definition #1239

Closed
waruqi opened this issue Feb 11, 2021 · 2 comments

Comments

@waruqi
Copy link
Member

waruqi commented Feb 11, 2021

We can improve the builin find_package script in add_requires to support to find more system/3rd package in other package managers.

Example (libusb)

for apt and some linux systems, it is libusb-1.0

But, we always use libusb as package name to find and use it:

add_requires("libusb")
target("test")
    set_kind("binary")
    add_files("src/*.c")
    add_packages("libusb")

for find_package, it always be libusb.

xmake l find_package libusb

Solution

package("libusb")
    -- pacman::xxx, brew::xxx ...
    add_extsources("pkg_config::libusb-1.0", "conan::libusb")

related issue: #1140

@waruqi
Copy link
Member Author

waruqi commented Feb 21, 2021

I added add_extsources() to add external package sources on dev branch. #1248

add_extsources("pkgconfig::libusb-1.0")

And I have improved xmake-repo/libusb to support it.

https://github.com/xmake-io/xmake-repo/blob/66f5ae98c44320a33275f2ac782effd5b87298f0/packages/l/libusb/xmake.lua#L25-L27

@waruqi waruqi closed this as completed Feb 21, 2021
@waruqi
Copy link
Member Author

waruqi commented Feb 22, 2021

on_fetch has been supported.

package("libusb")
    on_fetch("linux", function(package, opt)
        if opt.system then
            return find_package("pkgconfig::libusb-1.0")
        end
    end)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant