cmake: avoid Apple ranlib flags when not using AppleClang (#5258)

On macOS, `-no_warning_for_no_symbols -c` options are specific to the
Apple `ranlib` tool. When using other toolchains (e.g. Homebrew clang),
these flags cause errors since `llvm-ranlib` does not recognize them.

The patch ensures these flags are only passed when using AppleClang.

JerryScript-DCO-1.0-Signed-off-by: Renata Hodovan reni@inf.u-szeged.hu
This commit is contained in:
Renáta Hodován 2025-10-08 19:35:32 +02:00 committed by GitHub
parent 355ab24cdc
commit b7069350c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -209,7 +209,11 @@ endif()
if("${PLATFORM}" STREQUAL "DARWIN")
jerry_add_link_flags(-lSystem)
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Sqc <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
if("${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
else()
set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>")
endif()
set(CMAKE_SHARED_LINKER_FLAGS "-undefined dynamic_lookup")
elseif((NOT CYGWIN AND NOT MINGW AND NOT MSYS) AND (USING_GCC OR USING_CLANG))
jerry_add_link_flags(-Wl,-z,noexecstack)