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
.cpp
files to thesrc/
directory - Add your
.h
or.hpp
header files to theinclude/
directory - Update
CMakeLists.txt
to 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
MyProject
inCMakeLists.txt
to your desired name - C++ Standard: Modify
CMAKE_CXX_STANDARD
if you need a different C++ version - Compiler Flags: Add additional flags in the appropriate build type section
Happy coding! 🚀