Skip to content

Commit 5248673

Browse files
committed
Major project refactor
1 parent 142ad57 commit 5248673

38 files changed

+777
-3576
lines changed

.clang-format

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,37 @@
1+
# .clang-format — Based on the Google C++ Style Guide
2+
13
BasedOnStyle: Google
4+
5+
# Indentation & wrapping
26
IndentWidth: 2
7+
TabWidth: 2
8+
UseTab: Never
39
ColumnLimit: 120
4-
AccessModifierOffset: -2
5-
AllowShortFunctionsOnASingleLine: Inline
6-
SortIncludes: true
7-
IncludeBlocks: Preserve
8-
PointerAlignment: Left
9-
DerivePointerAlignment: false
10+
11+
# Brace and paren placement
12+
BreakBeforeBraces: Attach
1013
SpaceBeforeParens: ControlStatements
11-
BreakBeforeBraces: Allman # Or 'Attach' if you prefer brace on same line
14+
15+
# Pointer alignment
16+
PointerAlignment: Right
17+
DerivePointerAlignment: false
18+
19+
# Includes
20+
SortIncludes: true
21+
IncludeBlocks: Regroup
22+
23+
# Alignment tweaks
24+
AlignConsecutiveDeclarations: true
25+
AlignConsecutiveAssignments: true
26+
27+
# Disable column-alignment of trailing comments
28+
AlignTrailingComments: false
29+
30+
# Allow short inline functions on one line
31+
AllowShortFunctionsOnASingleLine: Inline
32+
33+
# Trailing comments
1234
SpacesBeforeTrailingComments: 2
35+
36+
# Maximum empty lines
37+
MaxEmptyLinesToKeep: 1

.clang-tidy

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,47 @@
11
Checks: >
2+
google-*,
23
bugprone-*,
34
clang-analyzer-*,
4-
modernize-*,
5+
clang-analyzer-security.*,
6+
cppcoreguidelines-*,
57
performance-*,
68
readability-*,
7-
cppcoreguidelines-*,
9+
modernize-*,
10+
-google-build-using-namespace,
11+
-google-readability-function-size,
812
-modernize-use-trailing-return-type,
913
-cppcoreguidelines-pro-type-vararg,
1014
-cppcoreguidelines-owning-memory
1115
1216
UseColor: true
13-
WarningsAsErrors: '*'
14-
HeaderFilterRegex: '^(include|src|tests|benchmarks)/'
1517
FormatStyle: file
18+
WarningsAsErrors: '*'
19+
1620
CheckOptions:
17-
- key: modernize-use-nullptr.NullMacros
18-
value: 'NULL'
21+
# Naming conventions (match .clang-format indent/specs)
1922
- key: readability-identifier-naming.VariableCase
23+
value: lower_case
24+
- key: readability-identifier-naming.FunctionCase
2025
value: camelBack
2126
- key: readability-identifier-naming.ClassCase
2227
value: CamelCase
2328
- key: readability-identifier-naming.ConstantCase
2429
value: UPPER_CASE
25-
- key: readability-identifier-naming.ParameterCase
26-
value: camelBack
30+
- key: readability-identifier-naming.MemberCase
31+
value: lower_case
32+
- key: readability-identifier-naming.PrivateMemberPrefix
33+
value: "m_"
34+
35+
# Modernize
36+
- key: modernize-use-nullptr.NullMacros
37+
value: 'NULL'
38+
- key: modernize-use-using.CheckAliases
39+
value: 'true'
40+
41+
# Performance
42+
- key: performance-unnecessary-value-param.AllowedTypes
43+
value: 'std::string,std::vector'
44+
45+
# Readability
46+
- key: readability-braces-around-statements.ShortStatementLines
47+
value: '1'

.vscode/extensions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
"matepek.vscode-catch2-test-adapter",
88
"llvm-vs-code-extensions.vscode-clangd",
99
]
10-
}
10+
}

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@
3131
"editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd",
3232
"editor.formatOnSave": true,
3333
}
34-
}
34+
}

CMakeLists.txt

Lines changed: 50 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,62 @@
11
cmake_minimum_required(VERSION 3.23 FATAL_ERROR)
2-
project(modern_cpp_project LANGUAGES CXX VERSION 0.1.0)
2+
project(modern_cpp LANGUAGES CXX VERSION 0.1.0)
33

4-
# === C++ Standard ===
4+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
5+
6+
# === Project Configuration ===
57
set(CMAKE_CXX_STANDARD 20)
8+
set(CMAKE_CXX_EXTENSIONS OFF)
69
set(CMAKE_CXX_STANDARD_REQUIRED ON)
710

8-
# === Compile Commands ===
9-
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
10-
11-
# === Custom Build Types ===
12-
if(CMAKE_CONFIGURATION_TYPES)
13-
foreach(build_type IN ITEMS Sanitize Coverage)
14-
list(APPEND CMAKE_CONFIGURATION_TYPES ${build_type})
15-
endforeach()
16-
list(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)
17-
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "" FORCE)
18-
endif()
11+
# === Options ===
12+
include(Options)
1913

