Skip to content

Commit

Permalink
Feature/use cpmfindpackage (#1)
Browse files Browse the repository at this point in the history
* Use cpmfindpackage if possible

Use current version of ftxui package with UNITY_BUILD fix.

* Cleanup and format cmake files

* Fix typos with codespell -w .

* Use cmake presets in .gitlab-ci.yml

Note: Only linux debug presets yet.

* Add gcovr.cfg

* Refactor Dependencies.cmake

* Add needed subdir for coverage

* Use latest OS versions on CI

* clang-tidy -extra-arg=-Wno-unknown-warning-option used

Sort clang-ignore list
  • Loading branch information
ClausKlein committed Mar 20, 2024
1 parent bacc570 commit 7030b87
Show file tree
Hide file tree
Showing 17 changed files with 176 additions and 135 deletions.
12 changes: 7 additions & 5 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ Checks: "*,
-abseil-*,
-altera-*,
-android-*,
-bugprone-suspicious-include,
-clang-diagnostic-ignored-optimization-argument,
-cppcoreguidelines-non-private-member-variables-in-classes,
-fuchsia-*,
-google-*,
-llvm*,
-misc-non-private-member-variables-in-classes,
-modernize-use-trailing-return-type,
-zircon-*,
-readability-avoid-const-params-in-decls,
-readability-else-after-return,
-readability-static-accessed-through-instance,
-readability-avoid-const-params-in-decls,
-cppcoreguidelines-non-private-member-variables-in-classes,
-misc-non-private-member-variables-in-classes,
-zircon-*,
"
WarningsAsErrors: ''
WarningsAsErrors: 'c*'
HeaderFilterRegex: ''
FormatStyle: none

Expand Down
5 changes: 5 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[codespell]
builtin = clear,rare,en-GB_to_en-US,names,informal,code
check-hidden =
skip = ./.git,./out/*,./cmake-build-*,./build/*,./prefix/*,./conan/*,./stagedir/*,*.log,.*.swp,*~,*.bak
quiet-level = 2
2 changes: 1 addition & 1 deletion .devcontainer/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ build/
out/
cmake-build-*/

# User spesific settings
# User specific settings
CMakeUserPresets.json

# IDE files
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ RUN apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \
apt-get install -y --no-install-recommends \
neovim emacs nano

# Install optional dependecies
# Install optional dependencies
RUN apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \
apt-get install -y --no-install-recommends \
doxygen graphviz ccache cppcheck
Expand Down
1 change: 1 addition & 0 deletions .github/actions/setup_cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ runs:
with:
# You might want to add .ccache to your cache configuration?
path: |
~/.cache/CPM
~/.cache/pip
~/.ccache
key: ${{ runner.os }}-${{ inputs.compiler }}-${{ inputs.build_type }}-${{ inputs.generator }}-${{ inputs.packaging_maintainer_mode }}-${{ hashFiles('**/CMakeLists.txt') }}
Expand Down
23 changes: 12 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ on:

env:
CLANG_TIDY_VERSION: "15.0.2"
CPM_SOURCE_CACHE: ~/.cache/CPM
VERBOSE: 1


jobs:
Test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
fail-fast: true

# Recommendations:
# * support at least 2 operating systems
Expand All @@ -29,13 +30,13 @@ jobs:
# and your own projects needs
matrix:
os:
- ubuntu-20.04
- macos-10.15
- windows-2019
- ubuntu-latest
- macos-latest
- windows-2022
compiler:
# you can specify the version after `-` like "llvm-15.0.2".
- llvm-15.0.2
- gcc-11
- gcc
generator:
- "Ninja Multi-Config"
build_type:
Expand All @@ -49,21 +50,21 @@ jobs:

exclude:
# mingw is determined by this author to be too buggy to support
- os: windows-2019
compiler: gcc-11
- os: windows-2022
compiler: gcc

include:
# Add appropriate variables for gcov version required. This will intentionally break
# if you try to use a compiler that does not have gcov set
- compiler: gcc-11
- compiler: gcc
gcov_executable: gcov
enable_ipo: On

- compiler: llvm-15.0.2
enable_ipo: Off
gcov_executable: "llvm-cov gcov"

- os: macos-10.15
- os: macos-latest
enable_ipo: Off

# Set up preferred package generators, for given build configurations
Expand All @@ -72,8 +73,8 @@ jobs:
package_generator: TBZ2

# This exists solely to make sure a non-multiconfig build works
- os: ubuntu-20.04
compiler: gcc-11
- os: ubuntu-latest
compiler: gcc
generator: "Unix Makefiles"
build_type: Debug
gcov_executable: gcov
Expand Down
114 changes: 57 additions & 57 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,60 +48,60 @@ jobs:


steps:
- uses: actions/checkout@v3

- name: Setup Cache
uses: ./.github/actions/setup_cache
with:
compiler: ${{ matrix.compiler }}
build_type: ${{ matrix.build_type }}
packaging_maintainer_mode: ${{ matrix.packaging_maintainer_mode }}
generator: ${{ matrix.generator }}

- name: Project Name
uses: cardinalby/export-env-action@v2
with:
envFile: '.github/constants.env'


- name: Setup Cpp
uses: aminya/setup-cpp@v1
with:
compiler: ${{ matrix.compiler }}
vcvarsall: ${{ contains(matrix.os, 'windows' )}}

cmake: true
ninja: true
vcpkg: false
ccache: true
clangtidy: false

cppcheck: false

gcovr: false
opencppcoverage: false

# make sure coverage is only enabled for Debug builds, since it sets -O0 to make sure coverage
# has meaningful results
- name: Configure CMake
run: |
cmake -S . -B ./build -G "${{matrix.generator}}" -DCMAKE_BUILD_TYPE:STRING=${{matrix.build_type}} -D${{ env.PROJECT_NAME }}_PACKAGING_MAINTAINER_MODE:BOOL=${{matrix.packaging_maintainer_mode}} -D${{ env.PROJECT_NAME }}_ENABLE_COVERAGE:BOOL=${{ matrix.build_type == 'Debug' }}
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main


- name: Build
# Execute the build. You can specify a specific target with "--target <NAME>"
run: |
cmake --build ./build --config ${{matrix.build_type}}
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
- uses: actions/checkout@v3

- name: Setup Cache
uses: ./.github/actions/setup_cache
with:
compiler: ${{ matrix.compiler }}
build_type: ${{ matrix.build_type }}
packaging_maintainer_mode: ${{ matrix.packaging_maintainer_mode }}
generator: ${{ matrix.generator }}

- name: Project Name
uses: cardinalby/export-env-action@v2
with:
envFile: '.github/constants.env'


- name: Setup Cpp
uses: aminya/setup-cpp@v1
with:
compiler: ${{ matrix.compiler }}
vcvarsall: ${{ contains(matrix.os, 'windows' )}}

cmake: true
ninja: true
vcpkg: false
ccache: true
clangtidy: false

cppcheck: false

gcovr: false
opencppcoverage: false

# make sure coverage is only enabled for Debug builds, since it sets -O0 to make sure coverage
# has meaningful results
- name: Configure CMake
run: |
cmake -S . -B ./build -G "${{matrix.generator}}" -DCMAKE_BUILD_TYPE:STRING=${{matrix.build_type}} -D${{ env.PROJECT_NAME }}_PACKAGING_MAINTAINER_MODE:BOOL=${{matrix.packaging_maintainer_mode}} -D${{ env.PROJECT_NAME }}_ENABLE_COVERAGE:BOOL=${{ matrix.build_type == 'Debug' }}
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main


- name: Build
# Execute the build. You can specify a specific target with "--target <NAME>"
run: |
cmake --build ./build --config ${{matrix.build_type}}
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
12 changes: 5 additions & 7 deletions .github/workflows/template-janitor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
developer_mode: ${{ matrix.developer_mode }}
generator: ${{ matrix.generator }}

- name: Get organization and project name
- name: Get organization and project name
run: |
echo "NEW_ORG=${{ github.repository_owner }}" >> $GITHUB_ENV
echo "NEW_PROJECT=${{ github.event.repository.name }}" >> $GITHUB_ENV
Expand All @@ -69,9 +69,9 @@ jobs:
run: |
# hyphens and dots in c++ identifiers are forbidden. Use underscores instead.
NEW_SAFE_PROJECT=$(echo ${{ env.NEW_PROJECT }} | sed "s/-/_/g" | sed "s/\./_/g" )
echo "NEW_SAFE_PROJECT=$NEW_SAFE_PROJECT" >> $GITHUB_ENV
echo "NEW_SAFE_PROJECT=$NEW_SAFE_PROJECT" >> $GITHUB_ENV
# Rename all cpp_starter_project occurences to current repository and remove this workflow
# Rename all cpp_starter_project occurrences to current repository and remove this workflow
- name: Insert new org and project
run: |
# rename the CMake project to match the github project
Expand Down Expand Up @@ -129,7 +129,6 @@ jobs:
envFile: '.github/constants.env'



- name: Test simple configuration to make sure nothing broke
run: |
cmake -S . -B ./build -G "${{ matrix.generator }}" -DCMAKE_BUILD_TYPE:STRING=${{ matrix.build_type }} -D${{ env.NEW_SAFE_PROJECT }}_PACKAGING_MAINTAINER_MODE:BOOL=ON
Expand All @@ -149,7 +148,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}



