This is a very simple, bare-bones cmake project template.
This project was originally created by me to learn about the cmake build system. A lot of cmake resources that I've looked into just seem very tedious and boring. My original sentiment was something along the lines of, "I just want to start coding, I don't care about any of this..."
So this template is just here to serve as a bare bones starting point, to get you up and running with a very simple project structure with some template cmake and cpp files included as examples.
-
Clone Repository:
git clone https://github.com/mdmubin/cmake-template.git
-
Open clone directory, create build directory and change current directory to build directory:
cd cmake-template mkdir build cd build
-
Configure cmake:
cmake ..
-
Build project:
- debug mode
cmake --build . --config Debug
- release mode
cmake --build . --config Release
I am using MSVC
compiler and for me the executable/library file built by cmake
is present in ../project-root/build/src/[Debug or Release]/
. If you are using
a different compiler, you might not find it in the same directory as I did.
- This is just a directory structure that I personally think manages to arrange every file in a neat manner.
project_root/
|---> build/
| |---> (cmake files are built in this directory)
|
|---> external/
| |---> include/ (external include headers)
| |---> libs/ (external library files, for example: .lib, .dll, etc)
|
|---> src/
| |---> include/ (public headers for your library goes here)
| |---> ... (any source files, for example: .cpp, .c, .h, .hpp, etc)
| |---> CMakeLists.txt
|
|---> test/
| |---> ... (test source files)
| |---> CMakeLists.txt
|
|---> .gitignore
|---> CMakeLists.txt
|---> LICENCE.txt
|---> README.md
-
I plan to add a simple cmake test, as soon as I learn more about it