@@ -369,21 +369,24 @@ if(${STRINGZILLA_BUILD_SHARED})
369369 target_compile_definitions (stringzilla_shared PRIVATE "SZ_OVERRIDE_LIBC=1" )
370370 target_include_directories (stringzilla_shared PUBLIC include )
371371
372-
373- # Try compiling a version without linking the LibC
374- define_shared (stringzilla_bare )
375- target_compile_definitions (stringzilla_bare PRIVATE "SZ_AVOID_LIBC=1" )
376- target_compile_definitions (stringzilla_bare PRIVATE "SZ_OVERRIDE_LIBC=1" )
377- target_include_directories (stringzilla_bare PUBLIC include )
378-
379- # Avoid built-ins on MSVC and other compilers, as that will cause compilation errors
380- target_compile_options (stringzilla_bare PRIVATE
381- "$<$<CXX_COMPILER_ID :GNU ,Clang >:-fno -builtin ;-nostdlib >"
382- "$<$<CXX_COMPILER_ID :MSVC >:/Oi -;/GS ->" )
383- target_link_options (stringzilla_bare PRIVATE "$<$<CXX_COMPILER_ID :GNU ,Clang >:-nostdlib >" )
384- target_link_options (stringzilla_bare PRIVATE "$<$<CXX_COMPILER_ID :MSVC >:/NODEFAULTLIB >" )
385-
386372
373+ # Try compiling a version without linking the LibC
374+ # ! This is only for Linux and Windows, as on modern Arm-based MacOS machines
375+ # ! we can't legally access Arm's "feature registers" without `sysctl` or `sysctlbyname`.
376+ # So let's check if we are compiling for a Darwin-based OS.
377+ if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
378+ define_shared (stringzilla_bare )
379+ target_compile_definitions (stringzilla_bare PRIVATE "SZ_AVOID_LIBC=1" )
380+ target_compile_definitions (stringzilla_bare PRIVATE "SZ_OVERRIDE_LIBC=1" )
381+ target_include_directories (stringzilla_bare PUBLIC include )
382+
383+ # Avoid built-ins on MSVC and other compilers, as that will cause compilation errors
384+ target_compile_options (stringzilla_bare PRIVATE
385+ "$<$<CXX_COMPILER_ID :GNU ,Clang >:-fno -builtin ;-nostdlib >"
386+ "$<$<CXX_COMPILER_ID :MSVC >:/Oi -;/GS ->" )
387+ target_link_options (stringzilla_bare PRIVATE "$<$<CXX_COMPILER_ID :GNU ,Clang >:-nostdlib >" )
388+ target_link_options (stringzilla_bare PRIVATE "$<$<CXX_COMPILER_ID :MSVC >:/NODEFAULTLIB >" )
389+ endif ()
387390endif ()
388391
389392if (STRINGZILLA_INSTALL)
0 commit comments