1

我正在查看FindBacktrace模块的文档,与FindThreads不同- 我没有看到我可以依赖的适当库目标,例如Backtrace::Backtrace. 它真的丢失了还是只是没有记录?

另外,当我使用这个模块时,我得到:

//Library providing backtrace(3), empty for default set of libraries
Backtrace_LIBRARY:FILEPATH=

在我的CMakeCache.txt(在 Devuan GNU/Linux 机器上)。这很奇怪。我期待看到-lbacktrace- 因为那是我得到的地方backtrace_create_state并且backtrace_pcinfo(我需要使用Boost stacktrace)。

那么,什么是“默认库集”?libbacktrace默认情况下肯定不会链接到。

4

2 回答 2

1

If one of the CMake-provided Find Modules (e.g. FindBacktrace) provides an imported target, it will almost certainly be documented. You can inspect the source code of the Find Module to be sure. In your case, for FindBacktrace.cmake, just search the file for the :: syntax of the imported target it may provide. At the time of writing, FindBacktrace.cmake does not provide one.

Because many of the Find Modules pre-date the arrival of modern CMake, there are actually many of them that do not yet provide imported targets. I imagine the CMake maintainers are tackling this task as dictated by the need and popularity of each module, so writing a CMake issue for the FindBacktrace module might provoke some action.

If so inspired, you could also write your own modified FindBacktrace.cmake file, adding the requisite CMake code to define the imported target Backtrace::Backtrace.


If the system (e.g. libc) provides support for backtrace(3), it is expected that the Backtrace_LIBRARY variable will be empty. The FindBacktrace module will pick up the default library if available, and populate it in Backtrace_LIBRARIES.

The Backtrace_LIBRARY cache path should only be used if your backtrace is available on your system through some other external library or package, such as on non-glibc systems. In that case, you'll populate Backtrace_LIBRARY manually.

于 2020-07-16T21:20:18.510 回答
0

正如@squareskittles 建议的那样,这只是 CMake 开发人员应该注意的事情。

我已就此事向 CMake 提交了一个错误,并将(希望记得)更新此问题以指示模块何时更新。

于 2020-07-21T08:13:09.870 回答