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 Clang-Tidy to the Project #54

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
5 changes: 5 additions & 0 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ jobs:
cache-key-prefix: ${{ runner.os }}-Qt-Cache-${{ env.QT_VERSION }}
dir: ${{ github.workspace }}/Qt

- name: Install LLVM for Clang-Tidy (MacOS)
if: startsWith(matrix.os,'macos-')
run: |
brew install llvm

# - name: Install correct version of mingw
# uses: crazy-max/ghaction-chocolatey@v1
# with:
Expand Down
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ if ( EGOA_ENABLE_BOOST )
include ( Boost )
endif ( EGOA_ENABLE_BOOST )

# Search for clang-tidy
find_package ( ClangTidy )

# Google tests
if ( EGOA_ENABLE_TESTS )
include ( CTest )
Expand Down Expand Up @@ -227,6 +230,13 @@ if ( Qt6_FOUND )
target_compile_definitions ( EGOA PUBLIC QT6_AVAILABLE )
endif ( Qt6_FOUND )

# clang-tidy found
if ( CLANG_TIDY_PROG )
message ( STATUS "${MY_SPACE}clang-tidy:\t\t\t\tis enabled" )
# set CXX_CLANG_TIDY property after defining the target
# set_target_properties(EGOA PROPERTIES CXX_CLANG_TIDY "${CMAKE_CXX_CLANG_TIDY}")
endif ( CLANG_TIDY_PROG )

# OpenMP found
if ( OPENMP_FOUND )
message ( STATUS "${MY_SPACE}OpenMP:\t\t\t\tadd libraries of OpenMP" )
Expand Down
29 changes: 29 additions & 0 deletions cmake/FindClangTidy.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# FindClangTidy.cmake
#
# Created on: Dec 27, 2023
# Author: Franziska Wegner
#
# This file enables clang tidy for the project.
#


# Search for clang-tidy
find_program(CLANG_TIDY_PROG
HINTS "/opt/homebrew/opt/llvm/bin/"
"/usr/local/opt/llvm/bin/"
NAMES "clang-tidy"
REQUIRED
)
# Setup clang-tidy command with executable and options, see https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_CLANG_TIDY.html.
# Disable all default checks (-*) and only enable checks that advocate the use of modern C++ language constructs with (modernize-*).
set(CMAKE_CXX_CLANG_TIDY
"${CLANG_TIDY_PROG}"
"-checks=-*,modernize-*"
# -format-style='file';
# -header-filter=${CMAKE_CURRENT_SOURCE_DIR};
# -header-filter=.;
# -warnings-as-errors=*;
franziska-wegner marked this conversation as resolved.
Show resolved Hide resolved
)

# set CXX_CLANG_TIDY property after defining the target
# set_target_properties(EGOA PROPERTIES CXX_CLANG_TIDY "${CMAKE_CXX_CLANG_TIDY}")