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 <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
This commit is contained in:
Mårten Nordheim 2019-09-19 17:22:43 +02:00
parent 13b54ea477
commit 25c53ce00e

View File

@ -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})