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

Use clang-tidy through cmake #341

Merged
merged 4 commits into from
Dec 25, 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
11 changes: 3 additions & 8 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,9 @@ jobs:
env:
CC: ${{ matrix.config.cc }}
CXX: ${{ matrix.config.cxx }}
run: |
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
- name: make
run: |
cd build
cmake --build . --config Release # `config Release` somehow necessary by windows
run: cmake -B build -S . -DCMAKE_BUILD_TYPE=Release
- name: build
run: cmake --build build --config Release # `config Release` somehow necessary by windows

- name: upload binaries
uses: actions/upload-artifact@v2
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ jobs:
runs-on: ubuntu-22.04

steps:
- run: sudo apt install clang-format-15

- run: clang-format-15 --version

- name: checkout
Expand Down
14 changes: 3 additions & 11 deletions .github/workflows/tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ jobs:
runs-on: ubuntu-22.04

steps:
- name: ubuntu install clang-tidy
run: |
sudo apt install clang-tidy-12
clang-tidy-12 --version
- run: clang-tidy --version

- name: set up python 3.8
uses: actions/setup-python@v2
Expand All @@ -31,12 +28,7 @@ jobs:
uses: actions/checkout@v2

- name: cmake
run: |
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
run: cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DODR_CLANG_TIDY=ON

- name: clang-tidy
run: |
FILES=$( find . -path ./build -prune -false -o -type f \( -iname \*.cpp \) )
clang-tidy-12 -p build -header-filter '.*' $FILES
run: cmake --build build
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

option(ODR_TEST "enable tests" ON)
option(ODR_CLANG_TIDY "Run clang-tidy static analysis" OFF)

# TODO defining global compiler flags seems to be bad practice with conan
# TODO consider using conan profiles
Expand Down Expand Up @@ -163,15 +164,15 @@ add_library(odr

"src/odr/internal/zip/zip_util.cpp"
"src/odr/internal/zip/zip_archive.cpp"
)
)
set_target_properties(odr PROPERTIES OUTPUT_NAME odr)
if (EXISTS "${PROJECT_SOURCE_DIR}/.git")
add_dependencies(odr check_git)
endif ()
target_include_directories(odr
PUBLIC
src
)
)
target_link_libraries(odr
PRIVATE
pugixml::pugixml
Expand All @@ -180,14 +181,18 @@ target_link_libraries(odr
nlohmann_json::nlohmann_json
vincentlaucsb-csv-parser::vincentlaucsb-csv-parser
uchardet::uchardet
)
)

add_subdirectory("cli")

if (ODR_TEST)
add_subdirectory("test")
endif ()

if (ODR_CLANG_TIDY)
add_subdirectory("static_analysis/clang-tidy")
endif ()

install(
TARGETS
odr
Expand Down
10 changes: 10 additions & 0 deletions static_analysis/clang-tidy/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
find_program(CLANG_TIDY_COMMAND NAMES clang-tidy)

if (NOT CLANG_TIDY_COMMAND)
message(ERROR "ACTS_RUN_CLANG_TIDY is ON but clang-tidy is not found!")
set(CMAKE_CXX_CLANG_TIDY "" CACHE STRING "" FORCE)
endif ()

message(STATUS "Setting up clang-tidy run")

set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}")
Loading