A simple C++ project template using CMake for easy building and project management.
cpp-project-template/
├── CMakeLists.txt # Build configuration
├── README.md # This file
├── include/ # Header files
│ └── math_utils.h # Math utility functions header
└── src/ # Source files
├── main.cpp # Main source file
└── math_utils.cpp # Math utility functions implementation
- CMake (version 3.10 or higher)
- C++ Compiler supporting C++17 (GCC, Clang, or MSVC)
mkdir build
cd build# For Debug build (includes debugging symbols) cmake -DCMAKE_BUILD_TYPE=Debug .. # For Release build (optimized) cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build .# On Linux/macOS ./MyProject # On Windows MyProject.exe
mkdir build && cd build && cmake .. && cmake --build . && ./MyProject
- Add your
.cppfiles to thesrc/directory - Add your
.hor.hppheader files to theinclude/directory - Update
CMakeLists.txtto include the new files:add_executable(${PROJECT_NAME} src/main.cpp src/math_utils.cpp src/your_new_file.cpp )
- Rebuild the project
- Project Name: Change
MyProjectinCMakeLists.txtto your desired name - C++ Standard: Modify
CMAKE_CXX_STANDARDif you need a different C++ version - Compiler Flags: Add additional flags in the appropriate build type section
Happy coding! 🚀