From 091a24cdf922e4eae46b35f5676dd8ca09e3621c Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Sat, 26 Apr 2025 21:00:05 +0200 Subject: [PATCH 1/7] fix header installation Update .gitlab-ci.yml file Fix gcovr html report Update Dockerfile Update docker related docu and config Add simple CMakeWorkflowPresets Try to use $env{CC} to control the compiler variant Format CMakePresets files Do not waste time, use run-clang-tidy Upgrade project_options Use cmake workflow on gitlab-ci Update link to setup-cpp-x64-linux Install current cmake version with pythone3-pip on CI Cleanup .gitlab-ci.yml file Use gcovr on gitlab-ci add build/coverage for CI gcovr Enable clang-tidy on CI builds Use custom-collapsible-sections Cleanup .gitlab-ci.yml Use CI_compiler variable while build use target_find_dependencies() again Use Dockerfile from setu-cpp As recommended in review Update docker.md Update setup-cpp Upgrade to gcovr Use newest cmake and project_options Use gcov-13 with gcc on CI --- .devcontainer/Dockerfile | 149 +++----------- .devcontainer/.dockerignore => .dockerignore | 13 +- .github/workflows/ci.yml | 10 +- .gitignore | 4 +- .gitlab-ci.yml | 48 ++++- CMakeLists.txt | 12 +- CMakeWorkflowPresets.json | 198 +++++++++++++++++++ docs/docker.md | 45 +---- gcovr.cfg | 22 +++ 9 files changed, 332 insertions(+), 169 deletions(-) rename .devcontainer/.dockerignore => .dockerignore (76%) create mode 100644 CMakeWorkflowPresets.json create mode 100644 gcovr.cfg diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index e5faeda..afd548e 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,120 +1,35 @@ -# [Choice] bionic (18.04), focal (20.04) -ARG VARIANT="jammy" -FROM ubuntu:${VARIANT} - -# Restate the variant to use it later on in the llvm and cmake installations -ARG VARIANT - -# Install necessary packages available from standard repos -RUN apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \ - apt-get install -y --no-install-recommends \ - software-properties-common wget apt-utils file zip unzip pkg-config \ - openssh-client gpg-agent socat rsync \ - make ninja-build git \ - python3 python3-pip - -# Install conan -RUN python3 -m pip install --upgrade pip setuptools && \ - python3 -m pip install conan && \ - conan --version - -# By default, anything you run in Docker is done as superuser. -# Conan runs some install commands as superuser, and will prepend `sudo` to -# these commands, unless `CONAN_SYSREQUIRES_SUDO=0` is in your env variables. -ENV CONAN_SYSREQUIRES_SUDO 0 -# Some packages request that Conan use the system package manager to install -# a few dependencies. This flag allows Conan to proceed with these installations; -# leaving this flag undefined can cause some installation failures. -ENV CONAN_SYSREQUIRES_MODE enabled - -# User-settable versions: -# This Dockerfile should support gcc-[7, 8, 9, 10, 11] and clang-[10, 11, 12, 13] -# Earlier versions of clang will require significant modifications to the IWYU section -ARG GCC_VER="11" -# Add gcc-${GCC_VER} -RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test && \ - apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \ - apt-get install -y --no-install-recommends \ - gcc-${GCC_VER} g++-${GCC_VER} gdb - -# Set gcc-${GCC_VER} as default gcc -RUN update-alternatives --install /usr/bin/gcc gcc $(which gcc-${GCC_VER}) 100 -RUN update-alternatives --install /usr/bin/g++ g++ $(which g++-${GCC_VER}) 100 - -ARG LLVM_VER="13" -# Add clang-${LLVM_VER} -ARG LLVM_URL="http://apt.llvm.org/${VARIANT}/" -ARG LLVM_PKG="llvm-toolchain-${VARIANT}-${LLVM_VER}" -RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - 2>/dev/null && \ - add-apt-repository -y "deb ${LLVM_URL} ${LLVM_PKG} main" && \ - apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \ - apt-get install -y --no-install-recommends \ - clang-${LLVM_VER} lldb-${LLVM_VER} lld-${LLVM_VER} clangd-${LLVM_VER} \ - llvm-${LLVM_VER}-dev libclang-${LLVM_VER}-dev clang-tidy-${LLVM_VER} - -# Set the default clang-tidy, so CMake can find it -RUN update-alternatives --install /usr/bin/clang-tidy clang-tidy $(which clang-tidy-${LLVM_VER}) 1 - -# Set clang-${LLVM_VER} as default clang -RUN update-alternatives --install /usr/bin/clang clang $(which clang-${LLVM_VER}) 100 -RUN update-alternatives --install /usr/bin/clang++ clang++ $(which clang++-${LLVM_VER}) 100 - -# Add current cmake/ccmake, from Kitware -ARG CMAKE_URL="https://apt.kitware.com/ubuntu/" -ARG CMAKE_PKG=${VARIANT} -RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null \ - | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null && \ - apt-add-repository -y "deb ${CMAKE_URL} ${CMAKE_PKG} main" && \ - apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \ - apt-get install -y --no-install-recommends cmake cmake-curses-gui - -# Install editors -RUN apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \ - apt-get install -y --no-install-recommends \ - neovim emacs nano - -# Install optional dependencies -RUN apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \ - apt-get install -y --no-install-recommends \ - doxygen graphviz ccache cppcheck gcovr - -# Install include-what-you-use -ENV IWYU /home/iwyu -ENV IWYU_BUILD ${IWYU}/build -ENV IWYU_SRC ${IWYU}/include-what-you-use -RUN mkdir -p ${IWYU_BUILD} && \ - git clone --branch clang_${LLVM_VER} \ - https://github.com/include-what-you-use/include-what-you-use.git \ - ${IWYU_SRC} -RUN CC=clang-${LLVM_VER} CXX=clang++-${LLVM_VER} cmake -S ${IWYU_SRC} \ - -B ${IWYU_BUILD} \ - -G "Unix Makefiles" -DCMAKE_PREFIX_PATH=/usr/lib/llvm-${LLVM_VER} && \ - cmake --build ${IWYU_BUILD} -j && \ - cmake --install ${IWYU_BUILD} - -# Per https://github.com/include-what-you-use/include-what-you-use#how-to-install: -# `You need to copy the Clang include directory to the expected location before -# running (similarly, use include-what-you-use -print-resource-dir to learn -# exactly where IWYU wants the headers).` -RUN mkdir -p $(include-what-you-use -print-resource-dir 2>/dev/null) -RUN ln -s $(readlink -f /usr/lib/clang/${LLVM_VER}/include) \ - $(include-what-you-use -print-resource-dir 2>/dev/null)/include - -## Cleanup cached apt data we don't need anymore -RUN apt-get autoremove -y && apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# Allow the user to set compiler defaults -ARG USE_CLANG -# if --build-arg USE_CLANG=1, set CC to 'clang' or set to null otherwise. -ENV CC=${USE_CLANG:+"clang"} -ENV CXX=${USE_CLANG:+"clang++"} -# if CC is null, set it to 'gcc' (or leave as is otherwise). -ENV CC=${CC:-"gcc"} -ENV CXX=${CXX:-"g++"} +#### Base Image +FROM ubuntu:22.04 as setup-cpp-ubuntu + +RUN apt-get update -qq && \ + # install nodejs + apt-get install -y --no-install-recommends nodejs npm && \ + # install setup-cpp + npm install -g setup-cpp@v0.36.2 && \ + # install the compiler and tools + setup-cpp \ + --nala true \ + --compiler llvm \ + --cmake true \ + --ninja true \ + --task true \ + --vcpkg true \ + --python true \ + --make true \ + --cppcheck true \ + --gcovr true \ + --doxygen true \ + --ccache true && \ + # cleanup + nala autoremove -y && \ + nala autopurge -y && \ + apt-get clean && \ + nala clean --lists && \ + rm -rf /var/lib/apt/lists/* && \ + rm -rf /tmp/* # Include project -#ADD . /workspaces/cpp_starter_project -#WORKDIR /workspaces/cpp_starter_project +ADD . /workspaces/cpp_vcpkg_project +WORKDIR /workspaces/cpp_vcpkg_project -CMD ["/bin/bash"] +ENTRYPOINT ["/bin/bash"] diff --git a/.devcontainer/.dockerignore b/.dockerignore similarity index 76% rename from .devcontainer/.dockerignore rename to .dockerignore index 023d28a..1784dd8 100644 --- a/.devcontainer/.dockerignore +++ b/.dockerignore @@ -1,7 +1,11 @@ # Build directories and binary files build/ +install/ out/ cmake-build-*/ +conan-cache/ +.cache/ +coverage.xml # User specific settings CMakeUserPresets.json @@ -14,7 +18,9 @@ CMakeUserPresets.json !.vscode/tasks.json !.vscode/launch.json !.vscode/extensions.json +.*.swp *.swp +.*~ *~ _ReSharper* *.log @@ -31,4 +37,9 @@ $RECYCLE.BIN/ .TemporaryItems ehthumbs.db Thumbs.db -Dockerfile \ No newline at end of file +compile_commands.json + +# docker related +#Dockerfile +toolchain/ +vcpkg/ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f939c91..b31c47b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,16 +45,16 @@ jobs: include: # Inject GCOV variable for gcc - compiler: gcc - GCOV: gcov + GCOV: gcov-13 # Inject GCOV variable for llvm - compiler: llvm GCOV: "llvm-cov gcov" # Only to test non-multiconfig builds - os: ubuntu-22.04 - compiler: gcc-11 - CMAKE_GENERATOR: "Unix Makefiles" - GCOV: gcov-11 + compiler: gcc + CMAKE_GENERATOR: "Ninja" + GCOV: gcov-13 - os: windows-2022 compiler: msvc @@ -99,9 +99,7 @@ jobs: ccache: true clangtidy: true task: true - cppcheck: true - gcovr: 7.2 opencppcoverage: true diff --git a/.gitignore b/.gitignore index e380c7d..5267863 100644 --- a/.gitignore +++ b/.gitignore @@ -18,7 +18,9 @@ CMakeUserPresets.json !.vscode/tasks.json !.vscode/launch.json !.vscode/extensions.json +.*.swp *.swp +.*~ *~ _ReSharper* *.log @@ -35,4 +37,4 @@ $RECYCLE.BIN/ .TemporaryItems ehthumbs.db Thumbs.db -compile_commands.json \ No newline at end of file +compile_commands.json diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 57b0285..fa73a9c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,10 +1,18 @@ -image: ubuntu:22.04 - stages: - test - docs_deploy + - build + +.standard-rules: # Make a hidden job to hold the common rules + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + artifacts: + paths: + - "build/*/*.tar.gz" .setup_linux: &setup_linux | + echo -e "\e[0Ksection_start:`date +%s`:my_setup_linux[collapsed=true]\r\e[0KHeader of the setup linux collapsible section" DEBIAN_FRONTEND=noninteractive # set time-zone @@ -20,14 +28,37 @@ stages: chmod +x ./setup-cpp ./setup-cpp --compiler $compiler --cmake true --ninja true --ccache true --vcpkg true --task true --gcovr 7 --doxygen true source ~/.cpprc + pwd && mkdir -p build/coverage + echo -e "\e[0Ksection_end:`date +%s`:my_setup_cpp\r\e[0K" + clang-tidy --version + python3 --version + python3 -m pip install cmake ninja gcovr + cmake --version + ninja --version + which gcovr && gcovr --version -.test: &test | +# XXX not longer used! CK +.task: &test | task coverage task coverage_release task install +.build: + script: + - *setup_cpp + - echo -e "\e[0Ksection_start:`date +%s`:my_build[collapsed=true]\r\e[0KHeader of the build collapsible section" + - cmake --workflow --preset ${CI_compiler}-debug + - gcovr . + - cmake --workflow --preset ${CI_compiler}-release + - echo -e "\e[0Ksection_end:`date +%s`:my_build\r\e[0K" + +default: # Add a default section to define the `image` keyword's default value + image: ubuntu:latest + before_script: + - *setup_linux + test_linux_llvm: - stage: test + stage: build variables: compiler: llvm script: @@ -50,7 +81,7 @@ test_linux_llvm: - public test_linux_gcc: - stage: test + stage: build variables: compiler: gcc script: @@ -67,3 +98,10 @@ pages: artifacts: paths: - public + +# see https://docs.gitlab.com/ee/ci/jobs/#custom-collapsible-sections +# job1: +# script: +# - echo -e "\e[0Ksection_start:`date +%s`:my_first_section[collapsed=true]\r\e[0KHeader of the 1st collapsible section" +# - echo 'this line should be hidden automatically after loading the job log' +# - echo -e "\e[0Ksection_end:`date +%s`:my_first_section\r\e[0K" diff --git a/CMakeLists.txt b/CMakeLists.txt index 11783ec..5829dca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.21...3.28) +cmake_minimum_required(VERSION 3.21...3.31) # set a default CXX standard for the tools and targets that do not specify them. # If commented, the latest supported standard for your compiler is automatically set. @@ -17,6 +17,7 @@ endif() set(PROJECT_OPTIONS_VERSION "v0.41.0") FetchContent_Declare( _project_options + GIT_SUBMODULES "" URL https://github.com/aminya/project_options/archive/refs/tags/${PROJECT_OPTIONS_VERSION}.zip) FetchContent_MakeAvailable(_project_options) @@ -55,10 +56,12 @@ if(FEATURE_TESTS) CMAKE_C_COMPILER_ID STREQUAL "GNU") - set(ENABLE_CLANG_TIDY "ENABLE_CLANG_TIDY") endif() - set(ENABLE_CPPCHECK "ENABLE_CPPCHECK") + if($ENV{CI}) + set(ENABLE_CLANG_TIDY "ENABLE_CLANG_TIDY") + set(ENABLE_CPPCHECK "ENABLE_CPPCHECK") + endif() set(ENABLE_COVERAGE "ENABLE_COVERAGE") set(ENABLE_VS_ANALYSIS "ENABLE_VS_ANALYSIS") @@ -84,6 +87,7 @@ project_options( PREFIX "my" ENABLE_CACHE + #TODO(CK): Only on CI! This is to slow while developing! use run-clang-tidy -p build/debug ${ENABLE_CPPCHECK} ${ENABLE_CLANG_TIDY} ${ENABLE_VS_ANALYSIS} @@ -108,9 +112,9 @@ project_options( # ENABLE_INCLUDE_WHAT_YOU_USE # ENABLE_GCC_ANALYZER # ENABLE_BUILD_WITH_TIME_TRACE - # ENABLE_UNITY # LINKER "lld" # CONAN_PROFILE ${profile_path} + #FIXME(CK): this does not work! ENABLE_UNITY ) add_subdirectory(./my_exe) diff --git a/CMakeWorkflowPresets.json b/CMakeWorkflowPresets.json new file mode 100644 index 0000000..d41ef81 --- /dev/null +++ b/CMakeWorkflowPresets.json @@ -0,0 +1,198 @@ +{ + "version": 7, + "cmakeMinimumRequired": { + "major": 3, + "minor": 27, + "patch": 0 + }, + "configurePresets": [ + { + "name": "default-config", + "hidden": true, + "generator": "Ninja", + "cacheVariables": { + "CMAKE_HOST_SYSTEM_PROCESSOR": "$penv{PROCESSOR_ARCHITECTURE}" + }, + "environment": { "VARIANT": "MSVC" } + }, + { + "name": "compiler-config", + "hidden": false, + "inherits": "default-config", + "cacheVariables": { + "CMAKE_C_COMPILER": "$penv{CC}", + "CMAKE_CXX_COMPILER": "$penv{CXX}", + "CMAKE_HOST_SYSTEM_PROCESSOR": "$penv{HOSTTYPE}" + } + }, + { + "name": "clang-config", + "hidden": true, + "inherits": "default-config", + "cacheVariables": { + "CMAKE_C_COMPILER": "clang", + "CMAKE_CXX_COMPILER": "clang++" + }, + "environment": { "VARIANT": "Clang" } + }, + { + "name": "ninja-multi-vcpkg", + "displayName": "Ninja Multi-Config", + "description": "Configure with vcpkg toolchain and generate Ninja Multi-Config project files for all variants", + "vendor": { + "ClausKlein.de/CMake/1.0": { + "description": "FIXME: We need macro expansion here!", + "inherits": "$penv{CC}-config" + } + }, + "inherits": "compiler-config", + "generator": "Ninja Multi-Config", + "hidden": true, + "cacheVariables": { + "CMAKE_TOOLCHAIN_FILE": { + "type": "FILEPATH", + "value": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake" + }, + "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": { + "type": "FILEPATH", + "value": "${sourceDir}/toolchain/WindowsToolchain/Windows.$env{VARIANT}.toolchain.cmake" + } + } + }, + { + "name": "common-config", + "description": "Settings for all toolchains", + "hidden": true, + "inherits": "ninja-multi-vcpkg", + "binaryDir": "${sourceDir}/build/${presetName}", + "installDir": "${sourceDir}/install/${presetName}", + "cacheVariables": { + "ENABLE_DOXYGEN": false, + "ENABLE_CPPCHECK": false, + "ENABLE_CLANG_TIDY": false + }, + "vendor": { + "microsoft.com/VisualStudioRemoteSettings/CMake/1.0": { + "sourceDir": "$env{HOME}/.vs/$ms{projectDirName}" + } + } + }, + { + "name": "debug", + "displayName": "Debug", + "description": "Debug build type", + "inherits": "common-config", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "FEATURE_TESTS": true + } + }, + { + "name": "release", + "displayName": "Release", + "description": "Release build type", + "inherits": "common-config", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "FEATURE_DOCS": false + } + } + ], + "testPresets": [ + { + "name": "common-test", + "description": "Test CMake settings that apply to all configurations", + "hidden": true, + "output": { + "outputOnFailure": true + }, + "execution": { + "noTestsAction": "error", + "stopOnFailure": true + } + }, + { + "name": "debug", + "displayName": "Strict", + "description": "Enable output and stop on failure", + "inherits": "common-test", + "configuration": "Debug", + "configurePreset": "debug" + }, + { + "name": "release", + "displayName": "Strict", + "description": "Enable output and stop on failure", + "inherits": "common-test", + "configuration": "Release", + "configurePreset": "release" + } + ], + "buildPresets": [ + { + "name": "release", + "configurePreset": "release" + }, + { + "name": "install", + "configurePreset": "release", + "targets": [ "install" ] + }, + { + "name": "gen-docs", + "configurePreset": "release", + "targets": [ "doxygen-docs" ] + }, + { + "name": "debug", + "configurePreset": "debug" + } + ], + "packagePresets": [ + { + "name": "release", + "configurePreset": "release", + "generators": [ + "TGZ" + ] + } + ], + "workflowPresets": [ + { + "description": "Developer workflow without installation", + "name": "debug", + "steps": [ + { + "type": "configure", + "name": "debug" + }, + { + "type": "build", + "name": "debug" + }, + { + "type": "test", + "name": "debug" + } + ] + }, + { + "description": "Release workflow without test", + "name": "release", + "steps": [ + { + "name": "release", + "type": "configure" + }, + { + "name": "release", + "type": "build" + }, + { + "name": "release", + "type": "package" + } + ] + } + ] +} diff --git a/docs/docker.md b/docs/docker.md index b1f5bf5..69c5ed7 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -4,32 +4,17 @@ If you have [Docker](https://www.docker.com/) installed, you can run this in your terminal, when the Dockerfile is inside the `.devcontainer` directory: ```bash -docker build -f ./.devcontainer/Dockerfile --tag=my_project:latest . -docker run -it my_project:latest +docker build -f ./.devcontainer/Dockerfile --tag=devcontainer:latest . +docker run -it devcontainer:latest ``` -This command will put you in a `bash` session in a Ubuntu 20.04 Docker container, +This command will put you in a `bash` session in a Ubuntu 22.04 Docker container, with all of the tools listed in the [Dependencies](#dependencies) section already installed. -Additionally, you will have `g++-11` and `clang++-13` installed as the default +Additionally, you will have `g++-13` and `clang++-16` installed as the default versions of `g++` and `clang++`. -If you want to build this container using some other versions of gcc and clang, -you may do so with the `GCC_VER` and `LLVM_VER` arguments: - -```bash -docker build --tag=myproject:latest --build-arg GCC_VER=10 --build-arg LLVM_VER=11 . -``` - -The CC and CXX environment variables are set to GCC version 11 by default. -If you wish to use clang as your default CC and CXX environment variables, you -may do so like this: - -```bash -docker build --tag=my_project:latest --build-arg USE_CLANG=1 . -``` - You will be logged in as root, so you will see the `#` symbol as your prompt. -You will be in a directory that contains a copy of the `cpp_starter_project`; +You will be in a directory that contains a copy of the `cpp_vcpkg_project`; any changes you make to your local copy will not be updated in the Docker image until you rebuild it. If you need to mount your local copy directly in the Docker image, see @@ -39,33 +24,23 @@ TLDR: ```bash docker run -it \ -v absolute_path_on_host_machine:absolute_path_in_guest_container \ - my_project:latest + devcontainer:latest ``` You can configure and build [as directed above](#build) using these commands: ```bash -/starter_project# mkdir build -/starter_project# cmake -S . -B ./build -/starter_project# cmake --build ./build +/cpp_vcpkg_project# cmake --workflow --preset gcc-debug +/cpp_vcpkg_project# gcovr ``` -You can configure and build using `clang-13`, without rebuilding the container, +You can configure and build using `clang-16`, without rebuilding the container, with these commands: ```bash -/starter_project# mkdir build -/starter_project# CC=clang CXX=clang++ cmake -S . -B ./build -/starter_project# cmake --build ./build +/cpp_vcpkg_project# cmake --workflow --preset clang-relase ``` -The `ccmake` tool is also installed; you can substitute `ccmake` for `cmake` to -configure the project interactively. All of the tools this project supports are installed in the Docker image; enabling them is as simple as flipping a switch using the `ccmake` interface. -Be aware that some of the sanitizers conflict with each other, so be sure to -run them separately. - -A script called `build_examples.sh` is provided to help you to build the example -GUI projects in this container. diff --git a/gcovr.cfg b/gcovr.cfg new file mode 100644 index 0000000..afb8f63 --- /dev/null +++ b/gcovr.cfg @@ -0,0 +1,22 @@ +root = . +search-path = build + +filter = src/* +filter = include/* +filter = my_lib/* +filter = my_header_lib/* +filter = my_exe/* + +exclude-directories = install +exclude-directories = build/*/_deps +exclude-directories = fuzz_test + +gcov-ignore-parse-errors = yes +print-summary = yes + +html-details = ./build/coverage/index.html + +cobertura-pretty = yes +cobertura = build/cobertura.xml + +#TBD delete-gcov-files = yes From 636a8eff6e295d0133f63a62db37ad01729b1e6e Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Sat, 26 Apr 2025 21:23:16 +0200 Subject: [PATCH 2/7] make format --- .devcontainer/devcontainer.json | 103 ++++----- CMakeWorkflowPresets.json | 373 ++++++++++++++++---------------- 2 files changed, 243 insertions(+), 233 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 8b79bed..cf2ec0e 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,52 +1,53 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: -// https://github.com/microsoft/vscode-dev-containers/tree/v0.205.2/containers/cpp -{ - "name": "C++", - "build": { - "dockerfile": "Dockerfile", - // Update 'VARIANT' to pick an Ubuntu OS version. Options: [bionic, focal]. Default: focal - // Update 'GCC_VER' to pick a gcc and g++ version. Options: [7, 8, 9, 10, 11]. Default: 11 - // Update 'LLVM_VER' to pick clang version. Options: [10, 11, 12, 13]. Default: 13 - // Update 'USE_CLANG' to set clang as the default C and C++ compiler. Options: [1, null]. Default null - // "args": { - // "VARIANT": "focal", - // "GCC_VER": "11", - // "LLVM_VER": "13" - // } - }, - "runArgs": [ - "--cap-add=SYS_PTRACE", - "--security-opt", - "seccomp=unconfined" - ], - // Set *default* container specific settings.json values on container create. - "settings": { - "cmake.configureOnOpen": true, - "editor.formatOnSave": true - }, - // Add the IDs of extensions you want installed when the container is created. - "extensions": [ - "ms-vscode.cpptools", - "ms-vscode.cmake-tools", - "twxs.cmake", - "ms-vscode.cpptools-themes", - "cschlosser.doxdocgen", - "eamodio.gitlens", - "ms-python.python", - "ms-python.vscode-pylance", - "mutantdino.resourcemonitor" - ], - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. - //"postCreateCommand": "uname -a", - // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. - //"remoteUser": "vscode", - "workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/${localWorkspaceFolderBasename},type=bind,consistency=delegated", - "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", - "features": { - "git": "latest", - "git-lfs": "latest", - "powershell": "latest" - } -} \ No newline at end of file + // https://github.com/microsoft/vscode-dev-containers/tree/v0.205.2/containers/cpp + { + "name": "C++", + "build": { + "dockerfile": "Dockerfile", + // Update 'VARIANT' to pick an Ubuntu OS version. Options: [bionic, focal]. Default: focal + // Update 'GCC_VER' to pick a gcc and g++ version. Options: [7, 8, 9, 10, 11]. Default: 11 + // Update 'LLVM_VER' to pick clang version. Options: [10, 11, 12, 13]. Default: 13 + // Update 'USE_CLANG' to set clang as the default C and C++ compiler. Options: [1, null]. Default null + // "args": { + // "VARIANT": "focal", + // "GCC_VER": "11", + // "LLVM_VER": "13" + // } + }, + "runArgs": [ + "--cap-add=SYS_PTRACE", + "--security-opt", + "seccomp=unconfined" + ], + // Set *default* container specific settings.json values on container create. + "settings": { + "cmake.configureOnOpen": true, + "editor.formatOnSave": true + }, + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ms-vscode.cpptools", + "ms-vscode.cmake-tools", + "twxs.cmake", + "ms-vscode.cpptools-themes", + "cschlosser.doxdocgen", + "eamodio.gitlens", + "ms-python.python", + "ms-python.vscode-pylance", + "mutantdino.resourcemonitor" + ], + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + // Use 'postCreateCommand' to run commands after the container is created. + //"postCreateCommand": "uname -a", + // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + //"remoteUser": "vscode", + "workspaceMount": + "source=${localWorkspaceFolder},target=/workspaces/${localWorkspaceFolderBasename},type=bind,consistency=delegated", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + "features": { + "git": "latest", + "git-lfs": "latest", + "powershell": "latest" + } + } \ No newline at end of file diff --git a/CMakeWorkflowPresets.json b/CMakeWorkflowPresets.json index d41ef81..25b2128 100644 --- a/CMakeWorkflowPresets.json +++ b/CMakeWorkflowPresets.json @@ -1,198 +1,207 @@ { - "version": 7, - "cmakeMinimumRequired": { - "major": 3, - "minor": 27, - "patch": 0 + "version": 7, + "cmakeMinimumRequired": { + "major": 3, + "minor": 27, + "patch": 0 + }, + "configurePresets": [ + { + "name": "default-config", + "hidden": true, + "generator": "Ninja", + "cacheVariables": { + "CMAKE_HOST_SYSTEM_PROCESSOR": "$penv{PROCESSOR_ARCHITECTURE}" + }, + "environment": { + "VARIANT": "MSVC" + } }, - "configurePresets": [ - { - "name": "default-config", - "hidden": true, - "generator": "Ninja", - "cacheVariables": { - "CMAKE_HOST_SYSTEM_PROCESSOR": "$penv{PROCESSOR_ARCHITECTURE}" - }, - "environment": { "VARIANT": "MSVC" } - }, - { - "name": "compiler-config", - "hidden": false, - "inherits": "default-config", - "cacheVariables": { - "CMAKE_C_COMPILER": "$penv{CC}", - "CMAKE_CXX_COMPILER": "$penv{CXX}", - "CMAKE_HOST_SYSTEM_PROCESSOR": "$penv{HOSTTYPE}" - } - }, - { - "name": "clang-config", - "hidden": true, - "inherits": "default-config", - "cacheVariables": { - "CMAKE_C_COMPILER": "clang", - "CMAKE_CXX_COMPILER": "clang++" - }, - "environment": { "VARIANT": "Clang" } - }, - { - "name": "ninja-multi-vcpkg", - "displayName": "Ninja Multi-Config", - "description": "Configure with vcpkg toolchain and generate Ninja Multi-Config project files for all variants", - "vendor": { - "ClausKlein.de/CMake/1.0": { - "description": "FIXME: We need macro expansion here!", - "inherits": "$penv{CC}-config" - } - }, - "inherits": "compiler-config", - "generator": "Ninja Multi-Config", - "hidden": true, - "cacheVariables": { - "CMAKE_TOOLCHAIN_FILE": { - "type": "FILEPATH", - "value": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake" - }, - "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": { - "type": "FILEPATH", - "value": "${sourceDir}/toolchain/WindowsToolchain/Windows.$env{VARIANT}.toolchain.cmake" - } - } - }, - { - "name": "common-config", - "description": "Settings for all toolchains", - "hidden": true, - "inherits": "ninja-multi-vcpkg", - "binaryDir": "${sourceDir}/build/${presetName}", - "installDir": "${sourceDir}/install/${presetName}", - "cacheVariables": { - "ENABLE_DOXYGEN": false, - "ENABLE_CPPCHECK": false, - "ENABLE_CLANG_TIDY": false - }, - "vendor": { - "microsoft.com/VisualStudioRemoteSettings/CMake/1.0": { - "sourceDir": "$env{HOME}/.vs/$ms{projectDirName}" - } - } - }, - { - "name": "debug", - "displayName": "Debug", - "description": "Debug build type", - "inherits": "common-config", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug", - "FEATURE_TESTS": true - } - }, - { - "name": "release", - "displayName": "Release", - "description": "Release build type", - "inherits": "common-config", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Release", - "FEATURE_DOCS": false - } + { + "name": "compiler-config", + "hidden": false, + "inherits": "default-config", + "cacheVariables": { + "CMAKE_C_COMPILER": "$penv{CC}", + "CMAKE_CXX_COMPILER": "$penv{CXX}", + "CMAKE_HOST_SYSTEM_PROCESSOR": "$penv{HOSTTYPE}" + } + }, + { + "name": "clang-config", + "hidden": true, + "inherits": "default-config", + "cacheVariables": { + "CMAKE_C_COMPILER": "clang", + "CMAKE_CXX_COMPILER": "clang++" + }, + "environment": { + "VARIANT": "Clang" + } + }, + { + "name": "ninja-multi-vcpkg", + "displayName": "Ninja Multi-Config", + "description": + "Configure with vcpkg toolchain and generate Ninja Multi-Config project files for all variants", + "vendor": { + "ClausKlein.de/CMake/1.0": { + "description": "FIXME: We need macro expansion here!", + "inherits": "$penv{CC}-config" } - ], - "testPresets": [ - { - "name": "common-test", - "description": "Test CMake settings that apply to all configurations", - "hidden": true, - "output": { - "outputOnFailure": true - }, - "execution": { - "noTestsAction": "error", - "stopOnFailure": true - } - }, - { - "name": "debug", - "displayName": "Strict", - "description": "Enable output and stop on failure", - "inherits": "common-test", - "configuration": "Debug", - "configurePreset": "debug" + }, + "inherits": "compiler-config", + "generator": "Ninja Multi-Config", + "hidden": true, + "cacheVariables": { + "CMAKE_TOOLCHAIN_FILE": { + "type": "FILEPATH", + "value": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake" }, - { - "name": "release", - "displayName": "Strict", - "description": "Enable output and stop on failure", - "inherits": "common-test", - "configuration": "Release", - "configurePreset": "release" + "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": { + "type": "FILEPATH", + "value": "${sourceDir}/toolchain/WindowsToolchain/Windows.$env{VARIANT}.toolchain.cmake" } - ], - "buildPresets": [ - { - "name": "release", - "configurePreset": "release" - }, - { - "name": "install", - "configurePreset": "release", - "targets": [ "install" ] + } + }, + { + "name": "common-config", + "description": "Settings for all toolchains", + "hidden": true, + "inherits": "ninja-multi-vcpkg", + "binaryDir": "${sourceDir}/build/${presetName}", + "installDir": "${sourceDir}/install/${presetName}", + "cacheVariables": { + "ENABLE_DOXYGEN": false, + "ENABLE_CPPCHECK": false, + "ENABLE_CLANG_TIDY": false + }, + "vendor": { + "microsoft.com/VisualStudioRemoteSettings/CMake/1.0": { + "sourceDir": "$env{HOME}/.vs/$ms{projectDirName}" + } + } + }, + { + "name": "debug", + "displayName": "Debug", + "description": "Debug build type", + "inherits": "common-config", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "FEATURE_TESTS": true + } + }, + { + "name": "release", + "displayName": "Release", + "description": "Release build type", + "inherits": "common-config", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "FEATURE_DOCS": false + } + } + ], + "testPresets": [ + { + "name": "common-test", + "description": "Test CMake settings that apply to all configurations", + "hidden": true, + "output": { + "outputOnFailure": true + }, + "execution": { + "noTestsAction": "error", + "stopOnFailure": true + } + }, + { + "name": "debug", + "displayName": "Strict", + "description": "Enable output and stop on failure", + "inherits": "common-test", + "configuration": "Debug", + "configurePreset": "debug" + }, + { + "name": "release", + "displayName": "Strict", + "description": "Enable output and stop on failure", + "inherits": "common-test", + "configuration": "Release", + "configurePreset": "release" + } + ], + "buildPresets": [ + { + "name": "release", + "configurePreset": "release" + }, + { + "name": "install", + "configurePreset": "release", + "targets": [ + "install" + ] + }, + { + "name": "gen-docs", + "configurePreset": "release", + "targets": [ + "doxygen-docs" + ] + }, + { + "name": "debug", + "configurePreset": "debug" + } + ], + "packagePresets": [ + { + "name": "release", + "configurePreset": "release", + "generators": [ + "TGZ" + ] + } + ], + "workflowPresets": [ + { + "description": "Developer workflow without installation", + "name": "debug", + "steps": [ + { + "type": "configure", + "name": "debug" }, { - "name": "gen-docs", - "configurePreset": "release", - "targets": [ "doxygen-docs" ] + "type": "build", + "name": "debug" }, { - "name": "debug", - "configurePreset": "debug" + "type": "test", + "name": "debug" } - ], - "packagePresets": [ + ] + }, + { + "description": "Release workflow without test", + "name": "release", + "steps": [ { - "name": "release", - "configurePreset": "release", - "generators": [ - "TGZ" - ] - } - ], - "workflowPresets": [ + "name": "release", + "type": "configure" + }, { - "description": "Developer workflow without installation", - "name": "debug", - "steps": [ - { - "type": "configure", - "name": "debug" - }, - { - "type": "build", - "name": "debug" - }, - { - "type": "test", - "name": "debug" - } - ] + "name": "release", + "type": "build" }, { - "description": "Release workflow without test", - "name": "release", - "steps": [ - { - "name": "release", - "type": "configure" - }, - { - "name": "release", - "type": "build" - }, - { - "name": "release", - "type": "package" - } - ] + "name": "release", + "type": "package" } - ] + ] + } + ] } From e51df398be79a8162cef1f00d72d7d05d11f551d Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Sat, 26 Apr 2025 21:28:00 +0200 Subject: [PATCH 3/7] Use cmake-format too --- CMakeLists.txt | 1 + Makefile | 1 + 2 files changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5829dca..d1fe34f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,6 +56,7 @@ if(FEATURE_TESTS) CMAKE_C_COMPILER_ID STREQUAL "GNU") + endif() if($ENV{CI}) diff --git a/Makefile b/Makefile index 1f9ca0e..658d4a7 100644 --- a/Makefile +++ b/Makefile @@ -47,6 +47,7 @@ ifeq ($(OS), Windows_NT) pwsh -c '$$files=(git ls-files --exclude-standard); foreach ($$file in $$files) { if ((get-item $$file).Extension -in ".json", ".cpp", ".hpp", ".c", ".cc", ".cxx", ".hxx", ".ixx") { clang-format -i -style=file $$file } }' else git ls-files --exclude-standard | grep -E '\.(json|cpp|hpp|c|cc|cxx|hxx|ixx)$$' | xargs clang-format -i -style=file + git ls-files --exclude-standard ::*.cmake ::*CMakeLists.txt | xargs cmake-format -i endif clean: From c0778632fe8e258aa635d1bd23dcf4ea8e19f8b1 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Sat, 26 Apr 2025 21:40:07 +0200 Subject: [PATCH 4/7] Fix gcovr.cfg --- gcovr.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcovr.cfg b/gcovr.cfg index afb8f63..994cde9 100644 --- a/gcovr.cfg +++ b/gcovr.cfg @@ -11,7 +11,7 @@ exclude-directories = install exclude-directories = build/*/_deps exclude-directories = fuzz_test -gcov-ignore-parse-errors = yes +gcov-ignore-parse-errors = all print-summary = yes html-details = ./build/coverage/index.html From 4d0296b64a44ef9a1f8c35b332af3f1e71dcc10f Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Sun, 27 Apr 2025 09:30:13 +0200 Subject: [PATCH 5/7] Update CI files --- .github/workflows/ci.yml | 10 +++++----- .gitlab-ci.yml | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b31c47b..97c9cca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,9 +29,9 @@ jobs: # and your own projects needs matrix: os: - - ubuntu-22.04 - - macos-13 + - ubuntu-24.04 - macos-14 + - macos-15 - windows-2022 compiler: # you can specify the version after `-` like "llvm-13.0.0". @@ -51,7 +51,7 @@ jobs: GCOV: "llvm-cov gcov" # Only to test non-multiconfig builds - - os: ubuntu-22.04 + - os: ubuntu-24.04 compiler: gcc CMAKE_GENERATOR: "Ninja" GCOV: gcov-13 @@ -93,14 +93,14 @@ jobs: compiler: ${{ matrix.compiler }} vcvarsall: ${{ contains(matrix.os, 'windows' )}} - cmake: "3.28.4" + cmake: "3.28.6" ninja: true vcpkg: true ccache: true clangtidy: true task: true cppcheck: true - gcovr: 7.2 + gcovr: 8.3 opencppcoverage: true - name: Initialize CodeQL diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fa73a9c..c59705a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,8 +22,10 @@ stages: # for downloading apt-get update -qq apt-get install -y --no-install-recommends curl gnupg ca-certificates + echo -e "\e[0Ksection_end:`date +%s`:my_setup_linux\r\e[0K" .setup_cpp: &setup_cpp | + echo -e "\e[0Ksection_start:`date +%s`:my_setup_cpp[collapsed=true]\r\e[0KHeader of the setup linux collapsible section" curl -o ./setup-cpp -LJ "https://github.com/aminya/setup-cpp/releases/download/v0.41.1/setup-cpp-x64-linux" chmod +x ./setup-cpp ./setup-cpp --compiler $compiler --cmake true --ninja true --ccache true --vcpkg true --task true --gcovr 7 --doxygen true @@ -37,12 +39,12 @@ stages: ninja --version which gcovr && gcovr --version -# XXX not longer used! CK .task: &test | task coverage task coverage_release task install +# TODO(CK): not used yet! .build: script: - *setup_cpp From e4074283baf40c82481d59ebb013c5dba035de0f Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Sun, 27 Apr 2025 10:36:06 +0200 Subject: [PATCH 6/7] Update dependencies at vcpkg.json --- CMakeLists.txt | 5 ++++- Makefile | 3 ++- vcpkg.json | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d1fe34f..86bbcf1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.21...3.31) +cmake_minimum_required(VERSION 3.21...4.0) # set a default CXX standard for the tools and targets that do not specify them. # If commented, the latest supported standard for your compiler is automatically set. @@ -11,6 +11,9 @@ include(FetchContent) if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") cmake_policy(SET CMP0135 NEW) endif() +if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.31.0") + cmake_policy(SET CMP0177 NEW) +endif() # Add project_options from https://github.com/aminya/project_options # Change the version in the following URL to update the package (watch the releases of the repository for future updates) diff --git a/Makefile b/Makefile index 658d4a7..93eb1a8 100644 --- a/Makefile +++ b/Makefile @@ -30,11 +30,12 @@ test_release: release test_install: release -coverage: +coverage: gcovr.cfg ifeq ($(OS), Windows_NT) OpenCppCoverage.exe --export_type cobertura:coverage.xml --cover_children -- $(MAKE) test else $(MAKE) test + mkdir -p build/coverage gcovr -j 1 --delete --root ./ --print-summary --xml-pretty --xml coverage.xml ./build --gcov-executable gcov endif diff --git a/vcpkg.json b/vcpkg.json index 73a88b5..e6e585a 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -6,7 +6,7 @@ "dependencies": [ { "name": "fmt", - "version>=": "10.1.1" + "version>=": "11.0.2#1" } ], "features": { @@ -15,7 +15,7 @@ "dependencies": [ { "name": "catch2", - "version>=": "3.4.0" + "version>=": "3.8.0" } ] } From fb73bbc2e2d1017365706f89c980eefa5f703a75 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Sun, 27 Apr 2025 11:02:39 +0200 Subject: [PATCH 7/7] Last try --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 97c9cca..c3c5a63 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,6 +62,7 @@ jobs: - os: macos-14 compiler: appleclang + GCOV: gcov # To exclude a specific job from the matrix (e.g llvm on macos-14), you can use this syntax. exclude: