From 9735d31eb9663232fec421264636ff7a62626b0a Mon Sep 17 00:00:00 2001 From: msclock Date: Sat, 23 Nov 2024 16:29:44 +0800 Subject: [PATCH] chore: remove redundant cmake things and settings (#22) Signed-off-by: msclock --- .clang-format | 228 ---------------------- .clang-tidy | 78 -------- .cppcheck-suppressions.txt | 2 - .pre-commit-config.yaml | 13 -- CMakeLists.txt | 13 -- cmake/ConfigureWarningsAndHardening.cmake | 117 ----------- cmake/vcpkg/ports/python3/portfile.cmake | 3 - cmake/vcpkg/ports/python3/vcpkg.json | 12 -- src/CMakeLists.txt | 12 -- 9 files changed, 478 deletions(-) delete mode 100644 .clang-format delete mode 100644 .clang-tidy delete mode 100644 .cppcheck-suppressions.txt delete mode 100644 cmake/ConfigureWarningsAndHardening.cmake delete mode 100644 cmake/vcpkg/ports/python3/portfile.cmake delete mode 100644 cmake/vcpkg/ports/python3/vcpkg.json delete mode 100644 src/CMakeLists.txt diff --git a/.clang-format b/.clang-format deleted file mode 100644 index a36591a..0000000 --- a/.clang-format +++ /dev/null @@ -1,228 +0,0 @@ ---- -# https://clang.llvm.org/docs/ClangFormatStyleOptions.html ---- -Language: Cpp -# Do not offset access specifiers (public, protected, private) -AccessModifierOffset: -4 -# Align parameters after opening brackets (round, angle, square) -AlignAfterOpenBracket: Align -# Do not align consecutive assignments -AlignConsecutiveAssignments: false -# Do not align consecutive declarations -AlignConsecutiveDeclarations: false -# Align consecutive macros -AlignConsecutiveMacros: true -# Align escaped newlines to the left -AlignEscapedNewlines: Left -# Align operands of binary and ternary expressions horizontally -AlignOperands: true -# Align trailing comments -AlignTrailingComments: true -# Allow all function arguments on the next line -AllowAllArgumentsOnNextLine: false -AllowAllConstructorInitializersOnNextLine: false -AllowAllParametersOfDeclarationOnNextLine: false -# Do not allow short blocks (e.g., while blocks) on a single line -AllowShortBlocksOnASingleLine: false -# Do not allow short case labels on a single line -AllowShortCaseLabelsOnASingleLine: false -# Do not allow non-empty functions defined outside of a class on a single line -AllowShortFunctionsOnASingleLine: Inline -# Do not allow short if statements on a single line -AllowShortIfStatementsOnASingleLine: false -# Do not allow short loop blocks on a single line -AllowShortLoopsOnASingleLine: false -# Do not break after the return type in function definitions, unless it exceeds the column limit -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -# Do not break before multiline strings -AlwaysBreakBeforeMultilineStrings: false -# Always break after template declarations -AlwaysBreakTemplateDeclarations: Yes -# Do not require each function argument to be on a separate line -BinPackArguments: false -# Do not require each function parameter to be on a separate line -BinPackParameters: false -# Configure brace wrapping style -BraceWrapping: - # Do not break after case labels - AfterCaseLabel: false - # Do not break after class definitions - AfterClass: false - # Do not break after control statements - AfterControlStatement: false - # Do not break after enum definitions - AfterEnum: false - # Do not break after function definitions - AfterFunction: false - # Do not break after namespace definitions - AfterNamespace: false - # Do not break after struct definitions - AfterStruct: false - # Do not break after union definitions - AfterUnion: false - # Do not break after extern blocks - AfterExternBlock: false - # Break before catch statements - BeforeCatch: true - # Break before else statements - BeforeElse: true - # Do not break before lambda bodies - BeforeLambdaBody: false - # Break before while statements - BeforeWhile: true - # Do not indent braces - IndentBraces: false - # Allow empty function bodies on a single line - SplitEmptyFunction: false - # Allow empty statements on a single line - SplitEmptyRecord: false - # Allow empty namespaces on a single line - SplitEmptyNamespace: false -# Break before binary operators, except for assignment operators -BreakBeforeBinaryOperators: NonAssignment -# Customize break before braces in BraceWrapping -BreakBeforeBraces: Custom -# Do not break after commas in inheritance lists -BreakBeforeInheritanceComma: false -# Break before colons in inheritance lists, but not before commas -BreakInheritanceList: BeforeColon -# Break before ternary operators -BreakBeforeTernaryOperators: true -# Do not break after commas in constructor initializer lists -BreakConstructorInitializersBeforeComma: false -# Break before colons in constructor initializer lists, but not before commas -BreakConstructorInitializers: BeforeColon -# Allow breaking string literals -BreakStringLiterals: true -# Column limit for each line -ColumnLimit: 120 -CommentPragmas: '^ IWYU pragma:' -# Do not allow different namespaces to be defined on the same line -CompactNamespaces: false -# Constructor initializer lists should either be all on one line or one per line -ConstructorInitializerAllOnOneLineOrOnePerLine: true -# Indent constructor initializer lists by 4 spaces -ConstructorInitializerIndentWidth: 4 -# Indent continuation lines by 4 spaces -ContinuationIndentWidth: 4 -# No spaces around variable initialization lists -Cpp11BracedListStyle: true -DerivePointerAlignment: true -DisableFormat: false -ExperimentalAutoDetectBinPacking: false -# Automatically add comments at the end of namespaces -FixNamespaceComments: true -ForEachMacros: - - foreach - - Q_FOREACH - - BOOST_FOREACH -IncludeBlocks: Preserve -IncludeCategories: - - Regex: ^ - Priority: 2 - - Regex: StdAfx.h - Priority: -1 - - Regex: ^<.*\.h> - Priority: 1 - - Regex: ^<.* - Priority: 2 - - Regex: .* - Priority: 3 -IncludeIsMainRegex: ([-_](test|unittest))?$ -# Indent case labels inside switch statements -IndentCaseLabels: true -# Indent code blocks inside extern blocks -IndentExternBlock: Indent -# Do not indent preprocessor directives -IndentPPDirectives: None -# Use 4 spaces for indentation -IndentWidth: 4 -# Do not indent wrapped function names after the return type -IndentWrappedFunctionNames: false -# Do not keep empty lines at the start of code blocks -KeepEmptyLinesAtTheStartOfBlocks: false -MacroBlockBegin: '' -MacroBlockEnd: '' -# Do not allow consecutive empty lines -MaxEmptyLinesToKeep: 1 -# Do not indent contents inside namespaces -NamespaceIndentation: None -PenaltyBreakAssignment: 2 -PenaltyBreakBeforeFirstCallParameter: 1 -PenaltyBreakComment: 300 -PenaltyBreakFirstLessLess: 120 -PenaltyBreakString: 1000 -PenaltyBreakTemplateDeclaration: 10 -PenaltyExcessCharacter: 1000000 -PenaltyReturnTypeOnItsOwnLine: 200 -# * and & should be placed next to the type name -PointerAlignment: Left -RawStringFormats: - - Language: Cpp - Delimiters: - - cc - - CC - - cpp - - Cpp - - CPP - - c++ - - C++ - CanonicalDelimiter: '' - BasedOnStyle: google - - Language: TextProto - Delimiters: - - pb - - PB - - proto - - PROTO - EnclosingFunctions: - - EqualsProto - - EquivToProto - - PARSE_PARTIAL_TEXT_PROTO - - PARSE_TEST_PROTO - - PARSE_TEXT_PROTO - - ParseTextOrDie - - ParseTextProtoOrDie - CanonicalDelimiter: '' - BasedOnStyle: google -# Allow reflowing of comments -ReflowComments: true -# Allow sorting of #include statements -SortIncludes: true -# Allow sorting of using declarations -SortUsingDeclarations: true -# Do not include spaces after C-style casts -SpaceAfterCStyleCast: false -# Require a space after the template keyword -SpaceAfterTemplateKeyword: true -# Require spaces around assignment operators -SpaceBeforeAssignmentOperators: true -# Do not include spaces before C++11 braced initializer lists -SpaceBeforeCpp11BracedList: false -# Require a space before the colon in constructor initializers -SpaceBeforeCtorInitializerColon: true -# Require a space before the colon in inheritance statements -SpaceBeforeInheritanceColon: true -# Require a space after control statement keywords (if, for, while, etc.) -SpaceBeforeParens: ControlStatements -# Require a space before the colon in range-based for loops -SpaceBeforeRangeBasedForLoopColon: true -# Do not include spaces inside empty parentheses -SpaceInEmptyParentheses: false -# Require a space before // in trailing comments -SpacesBeforeTrailingComments: 1 -# Do not include spaces around angle brackets -SpacesInAngles: false -# Do not include spaces around C-style cast parentheses -SpacesInCStyleCastParentheses: false -# Do not include spaces around parentheses -SpacesInParentheses: false -# Do not include spaces around square brackets -SpacesInSquareBrackets: false -Standard: Auto -StatementMacros: - - Q_UNUSED - - QT_REQUIRE_VERSION -TabWidth: 4 -UseTab: Never diff --git a/.clang-tidy b/.clang-tidy deleted file mode 100644 index 820d51d..0000000 --- a/.clang-tidy +++ /dev/null @@ -1,78 +0,0 @@ -Checks: > - *, - -abseil-*, - -altera-*, - -android-*, - -boost-*, - -cert-*, - -cppcoreguidelines-*, - -darwin-*, - -fuchsia-*, - -google-*, - -hicpp-*, - -linuxkernel-*, - -llvm-*, - -llvmlibc-*, - -mpi-*, - -objc-*, - -openmp-*, - -zircon-*, - cert-err34-c, - google-explicit-constructor, - cppcoreguidelines-rvalue-reference-param-not-moved, - -bugprone-assignment-in-if-condition, - -bugprone-branch-clone, - -bugprone-easily-swappable-parameters, - -bugprone-empty-catch, - -bugprone-macro-parentheses, - -bugprone-narrowing-conversions, - -bugprone-signed-char-misuse, - -bugprone-switch-missing-default-case, - -bugprone-unchecked-optional-access, - -clang-analyzer-*, - -concurrency-mt-unsafe, - -misc-const-correctness, - -misc-no-recursion, - -misc-non-private-member-variables-in-classes, - -misc-throw-by-value-catch-by-reference, - -misc-use-anonymous-namespace, - -misc-include-cleaner, - -misc-unused-using-decls, - -modernize-avoid-c-arrays, - -modernize-deprecated-ios-base-aliases, - -modernize-loop-convert, - -modernize-macro-to-enum, - -modernize-raw-string-literal, - -modernize-replace-auto-ptr, - -modernize-return-braced-init-list, - -modernize-type-traits, - -modernize-use-auto, - -modernize-use-nodiscard, - -modernize-use-trailing-return-type, - -modernize-concat-nested-namespaces, - -performance-avoid-endl, - -performance-enum-size, - -performance-inefficient-string-concatenation, - -performance-no-automatic-move, - -performance-noexcept-swap, - -portability-simd-intrinsics, - -portability-std-allocator-const, - -readability-avoid-const-params-in-decls, - -readability-avoid-nested-conditional-operator, - -readability-braces-around-statements, - -readability-container-data-pointer, - -readability-function-cognitive-complexity, - -readability-function-size, - -readability-identifier-length, - -readability-identifier-naming, - -readability-implicit-bool-conversion, - -readability-isolate-declaration, - -readability-magic-numbers, - -readability-suspicious-call-argument, - -readability-uppercase-literal-suffix -HeaderFilterRegex: (src)\/[a-z]+\.hpp -CheckOptions: - - key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic - value: '1' - - key: readability-simplify-boolean-expr.SimplifyDeMorgan - value: '0' diff --git a/.cppcheck-suppressions.txt b/.cppcheck-suppressions.txt deleted file mode 100644 index 3384b4a..0000000 --- a/.cppcheck-suppressions.txt +++ /dev/null @@ -1,2 +0,0 @@ -// Limit analysis of branches. Use --check-level=exhaustive to analyze all branches. -normalCheckLevelMaxBranches diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f22ce10..8ba6acf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -115,19 +115,6 @@ repos: - --check-filenames - --write-changes - # Check for common shell mistakes - - repo: https://github.com/shellcheck-py/shellcheck-py - rev: v0.9.0.6 - hooks: - - id: shellcheck - - # Clang format the codebase automatically - - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v18.1.8 - hooks: - - id: clang-format - types_or: [c++, c, cuda] - # Check for renovate config - repo: https://github.com/renovatebot/pre-commit-hooks rev: 38.110.2 diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d8d6f0..fff1bf9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,19 +26,6 @@ set(CMAKE_CXX_EXTENSIONS OFF CACHE BOOL "C++ extensions") -# Source includes from vcpkg -include_directories(${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include) - -# From https://github.com/msclock/cmake-registry. -find_package(cmake-modules REQUIRED) -include(cmake-modules/ProjectDefault) - -# Project custom modules -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -include(ConfigureWarningsAndHardening) - -add_subdirectory(src) - find_program(cppcheck NAMES "cppcheck" "cppcheck.exe") install(PROGRAMS ${cppcheck} DESTINATION ${SKBUILD_PROJECT_NAME}/Cppcheck) diff --git a/cmake/ConfigureWarningsAndHardening.cmake b/cmake/ConfigureWarningsAndHardening.cmake deleted file mode 100644 index 784fd89..0000000 --- a/cmake/ConfigureWarningsAndHardening.cmake +++ /dev/null @@ -1,117 +0,0 @@ -#[[ -This file configures the following things: - - dynamic tools: sanitizers, valgrind. - - static tools: clang-tidy, cppcheck. - - compiler flags - - hardening options - -]] - -include_guard(GLOBAL) - -# ############################################################################## -# Sanitizer -# ############################################################################## - -set(USE_SANITIZER - OFF - CACHE BOOL "Enable sanitizer") - -include(cmake-modules/build/Sanitizer) - -# ############################################################################## -# Valgrind -# ############################################################################## - -set(USE_VALGRIND - OFF - CACHE BOOL "Enable Valgrind") -set(USE_VALGRIND_OPTIONS - --leak-check=full # Each individual leak will be shown in detail. - --show-leak-kinds=all # Show all of "definite, indirect, possible, - # reachable" leak kinds in the "full" report. - --gen-suppressions=all # gen suppress info automatically. - --track-origins=yes # Favor useful output over speed. This tracks the - # origins of uninitialized values, which could be very - # useful for memory errors. Consider turning off if - # Valgrind is unacceptably slow. - CACHE STRING "valgrind options.") - -include(cmake-modules/test/Valgrind) - -# ############################################################################## -# Clang-Tidy -# ############################################################################## - -set(USE_CLANGTIDY - OFF - CACHE BOOL "Enable Clang-Tidy") - -include(cmake-modules/build/ClangTidy) - -# ############################################################################## -# Cppcheck -# ############################################################################## - -set(USE_CPPCHECK - OFF - CACHE BOOL "Enable Cppcheck") -set(USE_CPPCHECK_SUPPRESSION_FILE - ${CMAKE_SOURCE_DIR}/.cppcheck-suppressions.txt - CACHE STRING - "Customize the path to the Cppcheck suppressions file of the project") - -include(cmake-modules/build/Cppcheck) - -# ############################################################################## -# CompilerFlags -# ############################################################################## - -include(cmake-modules/build/CompilerFlags) - -# ############################################################################## -# Hardening -# ############################################################################## - -set(USE_HARDENING_FLAGS - -D_GLIBCXX_ASSERTIONS # Enable assertions - -U_FORTIFY_SOURCE # Disable stack protector - -D_FORTIFY_SOURCE=3 # Enable stack protector - -fstack-protector-strong # Enable stack protector - -fcf-protection # Control Flow Guard - -fstack-clash-protection # Control Flow Guard - -Wimplicit-fallthrough # Enabled in compiler flags by default - -fstrict-flex-arrays=3 # Enable strict array bounds - -Wformat # Enabled in compiler flags by default - -Wformat=2 # Enabled in compiler flags by default - # -Wl,-z,nodlopen # Restrict dlopen(3) calls to shared objects - -Wl,-z,noexecstack # Enable data execution prevention by marking stack - # memory as non-executable - -Wl,-z,relro # Mark relocation table entries resolved at load-time as - # read-only - -Wl,-z,now # Mark relocation table entries resolved at load-time as - # read-only. It impacts startup performance - "-fsanitize=undefined -fsanitize-minimal-runtime" # Enable minimal runtime - # undefined behavior sanitizer - -fno-delete-null-pointer-checks - -fno-strict-overflow - -fno-strict-aliasing - -ftrivial-auto-var-init=zero - -Wtrampolines # Enable trampolines(gcc only) - -mbranch-protection=standard # Enable indirect branches(aarch64 only) - CACHE STRING "Additional hardening compilation flags for GCC/Clang") - -set(USE_HARDENING_LINKS - -fstack-protector-strong # Enable stack protector - "-fsanitize=undefined -fsanitize-minimal-runtime" # Enable minimal runtime - # undefined behavior sanitizer -Wl,-z,nodlopen # Restrict dlopen(3) calls to - # shared objects - -Wl,-z,noexecstack # Enable data execution prevention by marking stack - # memory as non-executable - -Wl,-z,relro # Mark relocation table entries resolved at load-time as - # read-only - -Wl,-z,now # Mark relocation table entries resolved at load-time as - # read-only. It impacts startup performance - CACHE STRING "Additional hardening linking flags for GCC/Clang") - -include(cmake-modules/build/Hardening) diff --git a/cmake/vcpkg/ports/python3/portfile.cmake b/cmake/vcpkg/ports/python3/portfile.cmake deleted file mode 100644 index bd750d8..0000000 --- a/cmake/vcpkg/ports/python3/portfile.cmake +++ /dev/null @@ -1,3 +0,0 @@ -message(WARNING "Using fake python3 to force system libraries.") - -set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/cmake/vcpkg/ports/python3/vcpkg.json b/cmake/vcpkg/ports/python3/vcpkg.json deleted file mode 100644 index e0f89a8..0000000 --- a/cmake/vcpkg/ports/python3/vcpkg.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "python3", - "version": "3.11.8", - "description": "The Python programming language", - "homepage": "https://github.com/python/cpython", - "license": "Python-2.0", - "features": { - "deprecated-win7-support": { - "description": "Deprecated support for the Windows 7 platform -- may be removed at any time." - } - } -} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index 3b11226..0000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -file( - GLOB _sub_dirs - RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/*) - -foreach(_sub_dir ${_sub_dirs}) - if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_sub_dir}/CMakeLists.txt") - add_subdirectory(${_sub_dir}) - endif() -endforeach() - -unset(_sub_dirs)