Linux C++ project directory layout - CMake
I would like to use some standard layout for my linux c++ project which is built using cmake and contains some executables and a library that these execs might link to. Currently I just had a folder for the project and a sub folder for each sub project. W开发者_如何学Cith a CMakeLists in the top level and one in each sub level that the opt level adds.
Project-
executable1
executable2
library
However I think it would be better setup like the following
Project -
lib //Library output folder
bin //Executable output folder
src //Al cpp source files
include //All header files
test //All tests
I would have just one CMakeLists in top level. I can easily set this up in cmake. does anyone have reasons for choosing a different layout?
I wouldn't put the lib, bin and test output directly on the project directory: if you want to make a debug and a release build, you get stuck, because you have only one placeholder. Out of source build is your friend! I would use something like:
Project
src
include
CMakeLists.txt
These will be generated when using cmake:
Project_build_dbg
bin
lib
test
Project_build_release
bin
lib
test
The layout you are proposing to use is pretty much how most of the projects are organised. And its a very well organised way of having a project. I usually also have a docs
folder wherein goes all the documentation about the project. So heres my usual project setup.
Project -
lib //Library output folder
bin //Executable output folder
src //All cpp source files
include //All header files
test //All tests
docs //All project documentation ------> new addition
精彩评论