CMake、Xcode 和 Unix 生成文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/751837/
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
CMake, Xcode and Unix Makefile
提问by claf
I was using classic Unix Makefile generator until I found a webpage explaining CMake could produce a nice xcode project file using "cmake -G Xcode" so I ran that command in my source directory and I get a nice xcode project. This is great but I'm facing some drawback and was wondering if there are solutions to these :
我一直在使用经典的 Unix Makefile 生成器,直到我发现一个解释 CMake 的网页可以使用“cmake -G Xcode”生成一个不错的 xcode 项目文件,所以我在我的源目录中运行了该命令,我得到了一个不错的 xcode 项目。这很棒,但我面临一些缺点,想知道是否有解决方案:
now I can't build out of tree using unix makefiles (I use to run cmake ../myproj in a build dir and then make command) this doesn't work anymore (I suppose temp files in the project dir are responsible)
some of my headers are generated by cmake (myproj.h.in became myproj.h and is include in some tests for example) but I can't find those files in the xcode project I get.
现在我无法使用 unix makefile 构建树(我过去常常在构建目录中运行 cmake ../myproj 然后 make 命令)这不再起作用(我想项目目录中的临时文件是负责的)
我的一些头文件是由 cmake 生成的(myproj.h.in 变成了 myproj.h,例如包含在一些测试中)但是我在我得到的 xcode 项目中找不到这些文件。
Thanks in advance for any good advice on how I can combine xcode project and unix makefile to be able to use both.
在此先感谢您提供有关如何将 xcode 项目和 unix makefile 结合起来使用的任何好的建议。
采纳答案by claf
I found the answer by myself (I mean asking the good person) :
我自己找到了答案(我的意思是问好人):
Use 2 separate build directories for each type of build files. This will ensure each build directory has the correct build files and generated files for its use.
为每种类型的构建文件使用 2 个单独的构建目录。这将确保每个构建目录都有正确的构建文件和生成的文件供其使用。
In the add_executable() command, in addition to the source files also include the headers and generated headers for those to show up in Xcode.
在 add_executable() 命令中,除了源文件之外,还包括要在 Xcode 中显示的头文件和生成的头文件。
回答by Martin
You can use xcodebuild to still have a proper Xcode project and build it from the command line/shell script/Makefile, e.g.
您可以使用 xcodebuild 仍然有一个合适的 Xcode 项目并从命令行/shell 脚本/Makefile 构建它,例如
xcodebuild -project MyProject.xcodeproj -target MyTarget -configuration Release