template-rename:
name: Renames template when a new name is detected
runs-on: ubuntu-latest
Expand All @@ -175,7 +173,7 @@ jobs:
developer_mode: ${{ matrix.developer_mode }}
generator: ${{ matrix.generator }}

- name: Get organization and project name
- name: Get organization and project name
run: |
echo "TEST_RUN=false" >> $GITHUB_ENV
echo "NEW_ORG=${{ github.repository_owner }}" >> $GITHUB_ENV
Expand Down Expand Up @@ -205,7 +203,7 @@ jobs:
# Rename all cpp_starter_project occurrences to current repository and remove this workflow
- name: Update repository to match new template information
run: |
# Update the README and template files to match the new org / repository names
# Update the README and template files to match the new org / repository names
sed -i "s|${{ env.TEMPLATE_REPOSITORY }}|${{ env.NEW_REPOSITORY }}|g" README.md ${{ env.TEMPLATES_PATH }}/template_repository
sed -i "s|${{ env.TEMPLATE_NAME }}|${{ env.NEW_PROJECT }}|g" README.md ${{ env.TEMPLATES_PATH }}/template_name
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ out/coverage/*
cmake-build-*/
conan-cache/

# User spesific settings
# User specific settings
CMakeUserPresets.json

# IDE files
Expand Down
15 changes: 9 additions & 6 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,21 @@ stages:
--clangtidy true --clangformat true --cppcheck true --gcovr true
source ~/.cpprc
echo -e "section_end:"`date +%s`":hidden_section\r\e[0Ksection_start:"`date +%s`":.setup_cpp\r\e[0K"
clang-tidy --version
cmake --version
ninja --version
clang --version
gcc --version
cmake --version
echo "ninja --version" && ninja --version

