Skip to content

facade: libobs/CMakeLists.txt and cmake/rust.cmake: move platform conditionals into per-OS cmake files #888

Closed

Description

@zackees

Part of #847.

Platform-conditional CMake in libobs (build config, not #if; not counted in the C/C++ totals). The tree already has libobs/cmake/os-{windows,macos,linux,freebsd}.cmake; the aim is to put per-OS sources, flags and public-header lists there so shared CMake is OS-free.

file:line condition what it does proposed move
libobs/CMakeLists.txt:5 OS_WINDOWS AND NOT OBS_PARENT_ARCHITECTURE STREQUAL CMAKE_VS_PLATFORM_NAME Windows multi-arch (ARM64EC/x64) early include+return stays as bootstrap, or move into cmake/obs-version.cmake flow; document as exception
libobs/CMakeLists.txt:242 CMAKE_C_COMPILER_ID STREQUAL "MSVC" /wd4996 on obs-data.c (compiler, not OS) move to os-windows.cmake (set_source_files_properties)
libobs/CMakeLists.txt:283-291 OS_WINDOWS / OS_MACOS / OS_LINUX / OS_FREEBSD OR OS_OPENBSD includes the per-OS file already the target pattern; keep as the single dispatch
libobs/CMakeLists.txt:385-398 OS_WINDOWS / OS_MACOS appends Windows/Apple util headers to public_headers list(APPEND public_headers ...) in os-windows.cmake / os-macos.cmake
libobs/cmake/rust.cmake:9 OS_MACOS cargo target triple per macOS arch move into cmake/rust-os-macos.cmake
libobs/cmake/rust.cmake:39,48 OS_LINUX OR OS_FREEBSD OR OS_OPENBSD, OS_LINUX Rust link libs / flags on unix cmake/rust-os-nix.cmake
libobs/cmake/rust.cmake:51 OS_WINDOWS Rust link libs on Windows (bcrypt/ntdll etc.) cmake/rust-os-windows.cmake
libobs/cmake/rust.cmake:66 OS_MACOS Rust link frameworks on macOS cmake/rust-os-macos.cmake

Class: all (a) movable; none are (b) or (c). Counts: 8 rows, 11 conditions.

Test approach: configure-only checks per OS in the existing native build jobs (ci-full); on Linux compare cmake --build -t help / generated source lists before/after (diff must be empty). Rust-related rows are covered by the ENABLE_RUST_LIBOBS ON build.

Keep each move mechanical so upstream merges stay manageable. CI scoping then maps libobs/cmake/os-<os>.cmake and rust-os-<os>.cmake to platforms by path.

Activity

  1. zackees commented on Oct 23, 2026

    @zackees
    MemberAuthor

    Claiming: #888, one mechanical move per PR.

    1. Move the Windows/Apple public_headers appends (libobs/CMakeLists.txt OS_WINDOWS/OS_MACOS block) into os-windows.cmake / os-macos.cmake as OBS_PUBLIC_HEADERS property appends. Check: the installed header set is unchanged (Linux configure diff empty). First PR today.
    2. rust.cmake per-OS link/export blocks into rust-os-{nix,windows,macos}.cmake.
    3. The MSVC /wd4996 row.
  2. added
    claimed
    on Oct 23, 2026
  3. zackees commented on Oct 23, 2026

    @zackees
    MemberAuthor

    Progress on #888:

    1. Public headers: build(libobs): append host public headers from os-<os>.cmake (#888) #1955.
    2. rust.cmake per-OS blocks moved into rust-os-{nix,windows,macos}.cmake: build(libobs): move the Rust export and link setup into rust-os-<os>.cmake (#888) #1957 (stacked on build(libobs): append host public headers from os-<os>.cmake (#888) #1955).
    3. Decision: the /wd4996 row (libobs/CMakeLists.txt, the deprecation-warning block for build/libobs.ported-data+.h.c) stays in the shared file. It branches on CMAKE_C_COMPILER_ID (MSVC vs. GNU/Clang/AppleClang), not on the OS. It is one paired rule, and moving only the MSVC half to os-windows.cmake would split it with no gain in platform scoping. ci/test_libobs_cmake_facade.py only checks OS_* conditions, so nothing flags it.

    The two remaining rows (the multi-arch bootstrap and the os-file dispatch) are the intended exceptions, so this issue closes when #1957 lands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions