CMake: Autodetect Objective-C support only on macOS

On Android, check_language() reports that the languages are supported,
but enable_language fails afterwards.

On Linux it causes issues with the PCH. The PCH file might contain
a Clang pragma, even though the C++ compiler is GCC. Presumably due
to finding a Clang Objective-C compiler.

Change-Id: I1b4c54459772c089e7f6350872c87af52ad72a37
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Alexandru Croitor 2020-04-06 15:52:48 +02:00
parent c356380154
commit 23be07c2d0

View File

@ -68,7 +68,12 @@ endmacro()
macro(qt_enable_cmake_languages)
include(CheckLanguage)
set(__qt_required_language_list C CXX)
set(__qt_optional_language_list OBJC OBJCXX)
set(__qt_optional_language_list )
# https://gitlab.kitware.com/cmake/cmake/-/issues/20545
if(APPLE)
list(APPEND __qt_optional_language_list OBJC OBJCXX)
endif()
foreach(__qt_lang ${__qt_required_language_list})
enable_language(${__qt_lang})