20-
# === Project Options ===
21-
option(ENABLE_WARNINGS "Enable compiler warnings" ON)
22-
option(ENABLE_STRICT_WARNINGS "Treat warnings as errors" ON)
14+
# === Flags ===
15+
include(CompilerFlags)
2316

24-
option(ENABLE_SANITIZERS "Enable sanitizer instrumentation" OFF)
17+
# === Search All Source Files ===
18+
file(GLOB_RECURSE CORE_SOURCES
19+
CONFIGURE_DEPENDS
20+
src/*.cpp
21+
src/*.hpp
22+
include/*.hpp
23+
)
2524

26-
option(ENABLE_TESTING "Build unit tests" ON)
27-
option(ENABLE_BENCHMARKS "Build benchmarks" ON)
28-
option(ENABLE_COVERAGE "Enable coverage instrumentation" OFF)
25+
set(ALL_SOURCE_FILES ${CORE_SOURCES})
2926

30-
option(BUILD_APP "Build the demo app" ON)
31-
option(BUILD_DOCS "Build Doxygen documentation" ON)
32-
33-
option(ENABLE_CPPCHECK "Enable cppcheck analysis target" ON)
34-
option(ENABLE_CLANG_TIDY "Enable clang-tidy analysis target" ON)
35-
option(ENABLE_CLANG_FORMAT "Enable clang-format target" ON)
36-
37-
# === Normalize Build Type (e.g., for string comparison) ===
38-
if(CMAKE_BUILD_TYPE)
39-
string(TOLOWER "${CMAKE_BUILD_TYPE}" BUILD_TYPE_LOWER)
40-
else()
41-
set(BUILD_TYPE_LOWER "release")
27+
if(ENABLE_TESTING)
28+
file(GLOB_RECURSE TEST_SOURCES
29+
CONFIGURE_DEPENDS
30+
tests/*.cpp
31+
)
32+
list(APPEND ALL_SOURCE_FILES ${TEST_SOURCES})
4233
endif()
4334

44-
# === Auto-toggle Options for Special Build Types ===
45-
if(BUILD_TYPE_LOWER STREQUAL "sanitize")
46-
set(ENABLE_SANITIZERS ON CACHE BOOL "Enable sanitizers" FORCE)
35+
if(ENABLE_BENCHMARKS)
36+
file(GLOB_RECURSE BENCH_SOURCES
37+
CONFIGURE_DEPENDS
38+
benchmarks/*.cpp
39+
)
40+
list(APPEND ALL_SOURCE_FILES ${BENCH_SOURCES})
4741
endif()
4842

49-
if(BUILD_TYPE_LOWER STREQUAL "coverage")
50-
set(ENABLE_COVERAGE ON CACHE BOOL "Enable coverage" FORCE)
51-
set(BUILD_APP OFF CACHE BOOL "Disable building app in coverage builds" FORCE)
52-
set(ENABLE_BENCHMARKS OFF CACHE BOOL "Disable benchmarks in coverage builds" FORCE)
43+
if(BUILD_APP)
44+
file(GLOB_RECURSE APP_SOURCES
45+
CONFIGURE_DEPENDS
46+
app/*.cpp
47+
)
48+
list(APPEND ALL_SOURCE_FILES ${APP_SOURCES})
5349
endif()
5450

55-
# === CMake Module Path ===
56-
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
57-
58-
# === Core Configuration ===
59-
include(options/Warnings)
60-
include(options/Sanitizers)
51+
# === Helpers ===
52+
include(Helpers)
6153

62-
# === Optional Tooling ===
63-
include(tools/Coverage)
64-
include(tools/Cppcheck)
65-
include(tools/ClangTidy)
66-
include(tools/ClangFormat)
54+
# === Core Library ===
55+
add_subdirectory(src)
6756

68-
# === Core library ===
69-
add_subdirectory(src) # modern_cpp_project::math
70-
71-
# === Application ===
57+
# === App ===
7258
if(BUILD_APP)
73-
add_subdirectory(app) # modern_cpp_project_app
59+
add_subdirectory(app)
7460
endif()
7561

7662
# === Unit Tests ===
@@ -84,8 +70,14 @@ if(ENABLE_BENCHMARKS)
8470
add_subdirectory(benchmarks)
8571
endif()
8672

87-
# === Documentation ===
88-
include(tools/Doxygen)
73+
# === Developer Tooling (formatters, linters, etc.) ===
74+
include(Tooling)
75+
76+
# === Coverage ===
77+
include(Coverage)
8978

90-
# === Installation ===
79+
# === Installation & Export ===
9180
include(install/InstallConfig)
81+
82+
# === Packaging ===
83+
include(CPackConfig)

0 commit comments

Comments
 (0)