Compare commits
No commits in common. "develop" and "master" have entirely different histories.
25 changed files with 204 additions and 284 deletions
|
@ -1,9 +1,9 @@
|
||||||
# SPDX-FileCopyrightText: 2025 Tobias Schmidl
|
# SPDX-FileCopyrightText: 2023 Tobias Schmidl
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
---
|
---
|
||||||
BasedOnStyle: Microsoft
|
BasedOnStyle: Mozilla
|
||||||
AlwaysBreakTemplateDeclarations: true
|
|
||||||
IndentWidth: 4
|
IndentWidth: 4
|
||||||
...
|
...
|
||||||
|
# vim: set filetype=yaml:
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
# SPDX-FileCopyrightText: 2025 Tobias Schmidl
|
# SPDX-FileCopyrightText: 2023 Tobias Schmidl
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
---
|
---
|
||||||
format:
|
format:
|
||||||
line_width: 140
|
line_width: 120
|
||||||
tab_size: 4
|
tab_size: 4
|
||||||
use_tabchars: true
|
use_tabchars: true
|
||||||
fractional_tab_policy: round-up
|
fractional_tab_policy: round-up
|
||||||
max_subgroups_hwrap: 3
|
max_subgroups_hwrap: 2
|
||||||
max_pargs_hwrap: 6
|
max_pargs_hwrap: 3
|
||||||
dangle_parens: true
|
dangle_parens: true
|
||||||
dangle_align: prefix
|
dangle_align: prefix
|
||||||
min_prefix_chars: 0
|
min_prefix_chars: 0
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: 2025 Tobias Schmidl
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
||||||
//
|
|
||||||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
|
|
||||||
// README at: https://github.com/devcontainers/templates/tree/main/src/cpp
|
|
||||||
{
|
|
||||||
"name": "glimpses-devcontainer",
|
|
||||||
"image": "mcr.microsoft.com/devcontainers/cpp:1",
|
|
||||||
// Features to add to the dev container. More info: https://containers.dev/features.
|
|
||||||
"features": {
|
|
||||||
"ghcr.io/devcontainers-extra/features/cmake:1": {},
|
|
||||||
"ghcr.io/devcontainers-extra/features/pre-commit:2": {},
|
|
||||||
"ghcr.io/devcontainers/features/common-utils:2": {
|
|
||||||
"username": "vscode",
|
|
||||||
"uid": "${localEnv:UID}",
|
|
||||||
"gid": "${localEnv:GID}"
|
|
||||||
},
|
|
||||||
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
|
|
||||||
"ghcr.io/devcontainers/features/git:1": {},
|
|
||||||
"ghcr.io/devcontainers/features/python:1": {}
|
|
||||||
},
|
|
||||||
// Configure tool-specific properties.
|
|
||||||
"customizations": {
|
|
||||||
// Configure properties specific to VS Code.
|
|
||||||
"vscode": {
|
|
||||||
"settings": {},
|
|
||||||
"extensions": [
|
|
||||||
"editorconfig.editorconfig",
|
|
||||||
"elagil.pre-commit-helper",
|
|
||||||
"llvm-vs-code-extensions.vscode-clangd",
|
|
||||||
"ms-vscode.cmake-tools",
|
|
||||||
"ms-vscode.cpptools",
|
|
||||||
"streetsidesoftware.code-spell-checker",
|
|
||||||
"vivaxy.vscode-conventional-commits"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"containerEnv": {
|
|
||||||
"CC": "clang",
|
|
||||||
"CXX": "clang++",
|
|
||||||
"CMAKE_BUILD_PARALLEL_LEVEL": "${localEnv:NUMBER_OF_PROCESSORS}",
|
|
||||||
"CMAKE_C_COMPILER": "clang",
|
|
||||||
"CMAKE_CXX_COMPILER": "clang++",
|
|
||||||
"CMAKE_EXPORT_COMPILE_COMMANDS": "1",
|
|
||||||
"CMAKE_PREFIX_PATH": "/usr/local/cmake"
|
|
||||||
},
|
|
||||||
"mounts": [
|
|
||||||
"source=${localEnv:HOME}/.ssh,target=/home/vscode/.ssh,type=bind,readonly",
|
|
||||||
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"
|
|
||||||
],
|
|
||||||
"workspaceMount": "source=${localWorkspaceFolder},target=${localWorkspaceFolder},type=bind",
|
|
||||||
"workspaceFolder": "${localWorkspaceFolder}"
|
|
||||||
}
|
|
8
.ecrc
8
.ecrc
|
@ -1,8 +0,0 @@
|
||||||
{
|
|
||||||
"IgnoreDefaults": false,
|
|
||||||
"Exclude": [
|
|
||||||
"^LICENSE$",
|
|
||||||
"^LICENSES/.*",
|
|
||||||
"documentation/pages/about.dox"
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
SPDX-FileCopyrightText: 2025 Tobias Schmidl
|
|
||||||
|
|
||||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
@ -1,25 +0,0 @@
|
||||||
# SPDX-FileCopyrightText: 2025 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
|
|
||||||
|
|
||||||
[*.{cpp,hpp,h}]
|
|
||||||
indent_size = 2
|
|
||||||
|
|
||||||
[{CMakeLists.txt,*.cmake}]
|
|
||||||
indent_style = tabs
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,4 +1,4 @@
|
||||||
# SPDX-FileCopyrightText: 2025 Tobias Schmidl
|
# SPDX-FileCopyrightText: 2023 Tobias Schmidl
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
# SPDX-FileCopyrightText: 2025 Tobias Schmidl
|
# SPDX-FileCopyrightText: 2023 Tobias Schmidl
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
---
|
---
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v5.0.0
|
rev: v4.4.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: check-yaml
|
- id: check-yaml
|
||||||
- id: end-of-file-fixer
|
- id: end-of-file-fixer
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
- id: check-merge-conflict
|
- id: check-merge-conflict
|
||||||
- id: check-ast
|
- id: check-ast
|
||||||
- id: check-byte-order-marker
|
|
||||||
- repo: https://github.com/fsfe/reuse-tool
|
- repo: https://github.com/fsfe/reuse-tool
|
||||||
rev: v5.0.2
|
rev: v2.1.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: reuse
|
- id: reuse
|
||||||
- repo: https://github.com/cheshirekow/cmake-format-precommit
|
- repo: https://github.com/cheshirekow/cmake-format-precommit
|
||||||
|
@ -30,23 +29,4 @@ repos:
|
||||||
hooks:
|
hooks:
|
||||||
- id: clang-format
|
- id: clang-format
|
||||||
- id: clang-tidy
|
- id: clang-tidy
|
||||||
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
|
|
||||||
rev: '3.2.1'
|
|
||||||
hooks:
|
|
||||||
- id: editorconfig-checker
|
|
||||||
alias: ec
|
|
||||||
stages: [pre-commit]
|
|
||||||
- repo: https://github.com/shellcheck-py/shellcheck-py
|
|
||||||
rev: v0.10.0.1
|
|
||||||
hooks:
|
|
||||||
- id: shellcheck
|
|
||||||
- repo: https://github.com/compilerla/conventional-pre-commit
|
|
||||||
rev: v4.2.0
|
|
||||||
hooks:
|
|
||||||
- id: conventional-pre-commit
|
|
||||||
stages: [commit-msg]
|
|
||||||
- repo: https://github.com/igorshubovych/markdownlint-cli
|
|
||||||
rev: v0.45.0
|
|
||||||
hooks:
|
|
||||||
- id: markdownlint
|
|
||||||
...
|
...
|
||||||
|
|
12
.vscode/extensions.json
vendored
12
.vscode/extensions.json
vendored
|
@ -1,12 +0,0 @@
|
||||||
{
|
|
||||||
"recommendations": [
|
|
||||||
"cschlosser.doxdocgen",
|
|
||||||
"editorconfig.editorconfig",
|
|
||||||
"elagil.pre-commit-helper",
|
|
||||||
"llvm-vs-code-extensions.vscode-clangd",
|
|
||||||
"ms-vscode.cmake-tools",
|
|
||||||
"ms-vscode.cpptools",
|
|
||||||
"streetsidesoftware.code-spell-checker",
|
|
||||||
"vivaxy.vscode-conventional-commits"
|
|
||||||
]
|
|
||||||
}
|
|
3
.vscode/extensions.json.license
vendored
3
.vscode/extensions.json.license
vendored
|
@ -1,3 +0,0 @@
|
||||||
SPDX-FileCopyrightText: 2025 Tobias Schmidl
|
|
||||||
|
|
||||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
@ -1,4 +1,4 @@
|
||||||
# SPDX-FileCopyrightText: 2025 Tobias Schmidl
|
# SPDX-FileCopyrightText: 2023 Tobias Schmidl
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
@ -8,26 +8,44 @@ include(cmake/version-from-git.cmake)
|
||||||
|
|
||||||
# ---- Project ----
|
# ---- Project ----
|
||||||
|
|
||||||
project(Glimpses VERSION ${VERSION_STRING} LANGUAGES CXX)
|
project(
|
||||||
|
Glimpses
|
||||||
|
VERSION ${VERSION_STRING}
|
||||||
|
LANGUAGES CXX
|
||||||
|
)
|
||||||
|
|
||||||
# ---- Include guards ----
|
# ---- Include guards ----
|
||||||
if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
|
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()
|
endif()
|
||||||
|
|
||||||
# ---- Add dependencies via CPM ----
|
# ---- Add dependencies via CPM ----
|
||||||
# see https://github.com/TheLartians/CPM.cmake for more info
|
# see https://github.com/TheLartians/CPM.cmake for more info
|
||||||
|
|
||||||
include(cmake/get_cpm.cmake)
|
include(cmake/CPM.cmake)
|
||||||
|
|
||||||
# PackageProject.cmake will be used to make our target installable
|
# PackageProject.cmake will be used to make our target installable
|
||||||
CPMAddPackage("gh:TheLartians/PackageProject.cmake@1.8.0")
|
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 ----
|
# ---- Add source files ----
|
||||||
file(GLOB_RECURSE headers CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
|
file(
|
||||||
file(GLOB_RECURSE sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp")
|
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 ----
|
# ---- Create library ----
|
||||||
|
|
||||||
|
@ -42,7 +60,8 @@ target_link_libraries(${PROJECT_NAME} PRIVATE # fmt::fmt
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include/${PROJECT_NAME}-${PROJECT_VERSION}>
|
${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
|
||||||
|
$<INSTALL_INTERFACE:include/${PROJECT_NAME}-${PROJECT_VERSION}>
|
||||||
)
|
)
|
||||||
|
|
||||||
# the location where the project's version header will be placed should match the project's regular header paths
|
# the location where the project's version header will be placed should match the project's regular header paths
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) <year> <copyright holders>
|
|
||||||
|
|
||||||
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.
|
|
|
@ -1,11 +1,9 @@
|
||||||
<!--
|
<!--
|
||||||
SPDX-FileCopyrightText: 2025 Tobias Schmidl
|
SPDX-FileCopyrightText: 2023 Tobias Schmidl
|
||||||
|
|
||||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
-->
|
-->
|
||||||
|
|
||||||
# glimpses
|
# glimpses
|
||||||
|
|
||||||
[](https://pre-commit.com/)
|
|
||||||
|
|
||||||
T.B.D.
|
T.B.D.
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: CC0-1.0
|
# 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)
|
cmake_minimum_required(VERSION 3.14...3.22)
|
||||||
|
|
||||||
|
|
24
cmake/CPM.cmake
Normal file
24
cmake/CPM.cmake
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
#
|
||||||
|
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors
|
||||||
|
|
||||||
|
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")
|
||||||
|
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
|
||||||
|
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")
|
||||||
|
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}
|
||||||
|
)
|
||||||
|
|
||||||
|
include(${CPM_DOWNLOAD_LOCATION})
|
|
@ -1,23 +0,0 @@
|
||||||
# SPDX-License-Identifier: MIT
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors
|
|
||||||
|
|
||||||
set(CPM_DOWNLOAD_VERSION 0.42.0)
|
|
||||||
set(CPM_HASH_SUM "2020b4fc42dba44817983e06342e682ecfc3d2f484a581f11cc5731fbe4dce8a")
|
|
||||||
|
|
||||||
if(CPM_SOURCE_CACHE)
|
|
||||||
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")
|
|
||||||
else()
|
|
||||||
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}
|
|
||||||
)
|
|
||||||
|
|
||||||
include(${CPM_DOWNLOAD_LOCATION})
|
|
|
@ -2,52 +2,69 @@
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: CC0-1.0
|
# 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
|
# this file contains a list of tools that can be activated and downloaded on-demand each tool is
|
||||||
# additional `-DUSE_<TOOL>=<VALUE>` argument to CMake
|
# enabled during configuration by passing an additional `-DUSE_<TOOL>=<VALUE>` argument to CMake
|
||||||
|
|
||||||
# only activate tools for top level project
|
# only activate tools for top level project
|
||||||
if(NOT PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
if(NOT PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/get_cpm.cmake)
|
include(${CMAKE_CURRENT_LIST_DIR}/CPM.cmake)
|
||||||
|
|
||||||
# enables sanitizers support using the the `USE_SANITIZER` flag available values are: Address, Memory, MemoryWithOrigins, Undefined, Thread,
|
# enables sanitizers support using the the `USE_SANITIZER` flag available values are: Address,
|
||||||
# Leak, 'Address;Undefined'
|
# Memory, MemoryWithOrigins, Undefined, Thread, Leak, 'Address;Undefined'
|
||||||
if(USE_SANITIZER OR USE_STATIC_ANALYZER)
|
if(USE_SANITIZER OR USE_STATIC_ANALYZER)
|
||||||
CPMAddPackage("gh:StableCoder/cmake-scripts#1f822d1fc87c8d7720c074cde8a278b44963c354")
|
CPMAddPackage("gh:StableCoder/cmake-scripts#1f822d1fc87c8d7720c074cde8a278b44963c354")
|
||||||
|
|
||||||
if(USE_SANITIZER)
|
if(USE_SANITIZER)
|
||||||
include(${cmake-scripts_SOURCE_DIR}/sanitizers.cmake)
|
include(${cmake-scripts_SOURCE_DIR}/sanitizers.cmake)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# cmake-lint: disable=C0103
|
if(USE_STATIC_ANALYZER)
|
||||||
if(USE_STATIC_ANALYZER)
|
if("clang-tidy" IN_LIST USE_STATIC_ANALYZER)
|
||||||
if("clang-tidy" IN_LIST USE_STATIC_ANALYZER)
|
set(CLANG_TIDY
|
||||||
set(CLANG_TIDY ON CACHE INTERNAL "")
|
ON
|
||||||
else()
|
CACHE INTERNAL ""
|
||||||
set(CLANG_TIDY OFF CACHE INTERNAL "")
|
)
|
||||||
endif()
|
else()
|
||||||
if("iwyu" IN_LIST USE_STATIC_ANALYZER)
|
set(CLANG_TIDY
|
||||||
set(IWYU ON CACHE INTERNAL "")
|
OFF
|
||||||
else()
|
CACHE INTERNAL ""
|
||||||
set(IWYU OFF CACHE INTERNAL "")
|
)
|
||||||
endif()
|
endif()
|
||||||
if("cppcheck" IN_LIST USE_STATIC_ANALYZER)
|
if("iwyu" IN_LIST USE_STATIC_ANALYZER)
|
||||||
set(CPPCHECK ON CACHE INTERNAL "")
|
set(IWYU
|
||||||
else()
|
ON
|
||||||
set(CPPCHECK OFF CACHE INTERNAL "")
|
CACHE INTERNAL ""
|
||||||
endif()
|
)
|
||||||
|
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})
|
clang_tidy(${CLANG_TIDY_ARGS})
|
||||||
include_what_you_use(${IWYU_ARGS})
|
include_what_you_use(${IWYU_ARGS})
|
||||||
cppcheck(${CPPCHECK_ARGS})
|
cppcheck(${CPPCHECK_ARGS})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# enables CCACHE support through the USE_CCACHE flag possible values are: YES, NO or equivalent
|
# enables CCACHE support through the USE_CCACHE flag possible values are: YES, NO or equivalent
|
||||||
if(USE_CCACHE)
|
if(USE_CCACHE)
|
||||||
CPMAddPackage("gh:TheLartians/Ccache.cmake@1.2.3")
|
CPMAddPackage("gh:TheLartians/Ccache.cmake@1.2.3")
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -12,7 +12,12 @@ execute_process(
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
)
|
)
|
||||||
if(GIT_DESCRIBE_ERROR_CODE EQUAL 0)
|
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)
|
if(DEFINED CMAKE_MATCH_1)
|
||||||
set(VERSION_STRING "${CMAKE_MATCH_1}")
|
set(VERSION_STRING "${CMAKE_MATCH_1}")
|
||||||
if(DEFINED CMAKE_MATCH_3)
|
if(DEFINED CMAKE_MATCH_3)
|
||||||
|
|
|
@ -8,9 +8,9 @@ project(GlimpsesDocs)
|
||||||
|
|
||||||
# ---- Dependencies ----
|
# ---- Dependencies ----
|
||||||
|
|
||||||
include(../cmake/get_cpm.cmake)
|
include(../cmake/CPM.cmake)
|
||||||
|
|
||||||
CPMAddPackage("gh:mosra/m.css#0a460a7a9973a41db48f735e7b49e4da9a876325")
|
CPMAddPackage("gh:mosra/m.css#a0d292ec311b97fefd21e93cdefb60f88d19ede6")
|
||||||
CPMAddPackage(NAME Glimpses SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/..)
|
CPMAddPackage(NAME Glimpses SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/..)
|
||||||
|
|
||||||
# ---- Doxygen variables ----
|
# ---- Doxygen variables ----
|
||||||
|
@ -28,7 +28,10 @@ configure_file(${CMAKE_CURRENT_LIST_DIR}/conf.py ${CMAKE_CURRENT_BINARY_DIR}/con
|
||||||
# cmake-lint: disable=C0113
|
# cmake-lint: disable=C0113
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
GenerateDocs
|
GenerateDocs
|
||||||
${CMAKE_COMMAND} -E make_directory "${DOXYGEN_OUTPUT_DIRECTORY}"
|
${CMAKE_COMMAND}
|
||||||
|
-E
|
||||||
|
make_directory
|
||||||
|
"${DOXYGEN_OUTPUT_DIRECTORY}"
|
||||||
COMMAND "${m.css_SOURCE_DIR}/documentation/doxygen.py" "${CMAKE_CURRENT_BINARY_DIR}/conf.py"
|
COMMAND "${m.css_SOURCE_DIR}/documentation/doxygen.py" "${CMAKE_CURRENT_BINARY_DIR}/conf.py"
|
||||||
COMMAND echo "Docs written to: ${DOXYGEN_OUTPUT_DIRECTORY}"
|
COMMAND echo "Docs written to: ${DOXYGEN_OUTPUT_DIRECTORY}"
|
||||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
||||||
|
|
|
@ -4,39 +4,22 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <map>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "glimpses/version.h"
|
namespace glimpses {
|
||||||
|
|
||||||
namespace glimpses
|
/**
|
||||||
{
|
* @brief A class for saying hello in multiple languages
|
||||||
|
*/
|
||||||
/** @brief A class for saying retrieving system information */
|
|
||||||
class Glimpses
|
class Glimpses
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** @brief Type for representing the number of CPU cores. */
|
|
||||||
using CPUCount = uint32_t;
|
|
||||||
|
|
||||||
/** @brief Type for representing a set of CPU cores, mapped by their names. */
|
|
||||||
using CPUSet = std::map<std::string, CPUCount>;
|
|
||||||
|
|
||||||
/** @brief Maximum number of CPU cores supported by Glimpses. */
|
|
||||||
constexpr static CPUCount MAX_CPU_COUNT = 1024;
|
|
||||||
|
|
||||||
/** @brief Version of the Glimpses library. */
|
|
||||||
constexpr static const char *VERSION = GLIMPSES_VERSION;
|
|
||||||
|
|
||||||
/** @brief Creates a new glimpses */
|
|
||||||
Glimpses();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns the number of CPU cores available on the system.
|
* @brief Creates a new glimpses
|
||||||
* @return The number of CPU cores available on the system.
|
* @param name the name to greet
|
||||||
*/
|
*/
|
||||||
CPUSet getCPUCount() const;
|
Glimpses();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace glimpses
|
} // namespace glimpses
|
||||||
|
|
|
@ -3,25 +3,7 @@
|
||||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
#include <glimpses/glimpses.hpp>
|
#include <glimpses/glimpses.hpp>
|
||||||
#include <sched.h>
|
|
||||||
#include <thread>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
using namespace glimpses;
|
using namespace glimpses;
|
||||||
|
|
||||||
Glimpses::Glimpses()
|
Glimpses::Glimpses() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Glimpses::CPUSet Glimpses::getCPUCount() const
|
|
||||||
{
|
|
||||||
cpu_set_t cpuset;
|
|
||||||
auto minmax = [](int64_t min, int64_t value, int64_t max) -> CPUCount {
|
|
||||||
return std::min(std::max(value, min), max);
|
|
||||||
};
|
|
||||||
sched_getaffinity(0, sizeof(cpuset), &cpuset);
|
|
||||||
return CPUSet{{"configured", minmax(0, sysconf(_SC_NPROCESSORS_CONF), MAX_CPU_COUNT)},
|
|
||||||
{"logical", minmax(0, std::thread::hardware_concurrency(), MAX_CPU_COUNT)},
|
|
||||||
{"online", minmax(0, sysconf(_SC_NPROCESSORS_ONLN), MAX_CPU_COUNT)},
|
|
||||||
{"allowed", minmax(0, CPU_COUNT(&cpuset), MAX_CPU_COUNT)}};
|
|
||||||
}
|
|
||||||
|
|
|
@ -12,13 +12,18 @@ include(../cmake/tools.cmake)
|
||||||
|
|
||||||
# ---- Dependencies ----
|
# ---- Dependencies ----
|
||||||
|
|
||||||
include(../cmake/get_cpm.cmake)
|
include(../cmake/CPM.cmake)
|
||||||
|
|
||||||
CPMAddPackage(NAME Glimpses SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/..)
|
CPMAddPackage(NAME Glimpses SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/..)
|
||||||
|
|
||||||
# ---- Create standalone executable ----
|
# ---- Create standalone executable ----
|
||||||
|
|
||||||
file(GLOB sources CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp)
|
file(
|
||||||
|
GLOB
|
||||||
|
sources
|
||||||
|
CONFIGURE_DEPENDS
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp
|
||||||
|
)
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME} ${sources})
|
add_executable(${PROJECT_NAME} ${sources})
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,10 @@ include(../cmake/tools.cmake)
|
||||||
|
|
||||||
# ---- Dependencies ----
|
# ---- Dependencies ----
|
||||||
|
|
||||||
include(../cmake/get_cpm.cmake)
|
include(../cmake/CPM.cmake)
|
||||||
|
|
||||||
CPMAddPackage(NAME Catch2 GITHUB_REPOSITORY catchorg/Catch2 VERSION 3.8.1)
|
# CPMAddPackage("gh:doctest/doctest@2.4.9")
|
||||||
CPMAddPackage("gh:TheLartians/Format.cmake@1.8.3")
|
CPMAddPackage("gh:TheLartians/Format.cmake@1.7.3")
|
||||||
|
|
||||||
if(TEST_INSTALLED_VERSION)
|
if(TEST_INSTALLED_VERSION)
|
||||||
find_package(Glimpses REQUIRED)
|
find_package(Glimpses REQUIRED)
|
||||||
|
@ -29,15 +29,30 @@ endif()
|
||||||
|
|
||||||
# ---- Create binary ----
|
# ---- Create binary ----
|
||||||
|
|
||||||
file(GLOB sources CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp)
|
file(
|
||||||
|
GLOB
|
||||||
|
sources
|
||||||
|
CONFIGURE_DEPENDS
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp
|
||||||
|
)
|
||||||
add_executable(${PROJECT_NAME} ${sources})
|
add_executable(${PROJECT_NAME} ${sources})
|
||||||
target_link_libraries(${PROJECT_NAME} Catch2::Catch2WithMain Glimpses::Glimpses)
|
target_link_libraries(
|
||||||
|
${PROJECT_NAME}
|
||||||
|
# doctest::doctest
|
||||||
|
Glimpses::Glimpses
|
||||||
|
)
|
||||||
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17)
|
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17)
|
||||||
|
|
||||||
# enable compiler warnings
|
# enable compiler warnings
|
||||||
if(NOT TEST_INSTALLED_VERSION)
|
if(NOT TEST_INSTALLED_VERSION)
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||||
target_compile_options(Glimpses PUBLIC -Wall -Wpedantic -Wextra -Werror)
|
target_compile_options(
|
||||||
|
Glimpses
|
||||||
|
PUBLIC -Wall
|
||||||
|
-Wpedantic
|
||||||
|
-Wextra
|
||||||
|
-Werror
|
||||||
|
)
|
||||||
elseif(MSVC)
|
elseif(MSVC)
|
||||||
target_compile_options(Glimpses PUBLIC /W4 /WX)
|
target_compile_options(Glimpses PUBLIC /W4 /WX)
|
||||||
target_compile_definitions(${PROJECT_NAME} PUBLIC DOCTEST_CONFIG_USE_STD_HEADERS)
|
target_compile_definitions(${PROJECT_NAME} PUBLIC DOCTEST_CONFIG_USE_STD_HEADERS)
|
||||||
|
@ -48,17 +63,25 @@ endif()
|
||||||
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
include(CTest)
|
# Note: doctest and similar testing frameworks can automatically configure CMake tests. For other testing frameworks add
|
||||||
add_test(GlimpsesTests GlimpsesTests)
|
# the tests target instead: add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME})
|
||||||
|
|
||||||
# Note: doctest and similar testing frameworks can automatically configure CMake tests. For other testing frameworks add the tests target
|
|
||||||
# instead: add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME})
|
|
||||||
|
|
||||||
# include(${doctest_SOURCE_DIR}/scripts/cmake/doctest.cmake) doctest_discover_tests(${PROJECT_NAME})
|
# include(${doctest_SOURCE_DIR}/scripts/cmake/doctest.cmake) doctest_discover_tests(${PROJECT_NAME})
|
||||||
|
|
||||||
# ---- code coverage ----
|
# ---- code coverage ----
|
||||||
|
|
||||||
if(ENABLE_TEST_COVERAGE)
|
if(ENABLE_TEST_COVERAGE)
|
||||||
target_compile_options(Glimpses PUBLIC -O0 -g -fprofile-arcs -ftest-coverage)
|
target_compile_options(
|
||||||
target_link_options(Glimpses PUBLIC -fprofile-arcs -ftest-coverage)
|
Glimpses
|
||||||
|
PUBLIC -O0
|
||||||
|
-g
|
||||||
|
-fprofile-arcs
|
||||||
|
-ftest-coverage
|
||||||
|
)
|
||||||
|
target_link_options(
|
||||||
|
Glimpses
|
||||||
|
PUBLIC
|
||||||
|
-fprofile-arcs
|
||||||
|
-ftest-coverage
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -2,21 +2,24 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
|
||||||
#include <glimpses/glimpses.hpp>
|
#include <glimpses/glimpses.hpp>
|
||||||
#include <glimpses/version.h>
|
#include <glimpses/version.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
/*
|
||||||
|
TEST_CASE("Glimpses") {
|
||||||
|
using namespace greeter;
|
||||||
|
|
||||||
TEST_CASE("CPU count")
|
Glimpses greeter("Tests");
|
||||||
{
|
|
||||||
|
|
||||||
glimpses::Glimpses glimpses{};
|
CHECK(greeter.greet(LanguageCode::EN) == "Hello, Tests!");
|
||||||
|
CHECK(greeter.greet(LanguageCode::DE) == "Hallo Tests!");
|
||||||
CHECK(glimpses.getCPUCount().size() > 0);
|
CHECK(greeter.greet(LanguageCode::ES) == "¡Hola Tests!");
|
||||||
|
CHECK(greeter.greet(LanguageCode::FR) == "Bonjour Tests!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
TEST_CASE("Glimpses version") {
|
||||||
TEST_CASE("Glimpses version") { static_assert(std::string_view(GREETER_VERSION) == std::string_view("0.1.0"));
|
static_assert(std::string_view(GREETER_VERSION) == std::string_view("1.0"));
|
||||||
CHECK(std::string(GREETER_VERSION) == std::string("1.0"));
|
CHECK(std::string(GREETER_VERSION) == std::string("1.0"));
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
14
test/source/main.cpp
Normal file
14
test/source/main.cpp
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
// SPDX-FileCopyrightText: 2023 Tobias Schmidl
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
#if 0
|
||||||
|
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
||||||
|
|
||||||
|
#include <doctest/doctest.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue