Skip to content

CI: Add macOS CI build.#3409

Merged
ratkosrb merged 2 commits into
vmangos:developmentfrom
mserajnik:add-macos-ci-build
May 15, 2026
Merged

CI: Add macOS CI build.#3409
ratkosrb merged 2 commits into
vmangos:developmentfrom
mserajnik:add-macos-ci-build

Conversation

@mserajnik
Copy link
Copy Markdown
Contributor

@mserajnik mserajnik commented May 14, 2026

🍰 Pullrequest

This adds a macOS CI build (as requested by @ratkosrb), running on macos-26 (Apple Silicon only; Intel Macs will be abandoned with macOS 27 this year anyway) for client version 1.12.1.5875, matching the existing Ubuntu Clang and Windows builds.

Split into two commits:

  • Fix macOS build.: code and CMake changes needed to compile on macOS with -Werror:
    • cmake/find/FindMySQL.cmake: use the PATHS keyword properly in find_program (the old syntax was silently treating paths as additional names; it only worked on Linux because /usr/bin is in the default search) and add Homebrew search paths (for both Apple Silicon and Intel, so Intel Mac users should still be able to compile on older macOS systems), mirroring what FindOpenSSL.cmake already does.
    • cmake/platform/unix/settings.cmake: STREQUAL "Clang" was changed to MATCHES "Clang" so Apple's AppleClang compiler ID doesn't end up using the GCC branch and pick up GCC-only flags like -Wno-nonnull-compare.
    • dep/include/nlohmann/json.hpp: Made two whitespace-only changes because the PR runner image funnily got updated from Xcode 26.2 / AppleClang 17 to Xcode 26.4.1 / AppleClang 21 within the ~30 minutes between my fork run and the PR run, and AppleClang 21 enables -Wdeprecated-literal-operator by default.
    • All sprintf / strcpy / strcat call sites across src/ and contrib/ have been rewritten to snprintf / memcpy. Apple's SDK marks these with __deprecated_msg, so -Werror,-Wdeprecated-declarations fails the build otherwise. The replacements should be safe, but worth reviewing closely (I threw Claude Opus 4.7 Max at these replacements).
  • CI: Add macOS CI build.: adds the actual CI build.

The alternative to the sprintf/strcpy/strcat rewrites would be suppressing the deprecation on Apple Clang only by adding -Wno-deprecated-declarations in cmake/platform/unix/settings.cmake gated on CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" and drop the relevant changes from the first commit. Happy to do that instead if preferred.
Edit: and the same thing for -Wdeprecated-literal-operator since the PR runner image got updated.

Tested end-to-end in my fork: https://github.com/mserajnik/vmangos-core/actions/runs/25850039327

Proof

  • None

Issues

  • None

How2Test

  • None

Todo / Checklist

  • None

@mserajnik
Copy link
Copy Markdown
Contributor Author

mserajnik commented May 14, 2026

Looking into why the PR run failed when it worked in my fork. 👀

Edit: Found it, the runner image got updated between my fork run and the PR run:

  • Fork run: Xcode 26.2 / AppleClang 17
  • PR run: Xcode 26.4.1 / AppleClang 21

AppleClang 21 added -Wdeprecated-literal-operator, so need some more changes.

@mserajnik mserajnik force-pushed the add-macos-ci-build branch from 67993e0 to a6d01e7 Compare May 14, 2026 08:59

std::strcat(path, " -s run");
size_t pathLen = strlen(path);
snprintf(path + pathLen, sizeof(path) - pathLen, " -s run");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the name of this file I would expect that it shouldn't get compiled at all on MacOS.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, want me to drop it or keep it for consistency?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, want me to drop it or keep it for consistency?

std::strcat() would still warn (and thus error with -Werror) if it were outside of a Windows-only context, so imo it would make sense to keep everything consistent and not have different ways of doing basic things that will work on some platforms/compilers but not on others (even if in this particular case it doesn't matter since it's gated in #ifdef).

@ratkosrb ratkosrb merged commit 4fec743 into vmangos:development May 15, 2026
13 checks passed
@ratkosrb
Copy link
Copy Markdown
Contributor

Should we also have a release published for MacOS or would those binaries not be portable? Also since we are building on clang with MacOS, perhaps the Linux clang CI action is redundant?

@mserajnik
Copy link
Copy Markdown
Contributor Author

Should we also have a release published for MacOS or would those binaries not be portable?

Should be possible in a similar manner to the Linux release I believe. I will look into it next week or so.

Also since we are building on clang with MacOS, perhaps the Linux clang CI action is redundant?

I would leave that as it is still useful to have a CI build with regular Clang on Linux. Apple Clang is built with different options and defaults and as such is not a great general indicator of "can VMaNGOS be compiled with Clang?".

@mserajnik mserajnik deleted the add-macos-ci-build branch May 15, 2026 11:17
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.

2 participants