Skip to content

Convert build system from premake to CMake and add GitHub Actions CI#143

Merged
gafferongames merged 4 commits into
mainfrom
cmake-and-ci
Jul 9, 2026
Merged

Convert build system from premake to CMake and add GitHub Actions CI#143
gafferongames merged 4 commits into
mainfrom
cmake-and-ci

Conversation

@gafferongames

Copy link
Copy Markdown
Contributor

Summary

  • Replaces premake with CMake (3.16+). Targets: vendored sodium static lib, netcode static library, all examples/harnesses (client, server, client_server, soak, profile), and the unit test runner (netcode_test, output name test — CTest reserves the bare target name).
  • Faithful to the premake configuration: NETCODE_DEBUG/NETCODE_RELEASE per config, fast math (-ffast-math / /fp:fast), static MSVC runtime, ws2_32/iphlpapi on Windows, sodium warning suppressions, and the .S assembly files remain excluded (the premake gmake build never compiled them either).
  • Adds GitHub Actions CI: 6-cell matrix — {ubuntu-24.04 (x64), macos-15 (Apple Silicon), windows-2025 (x64)} × {Debug, Release}. Each cell builds everything and runs the 37-test suite via CTest.
  • BUILDING.md rewritten for CMake. libsodium is vendored so there is nothing to install.
  • .gitignore: !CMakeLists.txt exception for the *.txt rule, ignore build*/.

Behavior note

premake's release config did not define NDEBUG, so netcode_assert was live in release builds. CMake Release defines NDEBUG by convention, so asserts compile out in Release. The test suite's check macro is independent of NDEBUG; Debug CI covers the asserts-on configuration.

Test plan

  • Local macOS (Apple Silicon): Debug + Release build with zero warnings from netcode sources, all 37 tests pass via ctest
  • CI green on all 6 matrix cells

🤖 Generated with Claude Code

gafferongames and others added 4 commits July 9, 2026 00:01
- CMakeLists.txt replaces premake5.lua: sodium static lib, netcode static
  library, all examples/harnesses, and the unit test runner (test.cpp with
  NETCODE_ENABLE_TESTS, output name "test" since CTest reserves the target
  name). Matches the premake config: NETCODE_DEBUG/NETCODE_RELEASE defines,
  fast math, static MSVC runtime, ws2_32/iphlpapi on Windows, .S files
  excluded as before.
- CI builds and runs unit tests for Debug and Release on Linux x64
  (ubuntu-24.04), macOS Apple Silicon (macos-15) and Windows x64
  (windows-2025).
- BUILDING.md rewritten for CMake; vendored sodium means nothing to install.
- .gitignore: exempt CMakeLists.txt from the *.txt rule, ignore build dirs.

Note: CMake Release defines NDEBUG (premake did not), so netcode_assert now
compiles out in Release builds. Debug CI covers the asserts-on configuration.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
sodium/ is now an amalgamated sodium.h + sodium.c pair instead of 182
per-file sources. See sodium/NOTES.md for how the amalgamation is generated
and validated. CMake updated accordingly.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
client_server_socket_connect_to advances virtual time in a busy loop while
pumping real sockets, so virtual timeouts (connect token expiry, connection
request timeout) could expire before the OS delivered a single loopback
packet. Failed on the macOS Release CI runner. Sleep 10ms per iteration so
real packet delivery keeps pace with virtual time.

Also in this commit (small API hardening):

- netcode_parse_address: ports are now validated (all digits, <= 65535)
  instead of silently truncating through atoi + uint16_t cast. New tests.
- netcode_client_send_packet / netcode_server_send_packet reject zero-byte
  payloads with an error log. The receiver already dropped them on the wire,
  so previously they silently vanished.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…s continue

- State up front that the library is single-threaded by design and not
  thread safe (global state, no internal synchronization).
- The netcode_assert macro no longer calls exit(1) after invoking the assert
  handler. The default handler still breaks into the debugger and exits, so
  default behavior is unchanged, but a custom handler may now return and
  continue execution.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@gafferongames gafferongames merged commit e0e47f5 into main Jul 9, 2026
6 checks passed
@gafferongames gafferongames deleted the cmake-and-ci branch July 9, 2026 04:20
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