CMake Xcode 生成器创建无法构建的项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4961123/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 20:13:04  来源:igfitidea点击:

CMake Xcode generator creates a project that cannot build

xcodecmakegenerator

提问by aaragon

I have a C++ project that uses the CMake build system. I use a MacBook Pro for development, so when I use the terminal everything works like a charm, and I can build my project.

我有一个使用 CMake 构建系统的 C++ 项目。我使用 MacBook Pro 进行开发,所以当我使用终端时,一切都很顺利,我可以构建我的项目。

However, today I found out that I could use Xcode after creating the respective project using the CMake generator:

但是,今天我发现我可以在使用 CMake 生成器创建相应的项目后使用 Xcode:

$> cmake -G Xcode .

It works the project and it looks fine, except for the fact that I can't build anything. It doesn't recognize symbols included from included files. Why is this? It seems as if the CMake environmental variables are not passed to Xcode.

它适用于该项目并且看起来不错,除了我无法构建任何东西的事实。它无法识别包含文件中包含的符号。为什么是这样?似乎 CMake 环境变量没有传递给 Xcode。

How can I fix this?

我怎样才能解决这个问题?

回答by Randall Cook

Omit the dot (.) in your command invocation, leaving just cmake -G Xcode. When I first started using CMake, I also was generating Xcode projects that would not build. I was using CMake's interactive wizard UI, which led to a world of hurt. As often happens, using the simplest command is often the way to go. Once I stopped using the wizard and just using the defaults, I got an Xcode project that builds reliably.

在命令调用中省略点 (.),只留下cmake -G Xcode. 当我第一次开始使用 CMake 时,我还生成了无法构建的 Xcode 项目。我正在使用 CMake 的交互式向导 UI,这导致了一个受伤的世界。正如经常发生的那样,使用最简单的命令通常是可行的方法。一旦我停止使用向导而只使用默认值,我就得到了一个可以可靠构建的 Xcode 项目。