Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cmake workflow presets #124

Merged
merged 8 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove this file from the commit as it contains user specific configuration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Die you see the bugprone-use-after-move comments?

I hoped you use it to fix this errors.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confess I haven't run clang tidy in a long time on the code. But thanks for the hint, will have a look

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With clang-17 the are much more Warnungen.

#
# clang-format v12.0.0
#
Checks:
'-*,
#TBD llvm-header-guard,
bugprone-*,
cert-*,
clang-analyzer-*,
-clang-analyzer-cplusplus.Move,
cppcoreguidelines-*,
-cppcoreguidelines-macro-usage,
concurrency-*,
#MAYBE google-*,
hicpp-*,
-hicpp-explicit-conversions,
misc-*,
-misc-const-correctness,
-misc-include-cleaner,
modernize-*,
-modernize-type-traits,
-modernize-use-nodiscard,
-modernize-use-trailing-return-type,
performance-*,
portability-*,
readability-*,
-readability-identifier-naming,
-readability-identifier-length,
-readability-simplify-boolean-expr,
-readability-string-compare,
-*-magic-numbers,
-*-narrowing-conversions,
-*-uppercase-literal-suffix,
'

HeaderFilterRegex: '.*'
WarningsAsErrors: 'clang*'
FormatStyle: google
UseColor: false

#MAYBE: ... example only
CheckOptions:
- { key: readability-identifier-naming.NamespaceCase, value: CamelCase }
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
- { key: readability-identifier-naming.MemberCase, value: camelBack }
- { key: readability-identifier-naming.MemberPrefix, value: m_ }
- { key: readability-identifier-naming.StructCase, value: lower_case }
- { key: readability-identifier-naming.UnionCase, value: lower_case }
- { key: readability-identifier-naming.TypedefCase, value: lower_case }
- { key: readability-identifier-naming.TypedefSuffix, value: _type }
- { key: readability-identifier-naming.FunctionCase, value: camelBack }
- { key: readability-identifier-naming.EnumCase, value: CamelCase }
- { key: readability-identifier-naming.ConstexprFunctionCase, value: CamelCase }
- { key: readability-identifier-naming.ConstexprMethodCase, value: CamelCase }
- { key: readability-identifier-naming.ConstexprVariableCase, value: CamelCase }
- { key: readability-identifier-naming.ClassConstantCase, value: UPPER_CASE }
- { key: readability-identifier-naming.EnumConstantCase, value: UPPER_CASE }
- { key: readability-identifier-naming.GlobalConstantCase, value: UPPER_CASE }
- { key: readability-identifier-naming.GlobalConstantPointerCase, value: UPPER_CASE }
- { key: readability-identifier-naming.LocalConstantPointerCase, value: UPPER_CASE }
- { key: readability-identifier-naming.ScopedEnumConstantCase, value: UPPER_CASE }
- { key: readability-identifier-naming.StaticConstantCase, value: UPPER_CASE }
...
2 changes: 1 addition & 1 deletion .github/workflows/api-doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
name: generate-doxygen
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: install dependencies
run: |
sudo apt install doxygen graphviz
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
name: Run SI benchmarks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: install dependencies
run: |
sudo -H pip3 install setuptools wheel
Expand All @@ -17,7 +17,6 @@ jobs:

- name: Build and run benchmarks with Catch2
run: |

conan install . --output-folder=build --build=missing --settings=build_type=Release
cmake --preset=ci-ninja-release
cmake --build build --target SI_unit_benchmarks
Expand Down
41 changes: 21 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,40 @@ jobs:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: true
fail-fast: false
matrix:
name:
[ubuntu-gcc-9, ubuntu-clang-12, macos-apple-clang-11, windows-msvc-19]
[ubuntu-gcc-11, ubuntu-clang-13, macos-apple-clang, windows-msvc-19]
include:
- name: ubuntu-gcc-9
- name: ubuntu-gcc-11
os: ubuntu-22.04
compiler: g++
compiler-version: 9
compiler-version: 11
compiler-name-conan: gcc

- name: ubuntu-clang-12
- name: ubuntu-clang-13
os: ubuntu-22.04
compiler: clang++
compiler-version: "12"
compiler-version: "13"
compiler-name-conan: clang

- name: macos-apple-clang-11
os: macos-11

