summaryrefslogtreecommitdiffstats
path: root/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2023-06-27 15:25:50 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2023-06-29 16:28:53 +0200
commit961ff0cc8a7408f59b2d0f9adfa980fd89bd3274 (patch)
tree238ca526670a4c57490a5bb709e8e7caaecbdcc2 /cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
parentb249a8ab3ab68ee4e823f5cf32d9d742bebe1cd1 (diff)
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>
Diffstat (limited to 'cmake/QtBuildInternals/QtBuildInternalsConfig.cmake')
-rw-r--r--cmake/QtBuildInternals/QtBuildInternalsConfig.cmake13
1 files changed, 4 insertions, 9 deletions
diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
index e07c77c85a..4ee68e92c8 100644
--- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
+++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
@@ -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.