Skip to content

build: optional MIR2X_CLIENT_ONLY and Apple Clang flags#59

Open
iamcheyan wants to merge 1 commit into
etorth:mainfrom
iamcheyan:feat/macos-build
Open

build: optional MIR2X_CLIENT_ONLY and Apple Clang flags#59
iamcheyan wants to merge 1 commit into
etorth:mainfrom
iamcheyan:feat/macos-build

Conversation

@iamcheyan

Copy link
Copy Markdown
Contributor

Lets the project be configured and built on macOS without manual
CMake hacking. Linux GCC builds are unchanged.

Source-level companion PRs (independent, but you'll want them
merged together for the macOS build to actually compile end-to-
end): #57 (sol2 v3 rename), #58 (explicit headers / strict
conformance).

Top-level CMakeLists.txt

  • New MIR2X_CLIENT_ONLY option (default OFF — preserves
    current behaviour). When ON, server/ and tools/ are skipped.
    This is useful on macOS, where the server still needs brew LLVM
    to build (Apple Clang 17 hits an internal compiler crash on
    server/src/player.cpp's nested-lambda pattern in
    clang::Expr::EvaluateAsInitializer — reproducible; happy to
    file upstream at LLVM if useful) and the tools need extra
    FLTK 1.4 / Cairo wiring beyond the scope of this PR.
  • For Apple Clang only: don't pass -fcoroutines (GCC-only flag;
    Clang has C++20 coroutines on by default) and don't promote
    warnings to errors with -Werror (Clang's stricter warnings
    trip on otherwise-fine code; once everything's clean we can
    switch it back on).

client/src/CMakeLists.txt

  • On APPLE, append -L/opt/homebrew/lib so the linker finds
    SDL2_ttf / SDL2_gfx / SDL2_image / SDL2_mixer installed
    via Homebrew on Apple Silicon.

common/src/CMakeLists.txt

  • Link stdc++fs only for GCC. libc++ (Apple Clang, brew LLVM)
    has std::filesystem in the main runtime; linking stdc++fs
    there fails or is a no-op.
  • Explicitly add SDL2 / FLTK header dirs to the common target's
    include paths so subtargets that pull in common headers don't
    need to re-resolve them.

Tested

Lets the project configure and build on macOS without manual CMake
hacking. Linux GCC builds are unchanged.

CMakeLists.txt (top level):
  - New MIR2X_CLIENT_ONLY option. When ON, server/ and tools/ are
    skipped -- handy on macOS, where the server still needs brew
    LLVM (Apple Clang 17 hits an internal compiler bug on
    server/src/player.cpp's nested-lambda pattern) and the tools
    need additional FLTK 1.4 / Cairo wiring.
  - Apple Clang: don't pass -fcoroutines (a GCC-only flag; Clang
    has coroutines on by default at C++20) and don't promote
    warnings to errors with -Werror (avoids Clang's stricter
    warnings tripping the build on otherwise-fine code).

client/src/CMakeLists.txt:
  - On APPLE, append -L/opt/homebrew/lib so the linker finds
    SDL2_ttf / SDL2_gfx / SDL2_image / SDL2_mixer installed via
    Homebrew on Apple Silicon.

common/src/CMakeLists.txt:
  - Link stdc++fs only for GCC. libc++ (Apple Clang, brew LLVM)
    has std::filesystem in the main runtime; linking stdc++fs
    fails or is unnecessary.
  - Explicitly include SDL2 / FLTK header dirs for the common
    target so subtargets that pull in common headers don't need
    to re-resolve them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant