Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
e3881b7
ci: complete elite workflow with vcpkg toolchain fix
SagarPohekar Mar 8, 2026
cde9d59
fix: update branch references from main to master in CI workflow
SagarPohekar Mar 8, 2026
2df5acb
fix: update CMake configuration to use PowerShell syntax for toolchai…
SagarPohekar Mar 8, 2026
11ad0e1
fix: update CMake configuration to correctly reference VCPKG_TOOLCHAI…
SagarPohekar Mar 8, 2026
0f7a610
fix: update CMake configuration to use bash syntax for toolchain file
SagarPohekar Mar 8, 2026
a07f91b
fix: update CI workflow to use bash shell for build configuration
SagarPohekar Mar 8, 2026
6787db1
fix: update CI workflow to ensure consistent bash shell usage and imp…
SagarPohekar Mar 8, 2026
42506cd
fix: include <string> in hello.cpp for string usage
SagarPohekar Mar 8, 2026
a566ceb
fix: add .clang-tidy configuration and enable clang-tidy in CMakeList…
SagarPohekar Mar 8, 2026
201032e
fix: remove unnecessary newline in .clang-tidy configuration
SagarPohekar Mar 8, 2026
6284823
experimental changes
SagarPohekar Mar 9, 2026
438d456
fix: update CMake configuration for C++20, enable auto-formatting, an…
SagarPohekar Mar 9, 2026
539565d
fix: update CI workflow to separate build steps for Linux and Windows
SagarPohekar Mar 9, 2026
9544ed6
fix: ensure consistent shell usage in build steps for Linux and Windows
SagarPohekar Mar 9, 2026
a7db4b5
fix: enhance Windows build step to handle different preset configurat…
SagarPohekar Mar 9, 2026
6e30063
fix: refine CI workflow by separating Linux and Windows build steps a…
SagarPohekar Mar 9, 2026
1201a1d
fix: update CI workflow to correctly set up MSVC and adjust linker se…
SagarPohekar Mar 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
BasedOnStyle: LLVM

IndentWidth: 4
TabWidth: 4
UseTab: Never

ColumnLimit: 100

BreakBeforeBraces: Allman

AllowShortFunctionsOnASingleLine: Empty
AllowShortBlocksOnASingleLine: Never

NamespaceIndentation: All

PointerAlignment: Left
ReferenceAlignment: Left

SpaceBeforeParens: ControlStatements

SortIncludes: true
IncludeBlocks: Regroup
75 changes: 75 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# .clang-tidy
Checks: >
-*,

# High-value bug detection
bugprone-*,
clang-analyzer-*,

# Performance improvements
performance-*,

# Modern C++ suggestions
modernize-*,

# Selected core guidelines
cppcoreguidelines-avoid-magic-numbers,
cppcoreguidelines-init-variables,
cppcoreguidelines-narrowing-conversions,
cppcoreguidelines-slicing,
cppcoreguidelines-special-member-functions,

# Useful readability checks (not noisy ones)
readability-braces-around-statements,
readability-const-return-type,
readability-implicit-bool-conversion,
readability-redundant-control-flow,
readability-simplify-boolean-expr,

# Disabled noisy checks
-modernize-use-trailing-return-type,
-modernize-use-auto,
-modernize-use-nodiscard,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-pro-type-vararg,
-cppcoreguidelines-owning-memory,
-cppcoreguidelines-avoid-c-arrays,
-readability-magic-numbers

WarningsAsErrors: >
bugprone-*,
clang-analyzer-*

HeaderFilterRegex: 'src/.*|include/.*'

CheckOptions:

# Identifier naming
- key: readability-identifier-naming.NamespaceCase
value: lower_case

- key: readability-identifier-naming.ClassCase
value: CamelCase

- key: readability-identifier-naming.StructCase
value: CamelCase

- key: readability-identifier-naming.FunctionCase
value: lower_case

- key: readability-identifier-naming.MethodCase
value: lower_case

- key: readability-identifier-naming.VariableCase
value: lower_case

- key: readability-identifier-naming.PrivateMemberSuffix
value: _

# Magic numbers ignored in common cases
- key: readability-magic-numbers.IgnoredIntegerValues
value: '0;1;2;-1'

# Allow short functions to skip braces rule
- key: readability-braces-around-statements.ShortStatementLines
value: '1'
66 changes: 50 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: CI

on:
push:
branches: [main, develop]
branches: [master, develop]
pull_request:
branches: [main]
branches: [master]
workflow_dispatch:

jobs:
Expand All @@ -30,45 +30,79 @@ jobs:
with:
submodules: true

- name: Set up MSVC (Windows)
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64

- name: Setup vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgJsonGlob: 'vcpkg.json'

- name: Install Ninja & Tools (Linux)
- name: Install Ninja (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y ninja-build
run: |
sudo apt-get update
sudo apt-get install -y ninja-build

- name: Configure CMake
run: cmake --preset ${{ matrix.preset }}
shell: bash
run: |
cmake --preset ${{ matrix.preset }} \
-DCMAKE_TOOLCHAIN_FILE="${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"

- name: Build
run: cmake --build --preset ${{ matrix.preset }} --parallel
- name: Build (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
# Split by the last hyphen to handle names like linux-clang-release
PRESET="${{ matrix.preset }}"
BASE_PRESET="${PRESET%-*}"
CONFIG="${PRESET##*-}"
bash ./scripts/build.sh "$BASE_PRESET" "$CONFIG"

- name: Test
run: ctest --preset ${{ matrix.preset }} --output-on-failure
- name: Build (Windows)
if: runner.os == 'Windows'
shell: cmd
run: |
@echo off
for /f "tokens=1,2,3 delims=-" %%a in ("${{ matrix.preset }}") do (
if "%%c"=="" (
call scripts\build.bat %%a %%b
) else (
call scripts\build.bat %%a-%%b %%c
)
)

# --- Code Quality & Sanitizers ---
analysis:
name: Analysis (Clang-Tidy & ASan)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup vcpkg # Use vcpkg here too for consistency!
- name: Checkout
uses: actions/checkout@v4

- name: Setup vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgJsonGlob: 'vcpkg.json'

- name: Install Tools
run: sudo apt-get update && sudo apt-get install -y ninja-build clang clang-tidy
# ... rest of your cmake commands

run: |
sudo apt-get update
sudo apt-get install -y ninja-build clang clang-tidy

- name: Configure & Build
shell: bash
run: |
cmake -B build -G Ninja \
-DCMAKE_CXX_COMPILER=clang++ \
-DENABLE_SANITIZERS=ON \
-DENABLE_CLANG_TIDY=ON
-DENABLE_CLANG_TIDY=OFF \
-DCMAKE_TOOLCHAIN_FILE="${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
cmake --build build --parallel

- name: Run Tests
shell: bash
run: ctest --test-dir build --output-on-failure
20 changes: 12 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ set(MY_LIB_NAME "${MY_PROJECT_NAME}Core")
project(
${MY_PROJECT_NAME}
VERSION 1.0.0
DESCRIPTION "Universal C++23 Template"
DESCRIPTION "Universal C++20 Template"
LANGUAGES C CXX
)

# Set global C++ standard
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

Expand All @@ -24,17 +24,20 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# -----------------------------------------------------------------------------
# 2. Global Options & Modules
# -----------------------------------------------------------------------------
option(BUILD_BENCHMARKS "Build performance benchmarks" OFF)
option(BUILD_TESTS "Build unit tests" ON)
option(BUILD_SHARED_LIBS "Build libraries as shared" OFF)
# option(BUILD_BENCHMARKS "Build performance benchmarks" OFF)
# option(BUILD_TESTS "Build unit tests" ON)
# option(BUILD_SHARED_LIBS "Build libraries as shared" OFF)
# option(ENABLE_CLANG_TIDY "Enable clang-tidy static analysis" ON)

# Extend module path to find custom scripts in /cmake
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")

# Include Professional Tooling Modules
include(CompilerWarnings) # Sets strict warnings per compiler
include(Sanitizers) # Configures ASan/UBSan
include(StaticAnalyzers) # Configures Clang-Tidy/IWYU
include(ProjectOptions) # Global options and feature toggles
include(ProjectWarnings) # Sets strict warnings per compiler
include(StaticAnalyzers) # Configures Clang-Tidy/IWYU
include(Sanitizers) # Configures ASan/UBSan
include(ClangFormat) # Configures clang-format targets

# -----------------------------------------------------------------------------
# 3. Target Orchestration
Expand Down Expand Up @@ -70,4 +73,5 @@ message(STATUS " Compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VER
message(STATUS " Build Type: ${CMAKE_BUILD_TYPE}")
message(STATUS " Benchmarks: ${BUILD_BENCHMARKS}")
message(STATUS " Tests: ${BUILD_TESTS}")
message(STATUS " Clang Tidy: ${ENABLE_CLANG_TIDY}")
message(STATUS "-----------------------------------------------------------")
34 changes: 26 additions & 8 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"name": "msvc-base",
"displayName": "MSVC",
"hidden": true,
"generator": "Visual Studio 18 2026",
"generator": "Visual Studio 17 2022",
"inherits": "vcpkg-base",
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
},
Expand All @@ -39,7 +39,7 @@
"cacheVariables": {
"CMAKE_C_COMPILER": "clang-cl",
"CMAKE_CXX_COMPILER": "clang-cl",
"CMAKE_LINKER": "link.exe",
"CMAKE_LINKER": "lld-link.exe",
"CMAKE_AR": "llvm-lib.exe"
},
"environment": {
Expand Down Expand Up @@ -86,7 +86,10 @@
},
{
"name": "msvc-release",
"inherits": ["msvc-base", "benchmark-base"],
"inherits": [
"msvc-base",
"benchmark-base"
],
"binaryDir": "${sourceDir}/build/msvc/release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
Expand All @@ -102,7 +105,10 @@
},
{
"name": "clang-cl-release",
"inherits": ["clang-cl-base", "benchmark-base"],
"inherits": [
"clang-cl-base",
"benchmark-base"
],
"binaryDir": "${sourceDir}/build/clang-cl/release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
Expand All @@ -118,7 +124,10 @@
},
{
"name": "mingw-gcc-release",
"inherits": ["mingw-gcc", "benchmark-base"],
"inherits": [
"mingw-gcc",
"benchmark-base"
],
"binaryDir": "${sourceDir}/build/mingw-gcc/release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
Expand All @@ -134,7 +143,10 @@
},
{
"name": "mingw-clang-release",
"inherits": ["mingw-clang", "benchmark-base"],
"inherits": [
"mingw-clang",
"benchmark-base"
],
"binaryDir": "${sourceDir}/build/mingw-clang/release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
Expand All @@ -150,7 +162,10 @@
},
{
"name": "linux-gcc-release",
"inherits": ["linux-gcc", "benchmark-base"],
"inherits": [
"linux-gcc",
"benchmark-base"
],
"binaryDir": "${sourceDir}/build/linux-gcc/release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
Expand All @@ -166,7 +181,10 @@
},
{
"name": "linux-clang-release",
"inherits": ["linux-clang", "benchmark-base"],
"inherits": [
"linux-clang",
"benchmark-base"
],
"binaryDir": "${sourceDir}/build/linux-clang/release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
Expand Down
16 changes: 14 additions & 2 deletions apps/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ add_executable(${APP_TARGET} main.cpp)
target_link_libraries(${APP_TARGET}
PRIVATE
${PROJECT_NAME}::Core
project_options
project_warnings
project_sanitizers
)

if(COMMAND enable_clang_tidy)
enable_clang_tidy(${MY_LIB_NAME})
endif()

# 4. Enforce the "Flat Binary" Output Contract
set_target_properties(${APP_TARGET} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
Expand All @@ -19,5 +26,10 @@ set_target_properties(${APP_TARGET} PROPERTIES
OUTPUT_NAME "app"
)

# 5. Apply your template's strict warning configuration
set_project_warnings(${APP_TARGET})
# 5. Auto-format before build (if enabled)
if(DEFINED AUTO_FORMAT_DEP)
add_dependencies(${APP_TARGET} ${AUTO_FORMAT_DEP})
endif()

# 6. Apply your template's strict warning configuration
#set_project_warnings(${APP_TARGET})
6 changes: 4 additions & 2 deletions apps/app/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include <iostream>
#include "core/hello.hpp"
#include <iostream>

int main()
{
std::cout << core::hello() << std::endl;
std::cout << core::hello() << '\n';
return 0;

}
Loading