summaryrefslogtreecommitdiffstats
path: root/cmake/QtSanitizerHelpers.cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-08-13 17:37:47 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-08-14 13:17:11 +0200
commit44cce1a2ea9dadd8b2de93f40de34269dda703c0 (patch)
treeeca02c6e828da9e84c4c2de6ff643cafad794024 /cmake/QtSanitizerHelpers.cmake
parent9d3a908e9ed154294ed4c58429d22a9ff8541ba4 (diff)
CMake: Split QtBuild.cmake into smaller files
QtBuild.cmake is huge. Split it. Move module, plugin, tools, executables and test related functions out of QtBuild.cmake into separate files. Do the same for many other things too. An additional requirement is that all the new Helpers files only define functions and macros. No global variable definitions are allowed, nor execution of commands with side effects. Some notes: qt_install_qml_files is removed because it's dead code. Some functions still need to be figured out, because they are interspersed and depend on various global state assignments. Task-number: QTBUG-86035 Change-Id: I21d79ff02eef923c202eb1000422888727cb0e2c Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'cmake/QtSanitizerHelpers.cmake')
-rw-r--r--cmake/QtSanitizerHelpers.cmake31
1 files changed, 31 insertions, 0 deletions
diff --git a/cmake/QtSanitizerHelpers.cmake b/cmake/QtSanitizerHelpers.cmake
new file mode 100644
index 0000000000..5514465178
--- /dev/null
+++ b/cmake/QtSanitizerHelpers.cmake
@@ -0,0 +1,31 @@
+function(qt_internal_set_up_sanitizer_features)
+ set(ECM_ENABLE_SANITIZERS "" CACHE STRING "Enable sanitizers")
+ set_property(CACHE ECM_ENABLE_SANITIZERS PROPERTY STRINGS "address;memory;thread;undefined")
+
+ # If FEATURE_sanitize_foo is set on the command line, make sure to set the appropriate
+ # ECM_ENABLE_SANITIZERS value. Also the other way around. This basically allows setting either
+ # the feature or ECM_ENABLE_SANITIZERS directly.
+ #
+ # TODO: Decide which one of these should be the source of truth, because reconfiguration with
+ # different options might not work as expected when ECM_ENABLE_SANITIZERS is provided instead of
+ # the features.
+ set(enabled_sanitizer_features "")
+ foreach(sanitizer_type address memory thread undefined)
+ if(FEATURE_sanitize_${sanitizer_type})
+ list(APPEND enabled_sanitizer_features "${sanitizer_type}")
+ endif()
+ endforeach()
+ if(enabled_sanitizer_features)
+ set(ECM_ENABLE_SANITIZERS
+ "${enabled_sanitizer_features}" CACHE STRING "Enable sanitizers" FORCE)
+ endif()
+
+ if(ECM_ENABLE_SANITIZERS)
+ foreach(sanitizer_type ${ECM_ENABLE_SANITIZERS})
+ message(STATUS "Enabling sanitizer: ${sanitizer_type}")
+ set(feature_name "FEATURE_sanitize_${sanitizer_type}")
+ set(${feature_name} "ON" CACHE BOOL "Enable ${sanitizer_type} sanitizer" FORCE)
+ set(QT_${feature_name} "ON" CACHE BOOL "Enable ${sanitizer_type} sanitizer" FORCE)
+ endforeach()
+ endif()
+endfunction()