Skip to content

macOS下查找brew::ncurse失败 #7786

Description

@WittonBell

Xmake 版本

3.1.1

操作系统版本和架构

macOS 10.x

描述问题

在MacOS系统中默认会有一个ncurses版本5,使用brew安装了6后,项目要使用版本6,xmake.lua中配置add_requires("brew::ncurses", {alias = "ncurses"})会找到版本5,而不会找到6,跟了代码后发现:xmake/modules/package/manager/brew/find_package.lua中:

    if opt.require_version then
        table.insert(paths, path.join(brew_pkg_rootdir, nameinfo[1], opt.require_version, "lib/pkgconfig"))
        table.insert(paths, path.join(brew_pkg_rootdir, nameinfo[1], opt.require_version, "share/pkgconfig"))
    else
        table.insert(paths, path.join(brew_pkg_rootdir, nameinfo[1], "*/lib/pkgconfig"))
        table.insert(paths, path.join(brew_pkg_rootdir, nameinfo[1], "*/share/pkgconfig"))
    end

并没有排除默认的latest,导致查找失败,改为:

    if opt.require_version and opt.require_version ~= "latest" then
        table.insert(paths, path.join(brew_pkg_rootdir, nameinfo[1], opt.require_version, "lib/pkgconfig"))
        table.insert(paths, path.join(brew_pkg_rootdir, nameinfo[1], opt.require_version, "share/pkgconfig"))
    else
        table.insert(paths, path.join(brew_pkg_rootdir, nameinfo[1], "*/lib/pkgconfig"))
        table.insert(paths, path.join(brew_pkg_rootdir, nameinfo[1], "*/share/pkgconfig"))
    end

后测试,可以正确找到版本6

期待的结果

期望能正确找到brew中安装的版本

工程配置

add_rules("mode.debug", "mode.release")

add_requires("brew::ncurses", {alias = "ncurses"})
target("hello")
    set_kind("binary")
    add_files("src/*.c")
    add_packages("ncurses")

附加信息和错误日志

$ xmake f -vD -m debug -c
checking for platform ... macosx (x86_64)
checking for Xcode SDK ... no
checking for Codesign Identity of Xcode ... no
checkinfo: cannot runv(zig version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(nim --version), No such file or directory
checking for nim ... no
checking for dotnet ... /usr/local/share/dotnet/dotnet
checking for .NET SDK version ... 8.0.100
checking for .NET SDK directory ... /usr/local/share/dotnet/sdk/8.0.100
checking for git ... /usr/bin/git
checking for gzip ... /usr/bin/gzip
checking for tar ... /usr/bin/tar
finding ncurses from brew ..
checking for brew ... /usr/local/bin/brew
finding ncurses from system ..
checking for /Library/Developer/CommandLineTools/usr/bin/clang ... ok
checking for the c compiler (cc) ... clang
checking for /Library/Developer/CommandLineTools/usr/bin/clang ... ok
checking for flags (-fPIC) ... ok

clang "-fPIC" "-Qunused-arguments" "-target" "x86_64-apple-macos" "-isysroot" "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
/Library/Developer/CommandLineTools/usr/bin/clang -c -Qunused-arguments -target x86_64-apple-macos -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -o /var/folders/6h/7q8myh9x467bh1mxj3yjq2sc0000gn/T/.xmake501/260920/_d390a95732e36cc96dd3f599119846d5.o /var/folders/6h/7q8myh9x467bh1mxj3yjq2sc0000gn/T/.xmake501/260920/_5c2289377258fd5de3785c74a50568f0.c
checking for flags (-fdiagnostics-color=always) ... ok
clang "-fdiagnostics-color=always" "-Qunused-arguments" "-target" "x86_64-apple-macos" "-isysroot" "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
checking for flags (-Wno-gnu-line-marker -Werror) ... no
clang "-Wno-gnu-line-marker" "-Werror" "-Qunused-arguments" "-target" "x86_64-apple-macos" "-isysroot" "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
checkinfo: @programdir/core/sandbox/modules/os.lua:273: error: unknown warning option '-Wno-gnu-line-marker'; did you mean '-Wno-gnu-case-range'? [-Werror,-Wunknown-warning-option]

stack traceback:
[C]: in function 'error'
[@programdir/core/base/os.lua:1204]:
[@programdir/core/sandbox/modules/os.lua:273]: in function 'runv'
[@programdir/modules/core/tools/gcc/has_flags.lua:45]:
checking for /Library/Developer/CommandLineTools/usr/bin/clang++ ... ok
checking for the linker (ld) ... clang++
checking for /Library/Developer/CommandLineTools/usr/bin/clang++ ... ok
checking for flags (-fPIC) ... ok

clang++ "-fPIC" "-target" "x86_64-apple-macos" "-isysroot" "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk" "-lz" "-target" "x86_64-apple-macos" "-isysroot" "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk" "-lz"
/Library/Developer/CommandLineTools/usr/bin/clang++ -o /var/folders/6h/7q8myh9x467bh1mxj3yjq2sc0000gn/T/.xmake501/260920/_d390a95732e36cc96dd3f599119846d5.b /var/folders/6h/7q8myh9x467bh1mxj3yjq2sc0000gn/T/.xmake501/260920/_d390a95732e36cc96dd3f599119846d5.o -target x86_64-apple-macos -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -lz -lncurses
checking for c links(ncurses)
checking for c snippet(find_package/ncurses)
checking for brew::ncurses ... ncurses
configure
{
plat = macosx
host = macosx
clean = true
dotnet = /usr/local/share/dotnet/sdk/8.0.100
arch = x86_64
mode = debug
ndk_stdcxx = true
ccache = true
kind = static
dotnet_sdkver = 8.0.100
builddir = build
}

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions