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
This commit is contained in:
Vendored
+82
@@ -0,0 +1,82 @@
|
||||
# ==============================================================================
|
||||
# Compiler and Linker Flags
|
||||
# ==============================================================================
|
||||
# This module sets platform-specific and compiler-specific flags, libraries,
|
||||
# and definitions used throughout the build system.
|
||||
#
|
||||
# Variables set:
|
||||
# BASE_LIBRARIES - Libraries to link based on target platform
|
||||
# BASE_DEFINITIONS - Preprocessor definitions based on target platform
|
||||
# BASE_OPTIONS - Compiler warning flags (C/C++ only, not applied to Swift)
|
||||
#
|
||||
# Requires: Platform.cmake must be included first (for IS_* variables)
|
||||
# ==============================================================================
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Framework Detection Helper
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
# find_and_link_framework(<OUT_VAR> <FRAMEWORK_NAME> <DISPLAY_NAME>)
|
||||
#
|
||||
# Searches for an Apple framework and, if found, appends -framework <name> to
|
||||
# the output list.
|
||||
#
|
||||
# Parameters:
|
||||
# - OUT_VAR Name of the list variable to append the flag to
|
||||
# - FRAMEWORK_NAME The framework name to search for (e.g. "IOKit")
|
||||
# - DISPLAY_NAME Human-readable name for status messages
|
||||
function(find_and_link_framework OUT_VAR FRAMEWORK_NAME DISPLAY_NAME)
|
||||
find_library(_FOUND_LIB ${FRAMEWORK_NAME})
|
||||
if (_FOUND_LIB)
|
||||
message(STATUS " [x] ${DISPLAY_NAME} (-framework ${FRAMEWORK_NAME})")
|
||||
list(APPEND ${OUT_VAR} "-framework ${FRAMEWORK_NAME}")
|
||||
set(${OUT_VAR} "${${OUT_VAR}}" PARENT_SCOPE)
|
||||
else()
|
||||
message(STATUS " [ ] ${DISPLAY_NAME} (-framework ${FRAMEWORK_NAME})")
|
||||
endif()
|
||||
unset(_FOUND_LIB CACHE)
|
||||
endfunction()
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Platform-Specific Link Libraries
|
||||
# ------------------------------------------------------------------------------
|
||||
# These frameworks are required for USB access, crypto and (later) audio.
|
||||
# They are linked into the final executable; static libraries reference the
|
||||
# symbols and resolution happens at final link time.
|
||||
|
||||
set(BASE_LIBRARIES "")
|
||||
if (IS_MACOS)
|
||||
message(STATUS "macOS link libraries:")
|
||||
find_and_link_framework(BASE_LIBRARIES "IOKit" "IOKit (USB transport)")
|
||||
find_and_link_framework(BASE_LIBRARIES "CoreFoundation" "Core Foundation")
|
||||
find_and_link_framework(BASE_LIBRARIES "Security" "Security (crypto/ECDH)")
|
||||
elseif (IS_IOS)
|
||||
message(FATAL_ERROR "iOS is not supported yet!")
|
||||
endif()
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Platform-Specific Definitions
|
||||
# ------------------------------------------------------------------------------
|
||||
set(BASE_DEFINITIONS "")
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Compiler Warning Flags
|
||||
# ------------------------------------------------------------------------------
|
||||
# These are stored in BASE_OPTIONS and applied per-target via
|
||||
# target_compile_options() to avoid polluting external dependencies.
|
||||
# NOTE: Applied to C/C++ targets only; swiftc does not share these flags.
|
||||
set(BASE_OPTIONS "")
|
||||
if (IS_CLANG_OR_GCC)
|
||||
set(BASE_OPTIONS
|
||||
"-Wall" # Enable all common warnings
|
||||
"-Wextra" # Enable extra warnings
|
||||
"-Werror" # Treat warnings as errors
|
||||
)
|
||||
elseif (IS_MSVC)
|
||||
set(BASE_OPTIONS
|
||||
"/W4" # Warning level 4 (high)
|
||||
"/WX" # Treat warnings as errors
|
||||
"/utf-8" # Set source and execution character set to UTF-8
|
||||
"/Zc:__cplusplus" # Report correct C++ standard version in __cplusplus
|
||||
)
|
||||
endif()
|
||||
Reference in New Issue
Block a user