CMake 查找具有不同版本的多个包的特定包(NCurses)

发布于 2025-01-20 14:42:00 字数 887 浏览 6 评论 0原文

我目前有一个cmake文件,可以找到并将库(ncurses)链接到另一个库,

...
set(CURSES_NEED_NCURSES TRUE)
find_package(Curses REQUIRED)
include_directories(${CURSES_INCLUDE_DIR})

add_library(myLibrary STATIC ${sources})
target_link_libraries(myLibrary ${CURSES_LIBRARIES})
target_compile_options(myLibrary PUBLIC -std=c++20 -Wall -Wconversion)
...

但不幸的是,它正在提取与我需要的不同版本(5.7而不是6.1)

#include <ncurses.h>
#include <iostream>

int main()
{
    std::cout << "VERSION: " << NCURSES_VERSION;
}

输出:版本:5.7

我确实安装了所需的软件包:/usr/local/ncurses/6_1。 但是日志似乎说它是从其他位置将其拉到的:找到诅咒:/applications/xcode-beta.app/contents/developer/developer/platforms/macosx.platform/develform/develfer/sdks/sdks/macosx11.3.sdk/ usr/lib/libncurses.tbd

如何指定我要使用哪些?

I currently have a CMake file that finds and links a library (NCurses) to another library

...
set(CURSES_NEED_NCURSES TRUE)
find_package(Curses REQUIRED)
include_directories(${CURSES_INCLUDE_DIR})

add_library(myLibrary STATIC ${sources})
target_link_libraries(myLibrary ${CURSES_LIBRARIES})
target_compile_options(myLibrary PUBLIC -std=c++20 -Wall -Wconversion)
...

This works fine, however unfortunately it is pulling up a different version than I need (5.7 instead of 6.1)

#include <ncurses.h>
#include <iostream>

int main()
{
    std::cout << "VERSION: " << NCURSES_VERSION;
}

outputs: VERSION: 5.7

I do have the desired package installed under: /usr/local/ncurses/6_1.
But the logs seem to say it is pulling it from a different location: Found Curses: /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/lib/libncurses.tbd

How can I specify which of these I want to use?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

画骨成沙 2025-01-27 14:42:00

好吧,我已经弄清楚了可能遇到这个问题的任何人。

首先,我从这里安装了最新版本的Ncurses(6.3): .net/ncurses/#下载h2
(我下载了GZPAR的焦油)

然后我通过了我可以找到Ncurses的USR/Local中的所有参考。

然后,我提取焦油,然后进入新目录。

我只是在目录内(没有标志)内的Plain ./配置

完成此操作后,我运行制作

然后我ran 进行安装,在删除符号链接以停止碰撞之后,使安装能够正确运行。

确保CMAKE变量Curses_need_ncurses在找到软件包之前将其设置为true:

set(CURSES_NEED_NCURSES TRUE)
find_package(Curses REQUIRED)

它将完美工作:)

Okay I have figured this out, to anyone else who might come across this.

First I installed the latest version of ncurses (6.3) from here: https://invisible-island.net/ncurses/#downloads-h2
(I downloaded the gzipped tar)

I then went through and deleted all references in my usr/local i could find to ncurses.

I then extracted the tar, and entered the new directory.

I ran just plain ./configure inside the directory (with no flags).

After that finished, I ran make

Then I ran make install, after removing symlinks to stop collisions, make install was able to run properly.

Ensure that the CMake variable CURSES_NEED_NCURSES is set to TRUE before finding the package:

set(CURSES_NEED_NCURSES TRUE)
find_package(Curses REQUIRED)

and it will work perfectly :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文