Modern CMake 3:基本介绍
组织项目结构
CMake没有统一的项目结构,一些常用原则可以帮助我们组织更好的项目结构:
- 项目内部能够十分方便的读取其他工程;
- 避免项目结构冲突;
- 并行构建.
一个典型的例子(仅做参考),假设你的项目叫做project
,你的库名为lib
,可执行程序名为app
:
- project
- .gitignore
- README.md
- LICENCE.md
- CMakeLists.txt
- cmake
- FindSomeLib.cmake
- include
- project
- lib.hpp
- src
- CMakeLists.txt
- project
- CMakeLists.txt
- lib.cpp
- apps
- CMakeLists.txt
- app.cpp
- tests
- testlib.cpp
- docs
- Doxyfile.in
- extern
- googletest
- scripts
- helper.py
- 源文件中都应包含
CMakeLists.txt
文件。可以使用add_subdirectory
添加包含CMakeLists.txt
文件的子目录到工程。 - 大多时候,我们需要
cmake
文件夹,所有Find*.cmake
文件都应在此文件夹中找到。把cma