CMake: Don't use check_language for Objective-C/C++
The check_language macro spawns a new cmake subprocess to detect availability of a language. We use that to detect availability of the Objective-C/C++ languages when targeting Apple platforms. That's problematic because the parent process CFLAGS / LDFLAGS env vars influences the result of the subprocess compiler detection, and in some cases that can fail the detection. An example of that is passing iOS specific flags which then get mixed with the default macOS flags added by CMake, resulting in a linker failure. Instead of using check_language, explicitly enable the Objective-C and C++ languages when targeting Apple platforms because we know that we need them for compiling Qt. This avoids the issue because enable_language is not spawning a separate cmake sub-process and thus passes more information to the underlying try_compile project to ensure a successful check. The change also means that CMake will error out earlier in case if the Objective-C compiler is not found, which was not the case before. Pick-to: 6.5 6.6 Fixes: QTBUG-114470 Change-Id: I1a16c1e5828dfe10b2d7da27cc9a8c787517ab8e Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
b249a8ab3a
commit
961ff0cc8a
@ -328,24 +328,19 @@ function(qt_build_internals_add_toplevel_targets)
|
||||
endfunction()
|
||||
|
||||
macro(qt_enable_cmake_languages)
|
||||
include(CheckLanguage)
|
||||
set(__qt_required_language_list C CXX)
|
||||
set(__qt_optional_language_list )
|
||||
set(__qt_platform_required_language_list )
|
||||
|
||||
# https://gitlab.kitware.com/cmake/cmake/-/issues/20545
|
||||
if(APPLE)
|
||||
list(APPEND __qt_optional_language_list OBJC OBJCXX)
|
||||
list(APPEND __qt_platform_required_language_list OBJC OBJCXX)
|
||||
endif()
|
||||
|
||||
foreach(__qt_lang ${__qt_required_language_list})
|
||||
enable_language(${__qt_lang})
|
||||
endforeach()
|
||||
|
||||
foreach(__qt_lang ${__qt_optional_language_list})
|
||||
check_language(${__qt_lang})
|
||||
if(CMAKE_${__qt_lang}_COMPILER)
|
||||
enable_language(${__qt_lang})
|
||||
endif()
|
||||
foreach(__qt_lang ${__qt_platform_required_language_list})
|
||||
enable_language(${__qt_lang})
|
||||
endforeach()
|
||||
|
||||
# The qtbase call is handled in qtbase/CMakeLists.txt.
|
||||
|
Loading…
Reference in New Issue
Block a user