我开始从事大型C ++项目,并且对构建它有疑问。该项目包含两个应用程序:服务器ServerMain
和客户端ClientMain
。
我希望我的项目具有以下结构:
project/
├── cmake-build-release/
│ ├── ...
│ ├── ...
│ └── ...
│
├── lib/
│ ├── comp1/
│ │ ├── CmakeLists.txt
│ │ ├── a1.hpp
│ │ ├── a1.cpp
│ │ ├── b1.hpp
│ │ └── b1.cpp
│ ├── comp2/
│ │ ├── CmakeLists.txt
│ │ ├── a2.hpp
│ │ ├── a2.cpp
│ │ ├── b2.hpp
│ │ └── b2.cpp
│ └── comp3/
│ ├── CmakeLists.txt
│ ├── a3.hpp
│ ├── a3.cpp
│ ├── b3.hpp
│ └── b3.cpp
│
└── app/
├── CmakeLists.txt
├── ServerMain.cpp
└── ClientMain.cpp
现在,两个应用程序都依赖于不同的组件,而某些组件则依赖于其他组件。其次,我所有的包含内容应如下所示:
ServerMain
取决于a1.hpp
:#include<comp1/a1.hpp>
ClientMain
取决于a2.hpp
:#include<comp2/a2.hpp>
a1
和a2
依赖于b3.hpp
:#include<comp3/b3.hpp>
所以,我的问题是: 如何使用Cmake处理组件?不同的组件应如何相互包括以允许这些交叉方式?您能给我有关项目结构的其他提示吗?