1. What is cmake?
See
Http://en.wikipedia.org/wiki/CMake
Http://www.cmake.org/
In short, cmake is a cross-platform engineering build tool. The traditional * nix makefile generation tool is mainly the autotools series. These tools can generate makefiles based on different systems. Compared with traditional autotools tools. Cmake can generate corresponding engineering files based on IDE on different platforms. Currently, at least makefile, Visual Studio series, eclipse CDT, mingw, and codeblocks are supported.
2. A cmake example.
Assume that you want to generate a project named test, including a file named hello. cpp (under the directory test)
1 # include <stdio. h>
2
3 int main (INT argc, char ** argv)
4 {
5 printf ("Hello world! \ N ");
6 RETURN 0;
7}
Now we want cmake to build this project.
First, configure the cmakepoliccmakelists.txt file. Therefore, the cmakelists.txt file is created in the testobject directory.
Cmakelists.txt File Content
Project (test)
Set (src_list hello. cpp)
Add_executable (test $ {src_list })
Then build the project, go to the command line (corresponding to the command shell in Windows), and enter the test directory.
Cmake.
You can (note. indicates the current directory ). Cmake automatically generates the corresponding makefile (or Visual Studio project file)
3. For more information, see
The above example is relatively simple. For more usage of cmake, refer to the official documents of cmake and wiki, http://www.cmake.org --> help --> document and Wiki.
In addition, I personally feel that cmake's official documentation is very blunt and obscure. The following tutorial is recommended for general applications.
Http://sewm.pku.edu.cn/src/paradise/reference/CMake%20Practice.pdf
(In the last line of the 6th page of the PDF file, the src_list should be $ {src_list}. I believe you can easily see the original text incorrect)
Basically, the content required for normal use is included in the above tutorial. There are many examples, which are strongly recommended.