Skip to content

Comments

add macOS build support for unit tests#225

Open
m-mcgowan wants to merge 1 commit intoblues:masterfrom
m-mcgowan:build/macos-test-support
Open

add macOS build support for unit tests#225
m-mcgowan wants to merge 1 commit intoblues:masterfrom
m-mcgowan:build/macos-test-support

Conversation

@m-mcgowan
Copy link
Contributor

Summary

  • Enable building and running note-c unit tests on macOS (Apple Silicon and x86_64)
  • All changes are guarded with if(APPLE) / if(NOT APPLE) to preserve existing Linux CI behavior

Changes

CMakeLists.txt:

  • Skip -m32, -mfpmath=sse, -msse2 on macOS (not available on Apple toolchain)
  • Skip Linux-specific lib paths and -Wl,-melf_i386 linker flag on macOS
  • Define HAVE_STRLCPY and HAVE_STRLCAT on macOS (system provides these as macros, avoiding conflict with note-c bundled implementations)
  • Exclude n_str.c on macOS (bundled strlcpy/strlcat not needed)
  • Suppress AppleClang warnings for third-party C code: -Wno-deprecated-non-prototype, -Wno-unused-but-set-variable, -Wno-strict-prototypes
  • Add -Wl,-flat_namespace on macOS for FFF symbol interposition

test/CMakeLists.txt:

  • Skip -m32 for Catch2 on macOS
  • Add -Wl,-flat_namespace to test executables on macOS (required for FFF fakes to interpose dylib symbols)

Test plan

  • All existing unit tests build and pass on macOS
  • Linux CI unaffected (all changes APPLE-guarded)

Add conditional CMake configuration for macOS (APPLE):
- Skip -m32 and Linux-specific linker flags
- Define HAVE_STRLCPY/HAVE_STRLCAT (macOS provides these natively)
- Exclude n_str.c (strlcpy/strlcat bundled implementations)
- Suppress AppleClang-specific warnings in upstream code
- Use -flat_namespace for dylib and test executables to enable
  FFF test fake symbol interposition

All changes are guarded by if(APPLE)/if(NOT APPLE) so Linux CI
behavior is completely unchanged.
@m-mcgowan m-mcgowan force-pushed the build/macos-test-support branch from cd3c7a1 to 49afe4c Compare February 24, 2026 21:15
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