From 10dcf38a1942096e3ddc54bccad98b90de2f059f Mon Sep 17 00:00:00 2001 From: Tobias Schmidl Date: Fri, 6 Oct 2023 05:22:15 +0200 Subject: [PATCH 1/7] feat: added editorconfig --- .ecrc | 4 ++++ .ecrc.license | 3 +++ .editorconfig | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 .ecrc create mode 100644 .ecrc.license create mode 100644 .editorconfig diff --git a/.ecrc b/.ecrc new file mode 100644 index 0000000..1dc83fd --- /dev/null +++ b/.ecrc @@ -0,0 +1,4 @@ +{ + "IgnoreDefaults": false, + "Exclude": ["^LICENSE$", "^LICENSES/.*"] +} diff --git a/.ecrc.license b/.ecrc.license new file mode 100644 index 0000000..37bf852 --- /dev/null +++ b/.ecrc.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2023 Tobias Schmidl + +SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..296fecd --- /dev/null +++ b/.editorconfig @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: 2023 Tobias Schmidl +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.{yaml,yml}] +indent_size = 2 -- 2.47.2 From 3165f0ddc52aaecb456f6f88932bf9ddb4c6fc92 Mon Sep 17 00:00:00 2001 From: Tobias Schmidl Date: Fri, 6 Oct 2023 05:22:41 +0200 Subject: [PATCH 2/7] feat: extended pre-commit config --- .pre-commit-config.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 37e2524..577950c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,6 +11,7 @@ repos: - id: trailing-whitespace - id: check-merge-conflict - id: check-ast + - id: check-byte-order-marker - repo: https://github.com/fsfe/reuse-tool rev: v2.1.0 hooks: @@ -29,4 +30,16 @@ repos: hooks: - id: clang-format - id: clang-tidy +- repo: https://github.com/editorconfig-checker/editorconfig-checker.python + rev: '2.7.2' + hooks: + - id: editorconfig-checker + alias: ec + stages: [commit] +repos: +- repo: https://github.com/compilerla/conventional-pre-commit + rev: v2.4.0 + hooks: + - id: conventional-pre-commit + stages: [commit-msg] ... -- 2.47.2 From b09dd1049b5348170996cfd82acb4009ea10dbfd Mon Sep 17 00:00:00 2001 From: Tobias Schmidl Date: Fri, 6 Oct 2023 05:23:07 +0200 Subject: [PATCH 3/7] feat: added missing license --- .pre-commit-config.yaml | 1 - LICENSES/MIT.txt | 9 +++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 LICENSES/MIT.txt diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 577950c..22e4933 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,7 +36,6 @@ repos: - id: editorconfig-checker alias: ec stages: [commit] -repos: - repo: https://github.com/compilerla/conventional-pre-commit rev: v2.4.0 hooks: diff --git a/LICENSES/MIT.txt b/LICENSES/MIT.txt new file mode 100644 index 0000000..2071b23 --- /dev/null +++ b/LICENSES/MIT.txt @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- 2.47.2 From d41b8919e3b9c07629362baed77007bcb5b2e30e Mon Sep 17 00:00:00 2001 From: Tobias Schmidl Date: Fri, 6 Oct 2023 05:24:32 +0200 Subject: [PATCH 4/7] feat: added basic woodpecker config --- .woodpecker.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .woodpecker.yml diff --git a/.woodpecker.yml b/.woodpecker.yml new file mode 100644 index 0000000..dde54e0 --- /dev/null +++ b/.woodpecker.yml @@ -0,0 +1,16 @@ +# SPDX-FileCopyrightText: 2023 Tobias Schmidl +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +--- +steps: + + editor-config: + image: mstruebing/editorconfig-checker + group: lint + + reuse: + image: fsfe/reuse:latest + group: lint + +... -- 2.47.2 From 0eced723483600f08eb0d92a8d7a4af076bf7e40 Mon Sep 17 00:00:00 2001 From: Tobias Schmidl Date: Fri, 6 Oct 2023 05:58:18 +0200 Subject: [PATCH 5/7] fixup! feat: added missing license --- .ecrc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.ecrc b/.ecrc index 1dc83fd..43ccb09 100644 --- a/.ecrc +++ b/.ecrc @@ -1,4 +1,8 @@ { "IgnoreDefaults": false, - "Exclude": ["^LICENSE$", "^LICENSES/.*"] + "Exclude": [ + "^LICENSE$", + "^LICENSES/.*", + "documentation/pages/about.dox" + ] } -- 2.47.2 From 8fd7d8328a05995ed0d6e402c53fcc41c4d22b82 Mon Sep 17 00:00:00 2001 From: Tobias Schmidl Date: Fri, 6 Oct 2023 05:59:01 +0200 Subject: [PATCH 6/7] fix: adopted editorconfig to project needs --- .editorconfig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.editorconfig b/.editorconfig index 296fecd..35187b6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -17,3 +17,9 @@ insert_final_newline = true [*.{yaml,yml}] indent_size = 2 + +[*.{cpp,hpp,h}] +indent_size = 2 + +[{CMakeLists.txt,*.cmake}] +indent_style = tabs -- 2.47.2 From 4aa9978dcd501438cd63805ce7599520b887f99d Mon Sep 17 00:00:00 2001 From: Tobias Schmidl Date: Fri, 6 Oct 2023 06:03:57 +0200 Subject: [PATCH 7/7] style: reformatted to make the CMake scripts more compact --- .cmake-format.yaml | 6 +-- CMakeLists.txt | 31 +++----------- all/CMakeLists.txt | 3 +- cmake/CPM.cmake | 11 +++-- cmake/tools.cmake | 81 ++++++++++++++---------------------- cmake/version-from-git.cmake | 7 +--- 6 files changed, 48 insertions(+), 91 deletions(-) diff --git a/.cmake-format.yaml b/.cmake-format.yaml index 4594291..51a8fd3 100644 --- a/.cmake-format.yaml +++ b/.cmake-format.yaml @@ -3,12 +3,12 @@ # SPDX-License-Identifier: AGPL-3.0-or-later --- format: - line_width: 120 + line_width: 140 tab_size: 4 use_tabchars: true fractional_tab_policy: round-up - max_subgroups_hwrap: 2 - max_pargs_hwrap: 3 + max_subgroups_hwrap: 3 + max_pargs_hwrap: 6 dangle_parens: true dangle_align: prefix min_prefix_chars: 0 diff --git a/CMakeLists.txt b/CMakeLists.txt index cac0369..e8720d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,18 +8,11 @@ include(cmake/version-from-git.cmake) # ---- Project ---- -project( - Glimpses - VERSION ${VERSION_STRING} - LANGUAGES CXX -) +project(Glimpses VERSION ${VERSION_STRING} LANGUAGES CXX) # ---- Include guards ---- if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) - message( - FATAL_ERROR - "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there." - ) + message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there.") endif() # ---- Add dependencies via CPM ---- @@ -30,22 +23,11 @@ include(cmake/CPM.cmake) # PackageProject.cmake will be used to make our target installable CPMAddPackage("gh:TheLartians/PackageProject.cmake@1.8.0") -# CPMAddPackage( NAME fmt GIT_TAG 9.1.0 GITHUB_REPOSITORY fmtlib/fmt OPTIONS "FMT_INSTALL YES" # create an installable -# target ) +# CPMAddPackage( NAME fmt GIT_TAG 9.1.0 GITHUB_REPOSITORY fmtlib/fmt OPTIONS "FMT_INSTALL YES" # create an installable target ) # ---- Add source files ---- -file( - GLOB_RECURSE - headers - CONFIGURE_DEPENDS - "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h" -) -file( - GLOB_RECURSE - sources - CONFIGURE_DEPENDS - "${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp" -) +file(GLOB_RECURSE headers CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h") +file(GLOB_RECURSE sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp") # ---- Create library ---- @@ -60,8 +42,7 @@ target_link_libraries(${PROJECT_NAME} PRIVATE # fmt::fmt ) target_include_directories( - ${PROJECT_NAME} PUBLIC $ - $ + ${PROJECT_NAME} PUBLIC $ $ ) # the location where the project's version header will be placed should match the project's regular header paths diff --git a/all/CMakeLists.txt b/all/CMakeLists.txt index bb66c26..ade8fd0 100644 --- a/all/CMakeLists.txt +++ b/all/CMakeLists.txt @@ -2,8 +2,7 @@ # # SPDX-License-Identifier: CC0-1.0 -# this script adds all subprojects to a single build to allow IDEs understand the full project -# structure. +# this script adds all subprojects to a single build to allow IDEs understand the full project structure. cmake_minimum_required(VERSION 3.14...3.22) diff --git a/cmake/CPM.cmake b/cmake/CPM.cmake index a786712..f606c11 100644 --- a/cmake/CPM.cmake +++ b/cmake/CPM.cmake @@ -6,19 +6,18 @@ set(CPM_DOWNLOAD_VERSION 0.38.5) set(CPM_HASH_SUM "192aa0ccdc57dfe75bd9e4b176bf7fb5692fd2b3e3f7b09c74856fc39572b31c") if(CPM_SOURCE_CACHE) - set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") + set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") elseif(DEFINED ENV{CPM_SOURCE_CACHE}) - set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") + set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") else() - set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake") + set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake") endif() # Expand relative path. This is important if the provided path contains a tilde (~) get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE) -file(DOWNLOAD - https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake - ${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM} +file(DOWNLOAD https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake ${CPM_DOWNLOAD_LOCATION} + EXPECTED_HASH SHA256=${CPM_HASH_SUM} ) include(${CPM_DOWNLOAD_LOCATION}) diff --git a/cmake/tools.cmake b/cmake/tools.cmake index d693dbb..027609b 100644 --- a/cmake/tools.cmake +++ b/cmake/tools.cmake @@ -2,69 +2,52 @@ # # SPDX-License-Identifier: CC0-1.0 -# this file contains a list of tools that can be activated and downloaded on-demand each tool is -# enabled during configuration by passing an additional `-DUSE_=` argument to CMake +# this file contains a list of tools that can be activated and downloaded on-demand each tool is enabled during configuration by passing an +# additional `-DUSE_=` argument to CMake # only activate tools for top level project if(NOT PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) - return() + return() endif() include(${CMAKE_CURRENT_LIST_DIR}/CPM.cmake) -# enables sanitizers support using the the `USE_SANITIZER` flag available values are: Address, -# Memory, MemoryWithOrigins, Undefined, Thread, Leak, 'Address;Undefined' +# enables sanitizers support using the the `USE_SANITIZER` flag available values are: Address, Memory, MemoryWithOrigins, Undefined, Thread, +# Leak, 'Address;Undefined' if(USE_SANITIZER OR USE_STATIC_ANALYZER) - CPMAddPackage("gh:StableCoder/cmake-scripts#1f822d1fc87c8d7720c074cde8a278b44963c354") + CPMAddPackage("gh:StableCoder/cmake-scripts#1f822d1fc87c8d7720c074cde8a278b44963c354") - if(USE_SANITIZER) - include(${cmake-scripts_SOURCE_DIR}/sanitizers.cmake) - endif() + if(USE_SANITIZER) + include(${cmake-scripts_SOURCE_DIR}/sanitizers.cmake) + endif() - if(USE_STATIC_ANALYZER) - if("clang-tidy" IN_LIST USE_STATIC_ANALYZER) - set(CLANG_TIDY - ON - CACHE INTERNAL "" - ) - else() - set(CLANG_TIDY - OFF - CACHE INTERNAL "" - ) - endif() - if("iwyu" IN_LIST USE_STATIC_ANALYZER) - set(IWYU - ON - CACHE INTERNAL "" - ) - else() - set(IWYU - OFF - CACHE INTERNAL "" - ) - endif() - if("cppcheck" IN_LIST USE_STATIC_ANALYZER) - set(CPPCHECK - ON - CACHE INTERNAL "" - ) - else() - set(CPPCHECK - OFF - CACHE INTERNAL "" - ) - endif() + # cmake-lint: disable=C0103 + if(USE_STATIC_ANALYZER) + if("clang-tidy" IN_LIST USE_STATIC_ANALYZER) + set(CLANG_TIDY ON CACHE INTERNAL "") + else() + set(CLANG_TIDY OFF CACHE INTERNAL "") + endif() + if("iwyu" IN_LIST USE_STATIC_ANALYZER) + set(IWYU ON CACHE INTERNAL "") + else() + set(IWYU OFF CACHE INTERNAL "") + endif() + if("cppcheck" IN_LIST USE_STATIC_ANALYZER) + set(CPPCHECK ON CACHE INTERNAL "") + else() + set(CPPCHECK OFF CACHE INTERNAL "") + endif() - include(${cmake-scripts_SOURCE_DIR}/tools.cmake) + include(${cmake-scripts_SOURCE_DIR}/tools.cmake) - clang_tidy(${CLANG_TIDY_ARGS}) - include_what_you_use(${IWYU_ARGS}) - cppcheck(${CPPCHECK_ARGS}) - endif() + clang_tidy(${CLANG_TIDY_ARGS}) + include_what_you_use(${IWYU_ARGS}) + cppcheck(${CPPCHECK_ARGS}) + endif() endif() # enables CCACHE support through the USE_CCACHE flag possible values are: YES, NO or equivalent if(USE_CCACHE) - CPMAddPackage("gh:TheLartians/Ccache.cmake@1.2.3") + CPMAddPackage("gh:TheLartians/Ccache.cmake@1.2.3") endif() diff --git a/cmake/version-from-git.cmake b/cmake/version-from-git.cmake index e25c9ba..06bb60e 100644 --- a/cmake/version-from-git.cmake +++ b/cmake/version-from-git.cmake @@ -12,12 +12,7 @@ execute_process( OUTPUT_STRIP_TRAILING_WHITESPACE ) if(GIT_DESCRIBE_ERROR_CODE EQUAL 0) - string( - REGEX MATCH - "^v?([0-9]+)(\\.([0-9]+))?(\\.([0-9]+))?(\\.([0-9]+))?.*$" - _ - "${GIT_DESCRIBE_VERSION_STRING}" - ) + string(REGEX MATCH "^v?([0-9]+)(\\.([0-9]+))?(\\.([0-9]+))?(\\.([0-9]+))?.*$" _ "${GIT_DESCRIBE_VERSION_STRING}") if(DEFINED CMAKE_MATCH_1) set(VERSION_STRING "${CMAKE_MATCH_1}") if(DEFINED CMAKE_MATCH_3) -- 2.47.2