ccc5bc819d
Add the mt76::chip class on top of the USB transport: 32-bit register read/write via vendor requests, register polling, and EFUSE reads with the kick/control sequence from transport/mt76.c. Expose chip_id() and mac_address() (with the 62:45:bd fallback). Verified on hardware: chip ID 0x7612 (MT7612) and MAC address read from EFUSE. Co-Authored-By: qwen3.8-27b@q2_k_xl: ported register and EFUSE layer
115 lines
4.5 KiB
CMake
115 lines
4.5 KiB
CMake
# CMake supports Swift only with the Ninja and Xcode generators.
|
|
if(NOT CMAKE_GENERATOR MATCHES "^(Ninja|Xcode)$")
|
|
message(FATAL_ERROR
|
|
"This project requires the Ninja or Xcode generator for Swift support.\n"
|
|
" Configure with: cmake -S . -B build -G Ninja")
|
|
endif()
|
|
|
|
cmake_minimum_required(VERSION 3.21)
|
|
project(xone_macos VERSION 0.1.5 LANGUAGES CXX Swift)
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
# Add the deps directory to the module path
|
|
# Required for find_package injection
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/deps")
|
|
|
|
# Platform and compiler detection
|
|
include(Platform)
|
|
include(Flags)
|
|
include(Sanitizers)
|
|
|
|
# ==============================================================================
|
|
# Module libraries (bottom-up layering, mirrors medusalix/xone structure)
|
|
# ==============================================================================
|
|
|
|
# USB transport (IOKit / IOUSBFamily)
|
|
add_library(xone_usb STATIC
|
|
"src/usb/usb_transport.cpp"
|
|
)
|
|
target_include_directories(xone_usb PUBLIC "${CMAKE_SOURCE_DIR}/include")
|
|
target_compile_features(xone_usb PRIVATE cxx_std_23)
|
|
target_compile_options(xone_usb PRIVATE ${BASE_OPTIONS})
|
|
target_compile_definitions(xone_usb PRIVATE ${BASE_DEFINITIONS})
|
|
find_library(XONE_IOKIT IOKit)
|
|
find_library(XONE_COREFOUNDATION CoreFoundation)
|
|
target_link_libraries(xone_usb PUBLIC "${XONE_IOKIT}" "${XONE_COREFOUNDATION}")
|
|
|
|
# Auth + crypto (AES-CCMP key setup, ECDH, RSA — port from auth/)
|
|
add_library(xone_auth STATIC
|
|
"src/auth/crypto.cpp"
|
|
"src/auth/auth.cpp"
|
|
)
|
|
target_include_directories(xone_auth PUBLIC "${CMAKE_SOURCE_DIR}/include")
|
|
target_compile_features(xone_auth PRIVATE cxx_std_23)
|
|
target_compile_options(xone_auth PRIVATE ${BASE_OPTIONS})
|
|
target_compile_definitions(xone_auth PRIVATE ${BASE_DEFINITIONS})
|
|
find_library(XONE_SECURITY Security)
|
|
find_library(XONE_COREFOUNDATION CoreFoundation)
|
|
target_link_libraries(xone_auth PUBLIC "${XONE_SECURITY}" "${XONE_COREFOUNDATION}")
|
|
|
|
# MT76 chip protocol (firmware load, EFUSE, radio init, beacons)
|
|
add_library(xone_mt76 STATIC
|
|
"src/mt76/mt76.cpp"
|
|
)
|
|
target_include_directories(xone_mt76 PUBLIC "${CMAKE_SOURCE_DIR}/include")
|
|
target_compile_features(xone_mt76 PRIVATE cxx_std_23)
|
|
target_compile_options(xone_mt76 PRIVATE ${BASE_OPTIONS})
|
|
target_compile_definitions(xone_mt76 PRIVATE ${BASE_DEFINITIONS})
|
|
target_link_libraries(xone_mt76 PUBLIC xone_usb)
|
|
|
|
# GIP protocol (client lifecycle, handshake, status reports)
|
|
add_library(xone_gip STATIC
|
|
"src/gip/protocol.cpp"
|
|
)
|
|
target_include_directories(xone_gip PUBLIC "${CMAKE_SOURCE_DIR}/include")
|
|
target_compile_features(xone_gip PRIVATE cxx_std_23)
|
|
target_compile_options(xone_gip PRIVATE ${BASE_OPTIONS})
|
|
target_compile_definitions(xone_gip PRIVATE ${BASE_DEFINITIONS})
|
|
target_link_libraries(xone_gip PUBLIC xone_auth xone_mt76)
|
|
|
|
# Virtual HID gamepad presentation
|
|
add_library(xone_hid STATIC
|
|
"src/hid/hid_device.cpp"
|
|
)
|
|
target_include_directories(xone_hid PUBLIC "${CMAKE_SOURCE_DIR}/include")
|
|
target_compile_features(xone_hid PRIVATE cxx_std_23)
|
|
target_compile_options(xone_hid PRIVATE ${BASE_OPTIONS})
|
|
target_compile_definitions(xone_hid PRIVATE ${BASE_DEFINITIONS})
|
|
target_link_libraries(xone_hid PUBLIC xone_gip)
|
|
|
|
# C ABI bridge consumed by the Swift app and the test suite
|
|
add_library(xone_api STATIC
|
|
"src/app/api.cpp"
|
|
)
|
|
target_include_directories(xone_api PUBLIC "${CMAKE_SOURCE_DIR}/include")
|
|
target_compile_features(xone_api PRIVATE cxx_std_23)
|
|
target_compile_options(xone_api PRIVATE ${BASE_OPTIONS})
|
|
target_compile_definitions(xone_api PRIVATE XONE_VERSION="${PROJECT_VERSION}")
|
|
target_link_libraries(xone_api PUBLIC xone_hid)
|
|
|
|
# ==============================================================================
|
|
# macOS app (Swift entry point)
|
|
# ==============================================================================
|
|
add_executable(xone_app
|
|
"src/app/main.swift"
|
|
)
|
|
target_include_directories(xone_app PRIVATE "${CMAKE_SOURCE_DIR}/include")
|
|
target_compile_definitions(xone_app PRIVATE ${BASE_DEFINITIONS})
|
|
target_link_libraries(xone_app PRIVATE xone_api ${BASE_LIBRARIES})
|
|
|
|
# Swift sees the C ABI via a bridging header (no module map required)
|
|
target_compile_options(xone_app PRIVATE
|
|
-import-objc-header "${CMAKE_SOURCE_DIR}/include/app/xone_api.h"
|
|
)
|
|
|
|
# ==============================================================================
|
|
# Tests
|
|
# ==============================================================================
|
|
option(BUILD_TESTING OFF "Build Unity test suites")
|
|
if (BUILD_TESTING)
|
|
enable_testing()
|
|
find_package(Unity REQUIRED)
|
|
add_subdirectory(tests)
|
|
endif()
|