写在前面
其实CMake在C++编译中是常用的编译工具,简单易上手,学习成不较低,最近我们也在开始用CMake编译,写一点最近项目中学习的一点体会和知识点,作以记录,网上单层级的CMake的例子挺多的,毕竟最终都是用一个CMakeLists.txt进行编译的,这个放在后面写,这个帖子主要写下多层级CMake的使用方法及目录关系:
多层目录举例
工程结构大致分为三层:从编译的易操作性来讲,编译的的位置应在CMakePro目录下进行,层层包含直到编译完全部源文件,因此,CMakeLists.txt的分布为:
CMakePro/CMakeLists.txt
CMakePro/Makefile
CMakePro/include/CMakeLists.txt
CMakePro/common/CMakeLists.txt
CMakePro/src/CMakeLists.txt
CMakePro/third/CMakeLists.txt
CMakePro/other/CMakeLists.txt
CMakePro/other/other1/CMakeLists.txt
CMakePro/other/other2/CMakeLists.txt