Files
xone_macos/deps/Sanitizers.cmake
portersky a7d7d0f253 chore: scaffold CMake build system
Add the CMake build for the Swift + C++ macOS port, mirroring the
refix layout: deps/ modules (Platform, Flags, Sanitizers, FindUnity),
per-module static libraries (usb, auth, mt76, gip, hid, api), a Swift
app entry point with a pure C bridge header, and a Unity test suite
behind BUILD_TESTING.

Swift requires the Ninja or Xcode generator; a guard in
CMakeLists.txt rejects anything else.

Co-Authored-By: qwen (qwen/qwen3.8-27b@q2_k_xl): scaffolded CMake build + tests
2026-08-17 14:18:03 +02:00

29 lines
1.1 KiB
CMake

# ==============================================================================
# Sanitizers
# ==============================================================================
# AddressSanitizer (ASan) support.
# Works with GCC/Clang on Linux and macOS, Clang on Windows (requires
# compiler-rt with sanitizers), and MSVC on Windows (/fsanitize=address).
#
# Usage: cmake -DENABLE_ASAN=ON ...
# ==============================================================================
option(ENABLE_ASAN "Build with AddressSanitizer" OFF)
if (ENABLE_ASAN)
if (ENABLE_COVERAGE)
message(FATAL_ERROR "ENABLE_ASAN and ENABLE_COVERAGE cannot be used together")
endif()
if (MSVC)
add_compile_options(/fsanitize=address)
message(STATUS "ASan: enabled (MSVC)")
elseif (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
add_link_options(-fsanitize=address)
message(STATUS "ASan: enabled (${CMAKE_C_COMPILER_ID})")
else()
message(FATAL_ERROR "ENABLE_ASAN: unsupported compiler ${CMAKE_C_COMPILER_ID}")
endif()
endif()