Skip to content

Commit a6a371c

Browse files
authored
Merge pull request #11 from emrekovanci/develop
Develop
2 parents c9c3c2b + 5bd2a25 commit a6a371c

20 files changed

+168
-70
lines changed

.clang-format

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
# .clang-format 16
2+
# .clang-format 19
33

44
# Project
55
Language: Cpp
@@ -72,7 +72,10 @@ NamespaceIndentation: All
7272

7373
# Empty lines
7474
EmptyLineBeforeAccessModifier: Always
75-
KeepEmptyLinesAtTheStartOfBlocks: true
75+
KeepEmptyLines:
76+
AtEndOfFile: false
77+
AtStartOfBlock: false
78+
AtStartOfFile: false
7679
MaxEmptyLinesToKeep: 1
7780

7881
# Sorting

.clang-tidy

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,20 @@ Checks: >
1818
-readability-magic-numbers,
1919
-readability-uppercase-literal-suffix,
2020
CheckOptions:
21-
- { key: bugprone-misplaced-widening-cast.CheckImplicitCasts, value: true }
22-
- { key: bugprone-sizeof-expression.WarnOnSizeOfIntegerExpression, value: true }
23-
- { key: bugprone-suspicious-string-compare.WarnOnLogicalNotComparison, value: true }
24-
- { key: readability-uniqueptr-delete-release.PreferResetCall, value: true }
25-
- { key: cppcoreguidelines-narrowing-conversions.PedanticMode, value: true }
21+
- { key: bugprone-argument-comment.StrictMode, value: true }
22+
- { key: bugprone-argument-comment.CommentBoolLiterals, value: true }
23+
- { key: bugprone-misplaced-widening-cast.CheckImplicitCasts, value: true }
24+
- { key: bugprone-sizeof-expression.WarnOnSizeOfIntegerExpression, value: true }
25+
- { key: bugprone-suspicious-string-compare.WarnOnLogicalNotComparison, value: true }
26+
- { key: readability-simplify-boolean-expr.ChainedConditionalReturn, value: true }
27+
- { key: readability-simplify-boolean-expr.ChainedConditionalAssignment, value: true }
28+
- { key: readability-uniqueptr-delete-release.PreferResetCall, value: true }
29+
- { key: cppcoreguidelines-init-variables.MathHeader, value: "<cmath>" }
30+
- { key: cppcoreguidelines-narrowing-conversions.PedanticMode, value: true }
31+
- { key: readability-else-after-return.WarnOnUnfixable, value: true }
32+
- { key: readability-else-after-return.WarnOnConditionVariables, value: true }
33+
- { key: readability-inconsistent-declaration-parameter-name.Strict, value: true }
34+
- { key: readability-qualified-auto.AddConstToQualified, value: true }
2635
# Identifier styles
2736
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
2837
- { key: readability-identifier-naming.FunctionCase, value: camelBack }

.clangd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Style:
1010
- std
1111

1212
InlayHints:
13-
Enabled: No
13+
Enabled: Yes
1414
BlockEnd: Yes
1515
Designators: Yes
1616
ParameterNames: Yes

.github/workflows/ci.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ on:
88
branches:
99
- master
1010
- develop
11-
pull_request:
1211
release:
1312
types: [published]
1413
workflow_dispatch:
@@ -19,10 +18,10 @@ env:
1918

2019
jobs:
2120
lint:
22-
runs-on: ubuntu-22.04
21+
runs-on: ubuntu-24.04
2322

2423
env:
25-
CLANG_FORMAT_VERSION: 17
24+
CLANG_FORMAT_VERSION: 19
2625

2726
steps:
2827
- name: Checkout Code
@@ -73,8 +72,8 @@ jobs:
7372
- { os: windows-2022, generator: vs2022, compiler: llvm, preset: windows-vs2022-clangcl }
7473
- { os: windows-2022, generator: ninja, compiler: msvc, preset: windows-ninja }
7574
- { os: windows-2022, generator: ninja, compiler: llvm, preset: windows-ninja-clangcl }
76-
- { os: ubuntu-22.04, generator: ninja, compiler: gcc, preset: linux-ninja-gcc }
77-
- { os: ubuntu-22.04, generator: ninja, compiler: llvm, preset: linux-ninja-clang }
75+
- { os: ubuntu-24.04, generator: ninja, compiler: gcc, preset: linux-ninja-gcc }
76+
- { os: ubuntu-24.04, generator: ninja, compiler: llvm, preset: linux-ninja-clang }
7877
- { os: macos-13, generator: ninja, compiler: llvm, preset: mac-ninja-clang }
7978
- { os: macos-13, generator: xcode, compiler: llvm, preset: mac-xcode-clang }
8079
config:
@@ -103,7 +102,7 @@ jobs:
103102
env:
104103
VCPKG_ROOT: '~/vcpkg'
105104
shell: bash
106-
run: cmake --preset=${{ matrix.platform.preset }} ${{ matrix.config.flags }} ${{ matrix.type.flags }} -DVCPKG_MANIFEST_FEATURES=tests -DFEATURE_TESTS=ON
105+
run: cmake --preset=${{ matrix.platform.preset }} ${{ matrix.config.flags }} ${{ matrix.type.flags }} -DFEATURE_TESTS=ON
107106

108107
- name: CMake Build
109108
shell: bash

