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_templatemy-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 | Build 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=ONGenerate documentation with Doxygen:
cmake --build . --target docsCreate distributable packages:
cmake --build . --target packageThis 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.