cmake add_subdirectory 错误仅与 cmake 命令行有关,但在 Windows 上没有 cmake-gui(在驱动器号的根目录中检出源代码) [英] cmake add_subdirectory error only with cmake command line but not cmake-gui on windows (with source checked out at root of a drive letter)

查看:68
本文介绍了cmake add_subdirectory 错误仅与 cmake 命令行有关,但在 Windows 上没有 cmake-gui(在驱动器号的根目录中检出源代码)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究使用 CMake 构建的 3dtk.你可以在这里找到它的 CMakeLists.txt:https://sourceforge.net/p/slam6d/code/HEAD/tree/trunk/CMakeLists.txt

I'm working on 3dtk which uses CMake to build. You can find its CMakeLists.txt here: https://sourceforge.net/p/slam6d/code/HEAD/tree/trunk/CMakeLists.txt

在几个地方,它使用了 add_subdirectory 指令并且从不提供第二个参数(binary_dir).

In several places it uses the add_subdirectory directive and never supplies a second argument (the binary_dir).

在linux上调用ccmake out-of-tree 或者在windows上使用cmake-gui时似乎没有问题,在这两种情况下,项目配置成功.

This seems to be no problem when calling ccmake out-of-tree on linux or when using cmake-gui on windows as in both cases, the project configures successfully.

但是当我在 Windows 上的命令提示符下运行普通的 cmake 时,我会收到几个这样的错误:

But when I run plain cmake on windows in the command prompt, then I get several errors like this:

CMake Error at Z:/CMakeLists.txt:471 (add_subdirectory):
  add_subdirectory not given a binary directory but the given source
  directory "Z:/src/slam6d" is not a subdirectory of "Z:/". When specifying
  an out-of-tree source a binary directory must be explicitly specified.

我怀疑我只是缺少 cmake 命令的一个选项,但是哪个选项?

I suspect that I'm just missing an option to the cmake command but which one?

就像在 Windows 上使用 cmake-gui 一样,我为 在哪里构建二进制文件 指定了与 源代码在哪里 不同的路径> 进行树外构建,就像在 Linux 上使用 ccmake 在我的源代码的子目录中运行 ccmake 一样 ccmake ..,我正在 Windows 上从我的源代码的子目录中运行 cmake.

Just as with cmake-gui on Windows where I specify a different path for Where to build the binaries than for where is the source code to make an out-of-tree build and just as with ccmake on Linux where I run ccmake in a subdirectory of my source like this ccmake .., I'm running cmake on Windows from within a subdirectory of my source.

那么 cmake-guiccmake 做了哪些 cmake 没有做的事情以及需要人工干预的地方?

So what are cmake-gui and ccmake doing that cmake does not and where manual intervention is required?

找到解决方案后发现问题是我的源目录直接是一个 Windows 驱动器号而不是一个子目录.

after finding the solution it turns out that the problem was that my source directory was directly a windows drive letter instead of a subdirectory of one.

推荐答案

事实证明这是 cmake 中的一个错误.引用大卫科尔:

It turns out that this is a bug in cmake. Quoting David Cole:

将您的源代码放在子目录中.CMake 根本无法在Windows 上驱动器号的根目录.CMakeLists.txt 必须至少在根驱动器盘符路径下的一个子目录.

Put your source in a sub-directory. CMake simply does not work at the root of a drive letter on Windows. CMakeLists.txt MUST be in at least one sub-directory underneath a root drive letter path.

还有一些关于这个问题的公开错误报告:

There are also some open bugreports about this issue:

这篇关于cmake add_subdirectory 错误仅与 cmake 命令行有关,但在 Windows 上没有 cmake-gui(在驱动器号的根目录中检出源代码)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