summaryrefslogtreecommitdiffstats
path: root/cmake/QtExecutableHelpers.cmake
diff options
context:
space:
mode:
authorAlexey Edelev <alexey.edelev@qt.io>2023-06-28 15:36:02 +0200
committerAlexey Edelev <alexey.edelev@qt.io>2023-06-29 18:49:45 +0200
commit49ce711796c2f10dfe658cc77b81db1f2d1b25f7 (patch)
tree9f9875726db88dcae9fcc5f8498bb1448cb14db3 /cmake/QtExecutableHelpers.cmake
parented1fbc7a88008ddf118556a97f1ee34989151c75 (diff)
Fix syncqt compiler and linker flags handling
We want syncqt to be built optimized by default. The current approach set the default build type for the external projects and optimized flags for the non-configure-time syncqt build. The problem is that syncqt still have compiler flags littered by either the Qt configuration type or the system defaults that are applicable for RelWithDebugInfo configuration(the default one we chose for syncqt). This patch makes sure that we cleanup all compiler flags from any optimizations and apply optimized flags for all configurations. Also we discard '/RTC1' flag if it's set. Configure time executables now respect the language related flags that are set in the project and adjust the flags passed to try_compile. For linker flags we should use those that are applicable for the preferred build type. Since syncqt is built in RelWithDebugInfo by default we should replace linker flags in all configs with those are used for RelWithDebugInfo configuration. Fixes: QTBUG-114925 Pick-to: 6.5 6.6 Change-Id: I782f81a36f5ef7ee4d342ce8ac6c217cb2552f3b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake/QtExecutableHelpers.cmake')
-rw-r--r--cmake/QtExecutableHelpers.cmake24
1 files changed, 24 insertions, 0 deletions
diff --git a/cmake/QtExecutableHelpers.cmake b/cmake/QtExecutableHelpers.cmake
index dc73f57844..37670c1457 100644
--- a/cmake/QtExecutableHelpers.cmake
+++ b/cmake/QtExecutableHelpers.cmake
@@ -370,6 +370,7 @@ function(qt_internal_add_configure_time_executable target)
set(target_binary_dir "${CMAKE_CURRENT_BINARY_DIR}/configure_time_bins")
if(arg_CONFIG)
set(CMAKE_TRY_COMPILE_CONFIGURATION "${arg_CONFIG}")
+ string(TOUPPER "_${arg_CONFIG}" config_suffix)
endif()
get_cmake_property(is_multi_config GENERATOR_IS_MULTI_CONFIG)
@@ -463,6 +464,29 @@ function(qt_internal_add_configure_time_executable target)
set(cmake_flags_arg CMAKE_FLAGS "${arg_CMAKE_FLAGS}")
endif()
configure_file("${template}" "${target_binary_dir}/CMakeLists.txt" @ONLY)
+
+ qt_internal_get_enabled_languages_for_flag_manipulation(enabled_languages)
+ foreach(lang IN LISTS enabled_languages)
+ set(compiler_flags_var "CMAKE_${lang}_FLAGS")
+ list(APPEND cmake_flags_arg "-D${compiler_flags_var}:STRING=${${compiler_flags_var}}")
+ if(arg_CONFIG)
+ set(compiler_flags_var_config "${compiler_flags_var}${config_suffix}")
+ list(APPEND cmake_flags_arg
+ "-D${compiler_flags_var_config}:STRING=${${compiler_flags_var_config}}")
+ endif()
+ endforeach()
+
+ qt_internal_get_target_link_types_for_flag_manipulation(target_link_types)
+ foreach(linker_type IN LISTS target_link_types)
+ set(linker_flags_var "CMAKE_${linker_type}_LINKER_FLAGS")
+ list(APPEND cmake_flags_arg "-D${linker_flags_var}:STRING=${${linker_flags_var}}")
+ if(arg_CONFIG)
+ set(linker_flags_var_config "${linker_flags_var}${config_suffix}")
+ list(APPEND cmake_flags_arg
+ "-D${linker_flags_var_config}:STRING=${${linker_flags_var_config}}")
+ endif()
+ endforeach()
+
try_compile(result
"${target_binary_dir}"
"${target_binary_dir}"