# with foldable multi-line commands
.build:
script:
- *setup_cpp
- echo -e "section_end:"`date +%s`":.build\r\e[0Ksection_start:"`date +%s`":hidden_section\r\e[0K configure"
- cmake -S . -B ./build -G Ninja -D CMAKE_BUILD_TYPE=Debug -D CMAKE_UNITY_BUILD=YES -D CMAKE_SKIP_INSTALL_RULES=YES
- cmake --preset unixlike-${COMPILER}-debug
- run-clang-tidy -p out/build/unixlike-${COMPILER}-debug -extra-arg=-Wno-unknown-warning-option
- echo -e "section_end:"`date +%s`":hidden_section\r\e[0Ksection_start:"`date +%s`":.build\r\e[0K"
- cmake --build ./build --config Debug
- cmake --build ./build --config Debug --target test
- ninja -C out/build/unixlike-${COMPILER}-debug
- ninja -C out/build/unixlike-${COMPILER}-debug test
- gcovr .

default:
Expand All @@ -49,10 +50,12 @@ test_linux_llvm:
stage: test
variables:
compiler: llvm
COMPILER: clang
extends: .build

test_linux_gcc:
stage: test
variables:
compiler: gcc
COMPILER: gcc
extends: .build
Loading

0 comments on commit 7030b87

Please sign in to comment.