Skip to content

Commit edc6263

Browse files
committed
Build: Suppress Apple's ranlib "has no symbols" warnings on macOS.
1 parent 31f9e17 commit edc6263

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

cmake/platform/unix/settings.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ if(APPLE)
4343
message(STATUS "Homebrew installation found at ${HOMEBREW_PREFIX}")
4444
set(CMAKE_PREFIX_PATH "${HOMEBREW_PREFIX}")
4545
endif()
46+
47+
# Apple's ranlib supports -no_warning_for_no_symbols; llvm-ranlib does not.
48+
# Check that we are using the system Apple ranlib before applying the flag.
49+
if(CMAKE_RANLIB MATCHES ".*/usr/bin/ranlib$")
50+
# Suppress "has no symbols" warnings for static libraries.
51+
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> -Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
52+
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> -Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
53+
set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
54+
set(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
55+
endif()
4656
endif()
4757

4858
message(STATUS "UNIX: Detected compiler: ${CMAKE_C_COMPILER}")

0 commit comments

Comments
 (0)