.vscode/extensions.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"recommendations": [
33
"ms-vscode.cmake-tools",
4-
"twxs.cmake",
54
"ms-vscode.cpptools",
65
"llvm-vs-code-extensions.vscode-clangd",
76
"EditorConfig.EditorConfig",

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
cmake_minimum_required(VERSION 3.26)
22

33
include(cmake/PreventInSourceBuilds.cmake)
4+
include(cmake/Features.cmake)
45

56
project(
67
Template-CPP
@@ -10,7 +11,8 @@ project(
1011
LANGUAGES CXX
1112
)
1213

13-
include(cmake/Variables.cmake)
14+
include(cmake/CompilerWarnings.cmake)
15+
include(cmake/LinkerFlags.cmake)
1416

1517
if(FEATURE_TESTS)
1618
enable_testing()

app/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22

33
add_executable(Application App.cpp)
44
target_link_libraries(Application PRIVATE Core)
5+
set_compiler_warnings(Application)
6+
set_linker_flags(Application)
57
install(TARGETS Application)

cmake/CompilerWarnings.cmake

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
function(set_compiler_warnings target)
2+
if(MSVC)
3+
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
4+
set(PROJECT_WARNINGS
5+
-Wall
6+
-Wextra
7+
-Wshadow
8+
-Wpedantic
9+
-Wunused
10+
-Wformat=2
11+
-Wnull-dereference
12+
-Wnon-virtual-dtor
13+
-Woverloaded-virtual
14+
-Wold-style-cast
15+
-Wno-missing-prototypes
16+
-Wno-switch-enum
17+
-Wno-c++98-compat
18+
-Wno-c++98-compat-pedantic
19+
/EHsc)
20+
else()
21+
# Note that all the flags after /W4 are required for MSVC to conform to the language standard
22+
set(PROJECT_WARNINGS
23+
/guard:cf
24+
/utf-8
25+
/diagnostics:caret
26+
/sdl
27+
/W4
28+
/w14165 # 'HRESULT' is being converted to 'bool'; are you sure this is what you want?
29+
/w44242 # 'identifier': conversion from 'type1' to 'type2', possible loss of data
30+
/w44254 # 'operator': conversion from 'type1':'field_bits' to 'type2':'field_bits', possible loss of data
31+
/w44263 # 'function' : member function does not override any base class virtual member function
32+
/w34265 # 'classname': class has virtual functions, but its non-trivial destructor is not virtual; instances of this class may not be destructed correctly
33+
/w34287 # 'operator' : unsigned/negative constant mismatch
34+
/w44296 # 'operator' : expression is always false
35+
/w44388 # 'token' : signed/unsigned mismatch
36+
/w44464 # relative include path contains '..'
37+
/w14545 # expression before comma evaluates to a function which is missing an argument list
38+
/w14546 # function call before comma missing argument list
39+
/w14547 # 'operator' : operator before comma has no effect; expected operator with side-effect
40+
/w14549 # 'operator' : operator before comma has no effect; did you intend 'operator'?
41+
/w14555 # expression has no effect; expected expression with side-effect
42+
/w34619 # #pragma warning : there is no warning number 'number'
43+
/w34640 # 'instance' : construction of local static object is not thread-safe
44+
/w24826 # Conversion from 'type' to 'type' is sign-extended. This may cause unexpected runtime behavior.
45+
/w14905 # wide string literal cast to 'LPSTR'
46+
/w14906 # string literal cast to 'LPWSTR'
47+
/w14928 # illegal copy-initialization; more than one user-defined conversion has been implicitly applied
48+
/w45038 # data member 'member1' will be initialized after data member 'member2', data member 'member' will be initialized after base class 'base_class'
49+
/permissive-
50+
/volatile:iso
51+
/Zc:inline
52+
/Zc:preprocessor
53+
/Zc:enumTypes
54+
/Zc:lambda
55+
/Zc:__cplusplus
56+
/Zc:externConstexpr
57+
/Zc:throwingNew
58+
/EHsc)
59+
endif()
60+
elseif(APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
61+
set(PROJECT_WARNINGS
62+
-fstack-protector-strong
63+
-Wall
64+
-Wextra
65+
-Wpedantic
66+
-Wconversion
67+
-Wsign-conversion
68+
-Wcast-qual
69+
-Wformat=2
70+
-Wundef
71+
-Werror=float-equal
72+
-Wshadow
73+
-Wcast-align
74+
-Wunused
75+
-Wnull-dereference
76+
-Wdouble-promotion
77+
-Wimplicit-fallthrough
78+
-Wextra-semi
79+
-Woverloaded-virtual
80+
-Wnon-virtual-dtor
81+
-Wold-style-cast
82+
)
83+
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
84+
set(PROJECT_WARNINGS
85+
-U_FORTIFY_SOURCE
86+
-D_FORTIFY_SOURCE=3
87+
-D_GLIBCXX_ASSERTIONS=1
88+
-fstack-protector-strong
89+
-fcf-protection=full
90+
-fstack-clash-protection
91+
-Wall
92+
-Wextra
93+
-Wpedantic
94+
-Wconversion
95+
-Wsign-conversion
96+
-Wcast-qual
97+
-Wformat=2
98+
-Wundef
99+
-Werror=float-equal
100+
-Wshadow
101+
-Wcast-align
102+
-Wunused
103+
-Wnull-dereference
104+
-Wdouble-promotion
105+
-Wimplicit-fallthrough
106+
-Wextra-semi
107+
-Woverloaded-virtual
108+
-Wnon-virtual-dtor
109+
-Wold-style-cast
110+
)
111+
else()
112+
message(AUTHOR_WARNING "No compiler warnings set for CXX compiler: '${CMAKE_CXX_COMPILER_ID}'")
113+
endif()
114+
115+
target_compile_options(${target} PRIVATE ${PROJECT_WARNINGS})
116+
endfunction()

cmake/Features.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
option(FEATURE_TESTS "Enable the tests" OFF)
2+
if(FEATURE_TESTS)
3+
list(APPEND VCPKG_MANIFEST_FEATURES "tests")
4+
endif()
5+
6+
if(PROJECT_IS_TOP_LEVEL)
7+
option(BUILD_SHARED_LIBS "Build shared libs." OFF)
8+
endif()

cmake/Format.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ endif()
1717
execute_process(COMMAND ${CLANG_FORMAT_EXECUTABLE} --version OUTPUT_VARIABLE CLANG_FORMAT_VERSION)
1818
string(REGEX MATCH "clang-format version ([0-9]+)" CLANG_FORMAT_VERSION ${CLANG_FORMAT_VERSION})
1919
unset(CLANG_FORMAT_VERSION)
20-
if(NOT CMAKE_MATCH_1 EQUAL 17)
21-
message(FATAL_ERROR "clang-format version ${CMAKE_MATCH_1} not supported. Must use version 17!")
20+
if(NOT CMAKE_MATCH_1 EQUAL 19)
21+
message(FATAL_ERROR "clang-format version ${CMAKE_MATCH_1} not supported. Must use version 19!")
2222
endif()
2323

2424
# ---- Collect project files ----

0 commit comments

Comments
 (0)