-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR enables `clang-tidy` in the main CMake file [5]. Clang-tidy will help to enable developer guidelines such as [1,2]. The C++ Core Guidelines checkers are more a MSVC tool, which is not usable in a multi-platform development framework. A documentation for `clang-tidy` can be found in [4]. References: [1] https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines [2] https://developers.google.com/style/ [3] https://github.com/MicrosoftDocs/cpp-docs/blob/main/docs/code-quality/using-the-cpp-core-guidelines-checkers.md [4] https://clang.llvm.org/extra/clang-tidy/ [5] https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_CLANG_TIDY.html * Add Clang-Tidy to the project * Install LLVM for Clang-Tidy on MacOS Why? * The CXX compiler identification is AppleClang 14.0.0.14000029 * ls -la /Library/Developer/CommandLineTools/usr/bin/c* * For more information, see https://stackoverflow.com/questions/53111082/how-to-install-clang-tidy-on-macos * Add GitHub's `homebrew` path hint to `find_program`
- Loading branch information
1 parent
fe424e7
commit 6a26946
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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=*; | ||
) | ||
|
||
# set CXX_CLANG_TIDY property after defining the target | ||
# set_target_properties(EGOA PROPERTIES CXX_CLANG_TIDY "${CMAKE_CXX_CLANG_TIDY}") |