From 25c53ce00ed1e4ea777d1b34552443b5e090a859 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Thu, 19 Sep 2019 17:22:43 +0200 Subject: [PATCH] PCH: Only enable automatically for libraries/modules Some tests are changing headers using defines inside the tests. Let's more closely mirror what qmake does to fix this. And it will also save quite a lot of space since most tests don't include all of e.g. QtCore Change-Id: I6f7e530f922418944d690bd2a1ee5f459ba755e1 Reviewed-by: Alexandru Croitor Reviewed-by: Qt CMake Build Bot --- cmake/QtBuild.cmake | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index fc30e704189..3316fc4c306 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -976,8 +976,18 @@ function(extend_target target) list(APPEND dbus_sources "${sources}") endforeach() + get_target_property(target_type ${target} TYPE) + set(is_library FALSE) + if (${target_type} STREQUAL "STATIC_LIBRARY" OR ${target_type} STREQUAL "SHARED_LIBRARY") + set(is_library TRUE) + endif() foreach(lib ${arg_PUBLIC_LIBRARIES} ${arg_LIBRARIES}) - qt_update_precompiled_header_with_library("${target}" "${lib}") + # Automatically generate PCH for 'target' using dependencies + # if 'target' is a library/module! + if (${is_library}) + qt_update_precompiled_header_with_library("${target}" "${lib}") + endif() + string(REGEX REPLACE "_nolink$" "" base_lib "${lib}") if(NOT base_lib STREQUAL lib) qt_create_nolink_target("${base_lib}" ${target})