cmake
CMake
前言:
- CMake是一个跨平台的安装编译工具,可以用简单的语句来描述所有平台的安装(编译过程)。
- CMake可以说已经成为大部分C++开源项目标配
1 Cross-platform development
Let’s assume you have some cross-platform project with C++ code shared along different platforms/IDEs. Say you use Visual Studio
on Windows, Xcode
on OSX and Makefile
for Linux:
What you will do if you want to add new bar.cpp
source file? You have to add it to every tool you use:
To keep the environment consistent you have to do the similar update several times. And the most important thing is that you have to do it manually (arrow marked with a red color on the diagram in this case). Of course such approach is error prone and not flexible.
CMake solve this design flaw by adding extra step to development process. You can describe your project in CMakeLists.txt
file and use CMake to generate tools you currently interested in using cross-platform CMake code:
Same action - adding new bar.cpp
file, will be done in one step now:
Note that the bottom part of the diagram was not changed. I.e. you still can keep using your favorite tools like Visual Studio/msbuild
, Xcode/xcodebuild
and Makefile/make
!