# cmake/platform.cmake — central OS detection and per-OS source selection. # # Owned by PKG/QA (docs/adr/0020-cross-platform-strategy.md §4-5, amended: PORT owns # **/platform//** and the macOS/Windows packaging trees, but this file is root build # infrastructure and lands in Phase 0 — CORE's and DAEMON's own seams need # velox_platform_sources() to select their platform/linux/*.cpp before PORT ever starts). # # Sets exactly one of VELOX_OS_LINUX / VELOX_OS_MACOS / VELOX_OS_WINDOWS. Selection lives # here and nowhere else — no lane's own CMakeLists.txt should reimplement this check. if(CMAKE_SYSTEM_NAME STREQUAL "Linux") set(VELOX_OS_LINUX TRUE) elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") set(VELOX_OS_MACOS TRUE) elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") set(VELOX_OS_WINDOWS TRUE) else() message(FATAL_ERROR "velox: unsupported CMAKE_SYSTEM_NAME '${CMAKE_SYSTEM_NAME}' — " "expected Linux, Darwin or Windows.") endif() # velox_platform_sources( ) adds /platform//*.cpp to , where # is linux, macos or windows to match this file's VELOX_OS_* selection. is # relative to the calling lane's own CMakeLists.txt (e.g. src/io, src/rpc) — the seam # headers themselves (/platform/*.hpp) are not globbed here, they're ordinary sources # the owning lane already lists. function(velox_platform_sources target dir) if(VELOX_OS_LINUX) set(os_dir "linux") elseif(VELOX_OS_MACOS) set(os_dir "macos") elseif(VELOX_OS_WINDOWS) set(os_dir "windows") endif() file(GLOB platform_sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${dir}/platform/${os_dir}/*.cpp") if(NOT platform_sources) message(WARNING "velox: velox_platform_sources(${target} ${dir}) found no " "sources under ${dir}/platform/${os_dir}/ — is the seam missing " "its ${os_dir} backend?") endif() target_sources(${target} PRIVATE ${platform_sources}) endfunction()