|
| 1 | +# CMakeLists.txt |
| 2 | +# AES67 macOS Driver - Build #4 |
| 3 | +# Cross-platform build configuration |
| 4 | + |
| 5 | +cmake_minimum_required(VERSION 3.20) |
| 6 | + |
| 7 | +# Read version from VERSION.txt |
| 8 | +file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION.txt" VERSION_STRING) |
| 9 | +string(STRIP "${VERSION_STRING}" VERSION_STRING) |
| 10 | +string(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)-build\\.([0-9]+)" _ "${VERSION_STRING}") |
| 11 | +set(VERSION_MAJOR ${CMAKE_MATCH_1}) |
| 12 | +set(VERSION_MINOR ${CMAKE_MATCH_2}) |
| 13 | +set(VERSION_PATCH ${CMAKE_MATCH_3}) |
| 14 | +set(VERSION_BUILD ${CMAKE_MATCH_4}) |
| 15 | + |
| 16 | +project(AES67Driver |
| 17 | + VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} |
| 18 | + LANGUAGES CXX OBJCXX |
| 19 | + DESCRIPTION "AES67/RAVENNA/Dante Audio Driver for macOS" |
| 20 | +) |
| 21 | + |
| 22 | +message(STATUS "AES67 Driver Build #${VERSION_BUILD}") |
| 23 | + |
| 24 | +# C++ Standard |
| 25 | +set(CMAKE_CXX_STANDARD 17) |
| 26 | +set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 27 | +set(CMAKE_CXX_EXTENSIONS OFF) |
| 28 | + |
| 29 | +# Build type |
| 30 | +if(NOT CMAKE_BUILD_TYPE) |
| 31 | + set(CMAKE_BUILD_TYPE Release) |
| 32 | +endif() |
| 33 | + |
| 34 | +# macOS specific settings |
| 35 | +if(APPLE) |
| 36 | + set(CMAKE_OSX_DEPLOYMENT_TARGET "12.0" CACHE STRING "Minimum macOS version") |
| 37 | + set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "Build architectures") |
| 38 | + |
| 39 | + # Enable Hardened Runtime for notarization |
| 40 | + set(CMAKE_XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME YES) |
| 41 | + |
| 42 | + # Code signing (set to "-" for ad-hoc signing during development) |
| 43 | + set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "-" CACHE STRING "Code signing identity") |
| 44 | + set(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "" CACHE STRING "Development team ID") |
| 45 | +endif() |
| 46 | + |
| 47 | +# Compiler flags |
| 48 | +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang") |
| 49 | + add_compile_options( |
| 50 | + -Wall -Wextra -Wpedantic |
| 51 | + -Wno-unused-parameter |
| 52 | + -Wno-missing-field-initializers |
| 53 | + ) |
| 54 | + # Debug flags |
| 55 | + set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") |
| 56 | + # Release flags |
| 57 | + set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") |
| 58 | +endif() |
| 59 | + |
| 60 | +# ============================================================================ |
| 61 | +# Dependencies |
| 62 | +# ============================================================================ |
| 63 | + |
| 64 | +# Find oRTP |
| 65 | +find_package(PkgConfig REQUIRED) |
| 66 | +pkg_check_modules(ORTP REQUIRED ortp) |
| 67 | + |
| 68 | +# Find libASPL (header-only library) |
| 69 | +find_path(ASPL_INCLUDE_DIR aspl/Plugin.hpp |
| 70 | + PATHS |
| 71 | + /usr/local/include |
| 72 | + /opt/homebrew/include |
| 73 | + ${CMAKE_SOURCE_DIR}/external/libASPL/include |
| 74 | +) |
| 75 | + |
| 76 | +# Also find libASPL static library |
| 77 | +find_library(ASPL_LIBRARY ASPL |
| 78 | + PATHS |
| 79 | + /usr/local/lib |
| 80 | + /opt/homebrew/lib |
| 81 | +) |
| 82 | + |
| 83 | +if(NOT ASPL_INCLUDE_DIR) |
| 84 | + message(FATAL_ERROR "libASPL not found. Please install from https://github.com/gavv/libASPL") |
| 85 | +endif() |
| 86 | + |
| 87 | +message(STATUS "Found libASPL: ${ASPL_INCLUDE_DIR}") |
| 88 | + |
| 89 | +# ptpd (we'll link against it when building on macOS) |
| 90 | +find_library(PTPD_LIBRARY ptpd |
| 91 | + PATHS |
| 92 | + /usr/local/lib |
| 93 | + /opt/homebrew/lib |
| 94 | +) |
| 95 | + |
| 96 | +# ============================================================================ |
| 97 | +# Shared Library |
| 98 | +# ============================================================================ |
| 99 | + |
| 100 | +# Common source files for both driver and tests |
| 101 | +set(SHARED_SOURCES |
| 102 | + Shared/Types.cpp |
| 103 | + Shared/Config.cpp |
| 104 | +) |
| 105 | + |
| 106 | +# Driver source files |
| 107 | +set(DRIVER_SOURCES |
| 108 | + Driver/SDPParser.cpp |
| 109 | + Driver/AES67Device.cpp |
| 110 | + Driver/AES67IOHandler.cpp |
| 111 | +) |
| 112 | + |
| 113 | +# Network Engine source files |
| 114 | +set(NETWORK_SOURCES |
| 115 | + NetworkEngine/StreamChannelMapper.cpp |
| 116 | + NetworkEngine/StreamManager.cpp |
| 117 | + NetworkEngine/RTP/RTPReceiver.cpp |
| 118 | + NetworkEngine/RTP/RTPTransmitter.cpp |
| 119 | + NetworkEngine/PTP/PTPClock.cpp |
| 120 | + NetworkEngine/DoPDecoder.cpp |
| 121 | + # TODO: Add when implemented |
| 122 | + # NetworkEngine/Discovery/SAPListener.cpp |
| 123 | + # NetworkEngine/Discovery/RTSPClient.cpp |
| 124 | +) |
| 125 | + |
| 126 | +# Combine all C++ sources |
| 127 | +set(ALL_CPP_SOURCES |
| 128 | + ${SHARED_SOURCES} |
| 129 | + ${DRIVER_SOURCES} |
| 130 | + ${NETWORK_SOURCES} |
| 131 | +) |
| 132 | + |
| 133 | +# ============================================================================ |
| 134 | +# AudioServerPlugIn Bundle (macOS only) |
| 135 | +# ============================================================================ |
| 136 | + |
| 137 | +if(APPLE) |
| 138 | + # Create driver bundle |
| 139 | + add_library(AES67Driver MODULE |
| 140 | + ${ALL_CPP_SOURCES} |
| 141 | + Driver/PlugInMain.cpp # AudioServerPlugIn entry point |
| 142 | + ) |
| 143 | + |
| 144 | + target_include_directories(AES67Driver PRIVATE |
| 145 | + ${CMAKE_CURRENT_SOURCE_DIR} |
| 146 | + ${ASPL_INCLUDE_DIR} |
| 147 | + ${ORTP_INCLUDE_DIRS} |
| 148 | + /opt/homebrew/Cellar/ortp/5.4.50/libexec/include |
| 149 | + ) |
| 150 | + |
| 151 | + target_link_libraries(AES67Driver PRIVATE |
| 152 | + ${ASPL_LIBRARY} |
| 153 | + "-F/opt/homebrew/Cellar/ortp/5.4.50/Frameworks" |
| 154 | + "-framework ortp" |
| 155 | + "-framework CoreAudio" |
| 156 | + "-framework CoreFoundation" |
| 157 | + "-framework AudioToolbox" |
| 158 | + ) |
| 159 | + |
| 160 | + if(PTPD_LIBRARY) |
| 161 | + target_link_libraries(AES67Driver PRIVATE ${PTPD_LIBRARY}) |
| 162 | + endif() |
| 163 | + |
| 164 | + # Bundle properties |
| 165 | + set_target_properties(AES67Driver PROPERTIES |
| 166 | + BUNDLE TRUE |
| 167 | + BUNDLE_EXTENSION "driver" |
| 168 | + MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Driver/Info.plist.in" |
| 169 | + MACOSX_BUNDLE_BUNDLE_NAME "AES67" |
| 170 | + MACOSX_BUNDLE_BUNDLE_VERSION "${VERSION_BUILD}" |
| 171 | + MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}" |
| 172 | + MACOSX_BUNDLE_GUI_IDENTIFIER "com.aes67driver.audiodevice" |
| 173 | + XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "com.aes67driver.audiodevice" |
| 174 | + XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "13.0" |
| 175 | + OSX_DEPLOYMENT_TARGET "13.0" |
| 176 | + ) |
| 177 | + |
| 178 | + # Install to standard location |
| 179 | + install(TARGETS AES67Driver |
| 180 | + LIBRARY DESTINATION "/Library/Audio/Plug-Ins/HAL" |
| 181 | + BUNDLE DESTINATION "/Library/Audio/Plug-Ins/HAL" |
| 182 | + ) |
| 183 | +endif() |
| 184 | + |
| 185 | +# ============================================================================ |
| 186 | +# Manager App (SwiftUI - macOS only) |
| 187 | +# ============================================================================ |
| 188 | + |
| 189 | +if(APPLE) |
| 190 | + # Note: SwiftUI app will be built separately via Xcode |
| 191 | + # This CMake file focuses on the C++ driver component |
| 192 | + # See ManagerApp/AES67Manager.xcodeproj for Swift app |
| 193 | +endif() |
| 194 | + |
| 195 | +# ============================================================================ |
| 196 | +# Tests |
| 197 | +# ============================================================================ |
| 198 | + |
| 199 | +option(BUILD_TESTS "Build unit tests" ON) |
| 200 | + |
| 201 | +if(BUILD_TESTS) |
| 202 | + enable_testing() |
| 203 | + add_subdirectory(Tests) |
| 204 | +endif() |
| 205 | + |
| 206 | +# ============================================================================ |
| 207 | +# Examples |
| 208 | +# ============================================================================ |
| 209 | + |
| 210 | +option(BUILD_EXAMPLES "Build example programs" ON) |
| 211 | + |
| 212 | +if(BUILD_EXAMPLES) |
| 213 | + add_subdirectory(Examples) |
| 214 | +endif() |
| 215 | + |
| 216 | +# ============================================================================ |
| 217 | +# Documentation |
| 218 | +# ============================================================================ |
| 219 | + |
| 220 | +option(BUILD_DOCS "Build documentation" OFF) |
| 221 | + |
| 222 | +if(BUILD_DOCS) |
| 223 | + find_package(Doxygen) |
| 224 | + if(DOXYGEN_FOUND) |
| 225 | + set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/Docs/Doxyfile.in) |
| 226 | + set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) |
| 227 | + configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY) |
| 228 | + |
| 229 | + add_custom_target(docs ALL |
| 230 | + COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} |
| 231 | + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
| 232 | + COMMENT "Generating API documentation with Doxygen" |
| 233 | + VERBATIM |
| 234 | + ) |
| 235 | + endif() |
| 236 | +endif() |
| 237 | + |
| 238 | +# ============================================================================ |
| 239 | +# Installation |
| 240 | +# ============================================================================ |
| 241 | + |
| 242 | +# Install README and documentation |
| 243 | +install(FILES |
| 244 | + README.md |
| 245 | + VERSION.txt |
| 246 | + DESTINATION share/doc/AES67Driver |
| 247 | +) |
| 248 | + |
| 249 | +# Install example SDP files |
| 250 | +install(DIRECTORY Docs/Examples/ |
| 251 | + DESTINATION share/doc/AES67Driver/examples |
| 252 | + FILES_MATCHING PATTERN "*.sdp" |
| 253 | +) |
| 254 | + |
| 255 | +# ============================================================================ |
| 256 | +# Package |
| 257 | +# ============================================================================ |
| 258 | + |
| 259 | +set(CPACK_PACKAGE_NAME "AES67Driver") |
| 260 | +set(CPACK_PACKAGE_VENDOR "AES67 Driver") |
| 261 | +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "AES67 Audio Driver for macOS") |
| 262 | +set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}.${VERSION_BUILD}") |
| 263 | +set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR}) |
| 264 | +set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR}) |
| 265 | +set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH}) |
| 266 | + |
| 267 | +if(APPLE) |
| 268 | + set(CPACK_GENERATOR "productbuild") |
| 269 | + set(CPACK_PACKAGING_INSTALL_PREFIX "/") |
| 270 | +endif() |
| 271 | + |
| 272 | +include(CPack) |
| 273 | + |
| 274 | +# ============================================================================ |
| 275 | +# Summary |
| 276 | +# ============================================================================ |
| 277 | + |
| 278 | +message(STATUS "") |
| 279 | +message(STATUS "AES67 Driver Configuration:") |
| 280 | +message(STATUS " Version: ${PROJECT_VERSION} (Build #${VERSION_BUILD})") |
| 281 | +message(STATUS " Build type: ${CMAKE_BUILD_TYPE}") |
| 282 | +message(STATUS " C++ compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}") |
| 283 | +if(APPLE) |
| 284 | + message(STATUS " macOS deployment target: ${CMAKE_OSX_DEPLOYMENT_TARGET}") |
| 285 | + message(STATUS " Architectures: ${CMAKE_OSX_ARCHITECTURES}") |
| 286 | +endif() |
| 287 | +message(STATUS " oRTP: ${ORTP_VERSION}") |
| 288 | +message(STATUS " libASPL: ${ASPL_INCLUDE_DIR}") |
| 289 | +if(PTPD_LIBRARY) |
| 290 | + message(STATUS " ptpd: ${PTPD_LIBRARY}") |
| 291 | +else() |
| 292 | + message(WARNING " ptpd: NOT FOUND (PTP support will be limited)") |
| 293 | +endif() |
| 294 | +message(STATUS " Tests: ${BUILD_TESTS}") |
| 295 | +message(STATUS " Examples: ${BUILD_EXAMPLES}") |
| 296 | +message(STATUS "") |
0 commit comments