diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2139604..beeef60 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,3 +44,8 @@ jobs: modules_support_needed: true coroutine_support_needed: true secrets: inherit + + tests: + name: ✅ Testing w/ Clang-Tidy enabled + uses: libhal/ci/.github/workflows/tests.yml@5.x.y + secrets: inherit diff --git a/CMakeLists.txt b/CMakeLists.txt index f6a52a2..4e6356d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,18 +33,20 @@ project(async_context 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() # ============================================================================== diff --git a/conanfile.py b/conanfile.py index ad6b43a..26deab5 100644 --- a/conanfile.py +++ b/conanfile.py @@ -36,6 +36,14 @@ class async_context_conan(ConanFile): exports_sources = "modules/*", "benchmarks/*", "tests/*", "CMakeLists.txt", "LICENSE", ".clang-tidy" package_type = "static-library" 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): @@ -104,6 +112,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)