|
| 1 | +/** |
| 2 | + * @mainpage Modern C++ Project Template |
| 3 | + * |
| 4 | + * A modern C++20+ starter project using CMake, GoogleTest, sanitizers, GitHub Actions, and developer tooling. |
| 5 | + * |
| 6 | + * ## ✅ Features |
| 7 | + * |
| 8 | + * - CMake presets with Clang & GCC support |
| 9 | + * - C++20 (extendable to C++23) |
| 10 | + * - GoogleTest (with FetchContent) |
| 11 | + * - Sanitizers: AddressSanitizer + UndefinedBehaviorSanitizer |
| 12 | + * - Link Time Optimization (LTO) presets |
| 13 | + * - clang-format + clang-tidy + pre-commit hook |
| 14 | + * - GitHub Actions CI for builds, tests, and formatting |
| 15 | + * - Install targets |
| 16 | + * |
| 17 | + * ## 🚀 Getting Started |
| 18 | + * |
| 19 | + * This project uses [CMake Presets](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html). |
| 20 | + * |
| 21 | + * ### Build and Test |
| 22 | + * ```bash |
| 23 | + * cmake --preset gcc-RelWithDebInfo |
| 24 | + * cmake --build --preset gcc-RelWithDebInfo |
| 25 | + * ctest --preset gcc-RelWithDebInfo |
| 26 | + * ``` |
| 27 | + * |
| 28 | + * To list available presets: |
| 29 | + * ```bash |
| 30 | + * cmake --list-presets |
| 31 | + * ``` |
| 32 | + * |
| 33 | + * ### Sanitizers |
| 34 | + * |
| 35 | + * Use the `Sanitize` build type to catch runtime issues: |
| 36 | + * ```bash |
| 37 | + * cmake --preset gcc-Sanitize |
| 38 | + * cmake --build --preset gcc-Sanitize |
| 39 | + * ctest --preset gcc-Sanitize |
| 40 | + * ``` |
| 41 | + * |
| 42 | + * ### LTO Builds |
| 43 | + * ```bash |
| 44 | + * cmake --preset gcc-RelWithDebInfo-lto |
| 45 | + * cmake --build --preset gcc-RelWithDebInfo-lto |
| 46 | + * ``` |
| 47 | + * |
| 48 | + * ### Testing |
| 49 | + * |
| 50 | + * - Enabled via `ENABLE_TESTING` (default: ON) |
| 51 | + * - Works with all build types |
| 52 | + * - `Sanitize` is recommended for catching runtime errors |
| 53 | + * - GoogleTest + CTest integration |
| 54 | + * |
| 55 | + * ### Code Style and Linting |
| 56 | + * |
| 57 | + * - Uses `.clang-format` (enforced via pre-commit) |
| 58 | + * - Uses `.clang-tidy` for static analysis |
| 59 | + * |
| 60 | + * Manual usage: |
| 61 | + * ```bash |
| 62 | + * clang-format -i src/*.cpp include/**/*.hpp tests/*.cpp |
| 63 | + * clang-tidy src/*.cpp -p build/gcc-RelWithDebInfo |
| 64 | + * ``` |
| 65 | + * |
| 66 | + * ## 📦 Installation |
| 67 | + * |
| 68 | + * To install includes, libraries, and CMake config files: |
| 69 | + * ```bash |
| 70 | + * cmake --preset gcc-RelWithDebInfo |
| 71 | + * cmake --build --preset gcc-RelWithDebInfo |
| 72 | + * cmake --install build/gcc-RelWithDebInfo --prefix install |
| 73 | + * ``` |
| 74 | + * |
| 75 | + * ## 🔗 Using in Another Project |
| 76 | + * |
| 77 | + * After installation: |
| 78 | + * ```cmake |
| 79 | + * find_package(modern_cpp_project REQUIRED) |
| 80 | + * target_link_libraries(<your_app> PRIVATE modern_cpp_project::math) |
| 81 | + * ``` |
| 82 | + * |
| 83 | + * Set this variable in your project: |
| 84 | + * ```bash |
| 85 | + * cmake -DCMAKE_PREFIX_PATH=/path/to/install .. |
| 86 | + * ``` |
| 87 | + * |
| 88 | + * ## 📄 License |
| 89 | + * |
| 90 | + * Licensed under the [Apache License 2.0](https://github.com/ramsafin/modern-cpp-project-template/blob/master/LICENSE) |
| 91 | + * |
| 92 | + * ## 🤝 Contributing |
| 93 | + * |
| 94 | + * - Code must pass all tests |
| 95 | + * - Code must be clang-format and clang-tidy clean |
| 96 | + * - Commits should follow clear, atomic changes |
| 97 | + */ |
0 commit comments