A modern, feature-rich, customizable C++20 project template
- 🔄 Modern CMake (3.16+) setup
- 🚀 C++20 standard
- 📚 Google Test integration
- 📝 Comprehensive documentation structure
- 🧪 Example code
- 🛠️ Out-of-the-box compiler warnings
- 🔍 Code sanitizers
- 📊 Code coverage support
- 📋 Static analysis support
- 🔄 Continuous Integration ready
- 📦 Package management support
- 🚢 Installation and export targets
- CMake 3.16 or newer
- C++20 compatible compiler
- Git
# Clone the repository
git clone https://github.com/hun756/CPP-Starter-Template.git my-project
cd my-project
# Create build directory
mkdir build && cd build
# Configure
cmake ..
# Build
cmake --build .
# Run tests
ctest
# Run executable
./bin/cpp_project_template
my-project/
├── CMakeLists.txt # Main CMake configuration
├── cmake/ # CMake modules and utilities
│ ├── CompilerWarnings.cmake
│ ├── Sanitizers.cmake
│ ├── StaticAnalyzers.cmake
│ ├── LTO.cmake
│ ├── Packaging.cmake
│ ├── FindGTest.cmake
│ ├── FindGBenchmark.cmake # Benchmark için eklendi
│ └── configs/ # Configuration templates
├── include/ # Public header files
│ └── myproject/
│ ├── ModuleA.h
│ └── ModuleB.h
├── src/ # Source files
│ ├── ModuleA.cpp
│ ├── ModuleB.cpp
│ └── main.cpp
├── test/ # Test files
│ ├── CMakeLists.txt
│ ├── ModuleATest.cpp
│ └── ModuleBTest.cpp
├── bench/ # Benchmark files
│ ├── CMakeLists.txt
│ ├── StringProcessorBench.cpp
│ └── CalculatorBench.cpp
├── examples/ # Example programs
│ ├── CMakeLists.txt
│ ├── example1.cpp
│ └── example2.cpp
├── docs/ # Documentation
│ ├── CMakeLists.txt
│ └── Doxyfile.in
├── .clang-format # Formatting configuration
├── .clang-tidy # Static analysis configuration
├── .gitignore
└── README.md
Option | Default | Description |
---|---|---|
BUILD_SHARED_LIBS | OFF | Build shared libraries |
BUILD_EXAMPLES | ON | Build example programs |
BUILD_TESTS | ON | 7776Build tests |
BUILD_BENCHMARKS | ON | Build benchmark programs |
ENABLE_COVERAGE | OFF | Enable coverage reporting |
ENABLE_SANITIZERS | OFF | Enable sanitizers in debug builds |
ENABLE_PCH | OFF | Enable precompiled headers |
ENABLE_LTO | OFF | Enable Link Time Optimization |
ENABLE_CPPCHECK | OFF | Enable static analysis with cppcheck |
ENABLE_CLANG_TIDY | OFF | Enable static analysis with clang-tidy |
Example usage:
cmake .. -DBUILD_SHARED_LIBS=ON -DENABLE_SANITIZERS=ON
Generate documentation with Doxygen:
cmake --build . --target docs
Create distributable packages:
cmake --build . --target package
This project can be easily integrated in other CMake projects:
find_package(cpp_project_template REQUIRED)
target_link_libraries(your_target PRIVATE cpp_project_template::cpp_project_template)
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature
- Commit your changes:
git commit -am 'Add my feature'
- Push to the branch:
git push origin feature/my-feature
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.