Skip to content
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/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,8 @@ jobs:
with:
modules_support_needed: true
secrets: inherit

tests:
name: ✅ Testing w/ Clang-Tidy enabled
uses: libhal/ci/.github/workflows/tests.yml@5.x.y
secrets: inherit
21 changes: 11 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ cmake_minimum_required(VERSION 4.0)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_COLOR_DIAGNOSTICS ON)
set(CMAKE_CXX_SCAN_FOR_MODULES ON)
set(USE_CLANG_TIDY ON)

project(strong_ptr LANGUAGES CXX)

Expand All @@ -28,18 +27,20 @@ project(strong_ptr LANGUAGES CXX)

if(CMAKE_CROSSCOMPILING)
message(STATUS "Cross compiling, skipping clang-tidy")
else()
if(USE_CLANG_TIDY)
find_program(CLANG_TIDY_EXE NAMES clang-tidy)
if(CLANG_TIDY_EXE)
message(STATUS "Clang-tidy found: ${CLANG_TIDY_EXE}")
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE};--config-file=${CMAKE_CURRENT_SOURCE_DIR}/.clang-tidy;--fix")
else()
message(STATUS "Clang-tidy not found - continuing without clang-tidy")
elseif(LIBHAL_ENABLE_CLANG_TIDY)
find_program(CLANG_TIDY_EXE NAMES clang-tidy)
if(CLANG_TIDY_EXE)
message(STATUS "Clang-tidy found: ${CLANG_TIDY_EXE}")
set(CLANG_TIDY_CMD "${CLANG_TIDY_EXE};--config-file=${CMAKE_CURRENT_SOURCE_DIR}/.clang-tidy")
if(LIBHAL_CLANG_TIDY_FIX)
list(APPEND CLANG_TIDY_CMD "--fix")
endif()
set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_CMD})
else()
message(WARNING "Clang-tidy checks disabled")
message(STATUS "Clang-tidy not found - continuing without clang-tidy")
endif()
else()
message(STATUS "Clang-tidy checks disabled (use -o enable_clang_tidy=True to enable)")
endif()

# ==============================================================================
Expand Down
11 changes: 11 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ class strong_ptr_conan(ConanFile):
"CMakeLists.txt", "LICENSE", ".clang-tidy")
shared = False

options = {
"enable_clang_tidy": [True, False],
"clang_tidy_fix": [True, False],
}
default_options = {
"enable_clang_tidy": False,
"clang_tidy_fix": False,
}

@property
def _min_cppstd(self):
return "23"
Expand Down Expand Up @@ -111,6 +120,8 @@ def layout(self):
def generate(self):
tc = CMakeToolchain(self)
tc.generator = "Ninja"
tc.variables["LIBHAL_ENABLE_CLANG_TIDY"] = self.options.enable_clang_tidy
tc.variables["LIBHAL_CLANG_TIDY_FIX"] = self.options.clang_tidy_fix
tc.generate()

deps = CMakeDeps(self)
Expand Down