- name: macos-apple-clang
os: macos-latest
compiler-cppstd: "gnu17"

- name: windows-msvc-19
os: windows-2019
configure-preset: "ci-windows-msvc2019"
build-preset: "ci-msvc2019-debug"


steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt install shunit2 ninja-build python3-setuptools python3-pip -y
sudo pip3 install conan


- name: dependencies (macos)
if: runner.os == 'macOS'
Expand All @@ -59,7 +58,7 @@ jobs:
pip install conan
curl -L0 https://github.com/kward/shunit2/archive/v2.1.7.zip --output shunit2.zip
unzip -j -n shunit2.zip

- name: set-compiler-env
run: |
if [ "${{ matrix.compiler }}" != "" ]; then
Expand All @@ -71,10 +70,13 @@ jobs:
run: |
conan profile detect --force
if [ "${{ matrix.compiler-name-conan }}" != "" ]; then
sed -i 's/compiler=.*/compiler=${{ matrix.compiler-name-conan }}/g' ~/.conan2/profiles/default
sed -i.bak -e 's/compiler=.*/compiler=${{ matrix.compiler-name-conan }}/g' ~/.conan2/profiles/default
fi
if [ "${{ matrix.compiler-version }}" != "" ]; then
sed -i 's/compiler.version=[0-9]\+/compiler.version=${{ matrix.compiler-version }}/g' ~/.conan2/profiles/default
sed -i.bak -e 's/compiler.version=[0-9]\+/compiler.version=${{ matrix.compiler-version }}/g' ~/.conan2/profiles/default
fi
if [ "${{ matrix.compiler-cppstd }}" != "" ]; then
sed -i.bak -e 's/compiler.cppstd=gnu[0-9]\+/compiler.cppstd=${{ matrix.compiler-cppstd }}/g' ~/.conan2/profiles/default
fi
shell: bash

Expand All @@ -86,16 +88,15 @@ jobs:
else
cmake --preset=ci-ninja-debug
fi

shell: bash

- name: build-debug
run: |

if [ "${{ matrix.build-preset }}" != "" ]; then
cmake --build ./build --preset=${{ matrix.build-preset }}
else
cmake --build ./build
cmake --build ./build
fi

shell: bash
Expand All @@ -121,7 +122,7 @@ jobs:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- name: build
run: |
cmake --preset ci-ninja-debug
cmake --build build
cmake --build build

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
Expand Down
28 changes: 14 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
cmake_minimum_required(VERSION 3.23)
cmake_minimum_required(VERSION 3.23...3.27)

if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
endif()

project(
"SI"
Expand All @@ -9,28 +14,21 @@ project(
LANGUAGES CXX)

include(GNUInstallDirs)
include(CTest)

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(IS_TOPLEVEL_PROJECT TRUE)
else()
set(IS_TOPLEVEL_PROJECT FALSE)
endif()

option(SI_INSTALL_LIBRARY
"Enable installing of SI library into default locations"
${IS_TOPLEVEL_PROJECT})
option(SI_BUILD_TESTING "Build and run SI tests " ${IS_TOPLEVEL_PROJECT})
option(SI_BUILD_DOC "Generate SI documentation" ${IS_TOPLEVEL_PROJECT})
${PROJECT_IS_TOP_LEVEL})
option(SI_BUILD_TESTING "Build and run SI tests " ${PROJECT_IS_TOP_LEVEL})
option(SI_BUILD_DOC "Generate SI documentation" ${PROJECT_IS_TOP_LEVEL})

# Only search for Catch2 if we're doing testing
# (this reduces the amount of warnings when added via FetchContent or git submodules)
if(SI_BUILD_TESTING)
find_package(Catch2)
if (NOT Catch2_FOUND)
if(NOT Catch2_FOUND)
message(WARNING "Catch2 not found, not building tests")
set(SI_BUILD_TESTING OFF)
endif ()
endif()
endif()

add_library(SI INTERFACE)
Expand All @@ -45,7 +43,9 @@ target_include_directories(

target_compile_features(SI INTERFACE cxx_std_17)

if(BUILD_TESTING AND SI_BUILD_TESTING)
if(SI_BUILD_TESTING)
enable_testing()

include(Catch)
add_subdirectory(test)
endif()
Expand Down
Loading
Loading