Execution CMake can generate makefile files and some intermediate files, CMake has both internal and external construction operations, the proposed external build, keep the code clean, the project directory structure is clear.
CMake. Represents building the system based on the rules established in the file CMakeLists.txt in the current directory and generating makefile files in the current directory. "Within Build"
CMake.. Represents building the system and generating makefile files in the current directory based on the rules established in the file CMakeLists.txt in the previous level of the directory.
cmake [parameters] [specify directory to compile or directories to hold makefile files] [specify the directory where CMakeLists.txt files are located] "is an external build"
An appetizer.
The file structure in the Hello directory:?
./cmakelists.txt
1 2 3 4 |
├──cmakelists.txt├──hello.c├──hello.h└──main.c |
The C code is shown in the following section.
Simplest cmake configuration file:?
./cmakelists.txt
1 2 3 |
Project (Hello) set (src_list main.c hello.c) add_executable (Hello ${src_list}) |
If you want to compile into the debug version of GDB that you can debug, add the following in the configuration file:?
1 |
Set (Cmake_build_type Debug) |
If you want to compile to a version that is available gprof analysis, add the following in the configuration file: