summaryrefslogtreecommitdiffstats
path: root/cmake/QtPrecompiledHeadersHelpers.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/QtPrecompiledHeadersHelpers.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/QtPrecompiledHeadersHelpers.cmake')
-rw-r--r--cmake/QtPrecompiledHeadersHelpers.cmake29
1 files changed, 29 insertions, 0 deletions
diff --git a/cmake/QtPrecompiledHeadersHelpers.cmake b/cmake/QtPrecompiledHeadersHelpers.cmake
new file mode 100644
index 0000000000..b9735cd52a
--- /dev/null
+++ b/cmake/QtPrecompiledHeadersHelpers.cmake
@@ -0,0 +1,29 @@
+function(qt_update_precompiled_header target precompiled_header)
+ if (precompiled_header AND BUILD_WITH_PCH)
+ set_property(TARGET "${target}" APPEND PROPERTY "PRECOMPILE_HEADERS" "$<$<OR:$<COMPILE_LANGUAGE:CXX>,$<COMPILE_LANGUAGE:OBJCXX>>:${precompiled_header}>")
+ endif()
+endfunction()
+
+function(qt_update_precompiled_header_with_library target library)
+ if (TARGET "${library}")
+ get_target_property(TARGET_TYPE "${library}" TYPE)
+ if (NOT TARGET_TYPE STREQUAL "INTERFACE_LIBRARY")
+ get_target_property(HEADER "${library}" MODULE_HEADER)
+ qt_update_precompiled_header("${target}" "${HEADER}")
+ endif()
+ endif()
+endfunction()
+
+function(qt_update_ignore_pch_source target sources)
+ if (sources)
+ set_source_files_properties(${sources} PROPERTIES SKIP_PRECOMPILE_HEADERS ON)
+ endif()
+endfunction()
+
+function(qt_ignore_pch_obj_c_sources target sources)
+ # No obj-cxx PCH support for versions lower than 3.16.
+ if(CMAKE_VERSION VERSION_LESS 3.16.0)
+ list(FILTER sources INCLUDE REGEX "\\.mm$")
+ qt_update_ignore_pch_source("${target}" "${sources}")
+ endif()
+endfunction()