Understanding of cmake --build .

cmake --build .

The meaning of this command is: Execute the build system in the current directory to generate build targets.

A brief description of the cmake project construction process:

1. First, use the command line: 'cmake <source tree>', for example: cmake .., the project file project files are generated in your build directory (external build method), which is also called build tree/binary tree in official documents , which includes, for example: Makefile, and some other related files/directories/subdirectories;

2. Secondly, it is natural to compile and build the generated project (project files), using what you said 'cmake --build .'

3. Finally, the '.' behind --build refers to the path of the generated build tree. Generally speaking, if you know exactly which builder (build generator) you are using in your system, For example: Unix Makefiles, you can use make directly to build projects.

For this form of --build, it is mostly used in automated scripts, or in the IDE environment.

Note: <source tree> refers to the path where the source file + top-level CMakeLists are located, cmake .. assumes that the path is at the upper level.

After the Makefile is created through the cmake ./cmake .. command, the make command is generally used to compile the file. The cmake --build here has the same effect as make

Why not make directly, but use the cmake --build command, mainly for cross-platform, after using this form, no matter what generator you use, CMake can build correctly, otherwise if you use Ninja or other generators, then make will not take effect
 

Guess you like

Origin blog.csdn.net/qq_38563206/article/details/126486183