diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 4ddbcff3abe..8f249a15fec 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -231,6 +231,18 @@ set(QT_BUILD_INTERNALS_EXTRA_CMAKE_CODE "") # This will be /path/to/qtbase/tests when building standalone tests. set(QT_TOP_LEVEL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") +# Prevent warnings about object files without any symbols. This is a common +# thing in Qt as we tend to build files unconditionally, and then use ifdefs +# to compile out parts that are not relevant. +if(CMAKE_HOST_APPLE AND APPLE) + foreach(lang ASM C CXX) + # We have to tell 'ar' to not run ranlib by itself, by passing the 'S' option + set(CMAKE_${lang}_ARCHIVE_CREATE " qcS ") + set(CMAKE_${lang}_ARCHIVE_APPEND " qS ") + set(CMAKE_${lang}_ARCHIVE_FINISH " -no_warning_for_no_symbols ") + endforeach() +endif() + # Functions and macros: # qt_remove_args can remove arguments from an existing list of function