cmake是什么? [英] What does cmake .. do?

查看:195
本文介绍了cmake是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了Box2D项目源代码,想要编译它的testbed部分。
项目文件夹包含以下文件夹:freeglu glui testbed(演示)helloword(演示)
Box2D构建CMakeFiles



有很多CMakeLists。 txt在所有不同的文件夹。
我想我应该cmake所有这些文件,使make文件创建在所有地方需要。
我读这个(作为我想要的指令):

  wget http://box2d.googlecode .com / files / Box2D_v2.2.1.zip 
解压缩Box2D_v2.2.1.zip
cd Box2D_v2.2.1 / Build
cmake ..
make

cmake ..做什么?
构建文件夹中没有CMakeLists.txt。

解决方案

cmake Makefile生成器。



当你调用 cmake [path] ,你需要生成Makefile $ cmd







通常cmake会在工作时输出一些消息,完成后没有错误,您可以输入make来执行新创建的Makefile。



em> CMakeLists.txt 文件可以在子目录中引用其他 CMakeLists.txt 文件,因此您通常只对 CMakeLists.txt



使用空的build目录是一种称为源外构建的技术,其中所有生成的文件(.o,可执行文件,Makefile,.anything)在单独的build目录中生成,不与源文件混合。如果你想清除所有的内容,你可以删除build目录的所有内容。



事实上,你可以把你的build目录放在任何地方,因为你给cmake顶部CMakeLists.txt的正确路径。你甚至可以有几个构建目录。如果你需要几个不同的版本(使用不同的选项,不同版本的gcc等),这是非常有用的。



在旧程序中,生成Makefile但是使用 ./ configure (这称为自动工具,你可能已经遇到过)。 cmake被认为是自动工具的后继。


I got the Box2D project source and want to compile the testbed portion of it. The project folder contains folders like: freeglu glui testbed(a demo) helloword(a demo) Box2D Build CMakeFiles

There are many CMakeLists.txt in all the different folders. I was thinking that I should cmake all those files so that make files are created in all places required. I read this (as instructions to do do want I want) :

wget http://box2d.googlecode.com/files/Box2D_v2.2.1.zip
unzip Box2D_v2.2.1.zip
cd Box2D_v2.2.1/Build
cmake ..
make

What does the cmake .. do? There is no CMakeLists.txt in the build folder.

解决方案

cmake is a Makefile generator.

When you call cmake [path], you ask it to generate a Makefile in the current directory following instructions given in [path]/CMakeLists.txt

Usually cmake output some messages while it is working, and after it is done without errors, you can type "make" to execute your newly created Makefile.

CMakeLists.txt files can reference other CMakeLists.txt file in sub-directories, so you are usually only interested by the CMakeLists.txt of the top directory, not the other ones.

Using an empty "build" directory is a technique called "out-of-source build", in which all your generated files (.o, executable, Makefile, .anything) are generated in the separate "build" directory and not mixed with source files. If you want to clean all, you can delete all the content of the build directory.

In fact, you can put your "build" directory in any place, as long as you give cmake the correct path of the top CMakeLists.txt. You can even have several build directories. It is very useful if you need several different builds at the same time (with different options, different versions of gcc, etc.)

In old programs, you generate the Makefile too, but using ./configure (this is called auto-tools. You may have encountered that already). cmake is considered a successor of the auto-tools.

这篇关于cmake是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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