aboutsummaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2019-10-11 13:14:42 +0200
committerTobias Hunger <tobias.hunger@qt.io>2019-10-16 08:44:47 +0000
commita28f57abb9ea9b0228fd8daf56710a1c870efc8a (patch)
treef104c833fd093c41ae7633c788ae11b621f91479 /cmake
parent1e54d45139519a66de5e06767310245ee0f7d728 (diff)
CMake BuildSystem: Fix visibility handling for PCH
Change-Id: Ib91f03cf4f13ddefe365cf1e59cc083d700f0672 Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtCreatorAPI.cmake12
1 files changed, 11 insertions, 1 deletions
diff --git a/cmake/QtCreatorAPI.cmake b/cmake/QtCreatorAPI.cmake
index b635c5debb..f122ef1daf 100644
--- a/cmake/QtCreatorAPI.cmake
+++ b/cmake/QtCreatorAPI.cmake
@@ -288,6 +288,14 @@ endfunction()
function(enable_pch target)
if (BUILD_WITH_PCH)
+ # Skip PCH for targets that do not use the expected visibility settings:
+ get_target_property(visibility_property "${target}" CXX_VISIBILITY_PRESET)
+ get_target_property(inlines_property "${target}" VISIBILITY_INLINES_HIDDEN)
+
+ if (NOT visibility_property STREQUAL "hidden" OR NOT inlines_property)
+ return()
+ endif()
+
get_target_property(target_type ${target} TYPE)
if (NOT ${target_type} STREQUAL "OBJECT_LIBRARY")
function(_recursively_collect_dependencies input_target)
@@ -313,7 +321,9 @@ function(enable_pch target)
${CMAKE_CURRENT_BINARY_DIR}/empty_pch.c)
target_compile_definitions(${pch_target} PRIVATE ${DEFAULT_DEFINES})
set_target_properties(${pch_target} PROPERTIES
- PRECOMPILE_HEADERS ${pch_file})
+ PRECOMPILE_HEADERS ${pch_file}
+ CXX_VISIBILITY_PRESET hidden
+ VISIBILITY_INLINES_HIDDEN ON)
target_link_libraries(${pch_target} PRIVATE ${pch_dependency})
endif()
endfunction()