aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorRichard Qin <richard.qin.x@gmail.com>2026-04-08 03:23:16 +0800
committerRichard Qin <richard.qin.x@gmail.com>2026-04-08 03:23:16 +0800
commit4b31d8f59a6d3237f176a122c82f46fdaef4551d (patch)
tree917c9d42bb2cdbe96f5fc5416ae55789986029d7 /CMakeLists.txt
parent5ab3efd522cf0221481684b5bbc9c2ac6bfc9919 (diff)
downloadratp-4b31d8f59a6d3237f176a122c82f46fdaef4551d.tar.gz
ratp-4b31d8f59a6d3237f176a122c82f46fdaef4551d.tar.xz
feat: enhance clang-tidy configuration and improve code quality across multiple filesHEADmaster
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt13
1 files changed, 10 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1b6473e..2257766 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,8 +12,8 @@ set(CMAKE_CXX_EXTENSIONS OFF)
# Export compile_commands.json for clang-tidy and IDE support
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
-# ─── Compiler Warnings ──────────────────────────────────────────────────────
-add_compile_options(
+# ─── Compiler Warnings ──────────────────────────
+set(ATP_PROJECT_WARNING_FLAGS
-Wall -Wextra -Wpedantic
-Wshadow -Wnon-virtual-dtor
-Wold-style-cast -Wcast-align -Wunused
@@ -34,7 +34,6 @@ option(ATP_ENABLE_CLANG_TIDY "Enable clang-tidy static analysis" OFF)
if(ATP_ENABLE_CLANG_TIDY)
find_program(CLANG_TIDY_EXE NAMES clang-tidy)
if(CLANG_TIDY_EXE)
- set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE}")
message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
else()
message(WARNING "clang-tidy requested but not found")
@@ -91,10 +90,18 @@ add_library(atp_core STATIC ${ATP_SOURCES})
target_include_directories(atp_core PUBLIC
${PROJECT_SOURCE_DIR}/include
)
+target_compile_options(atp_core PRIVATE ${ATP_PROJECT_WARNING_FLAGS})
+if(ATP_ENABLE_CLANG_TIDY AND CLANG_TIDY_EXE)
+ set_property(TARGET atp_core PROPERTY CXX_CLANG_TIDY "${CLANG_TIDY_EXE}")
+endif()
# ─── Main Executable ────────────────────────────────────────────────────────
add_executable(atp src/main.cc)
target_link_libraries(atp PRIVATE atp_core)
+target_compile_options(atp PRIVATE ${ATP_PROJECT_WARNING_FLAGS})
+if(ATP_ENABLE_CLANG_TIDY AND CLANG_TIDY_EXE)
+ set_property(TARGET atp PROPERTY CXX_CLANG_TIDY "${CLANG_TIDY_EXE}")
+endif()
# ─── Tests ───────────────────────────────────────────────────────────────────
option(ATP_BUILD_TESTS "Build unit tests" ON)