summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-11-18 14:46:11 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-11-18 14:46:26 (GMT)
commit6cb9867ba3054ea4fbafa7ee60485db4d6266354 (patch)
treefb624526a0dc065f41af9397eff3a3f0426e46e4 /Tests
parentfc4f00cbf64c6f192b36e7b9187fc26a1f51a4b4 (diff)
parentbb4c2781ced335c81b3c9307069792dba66d5062 (diff)
downloadCMake-6cb9867ba3054ea4fbafa7ee60485db4d6266354.zip
CMake-6cb9867ba3054ea4fbafa7ee60485db4d6266354.tar.gz
CMake-6cb9867ba3054ea4fbafa7ee60485db4d6266354.tar.bz2
Merge topic 'pch-reuse-no-prop' into release-3.16
bb4c2781ce PCH: Do not issue an error on duplicate target_precompile_headers call Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4046
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/PrecompileHeaders/PchReuseFrom.cmake9
-rw-r--r--Tests/RunCMake/PrecompileHeaders/foobar.c8
2 files changed, 15 insertions, 2 deletions
diff --git a/Tests/RunCMake/PrecompileHeaders/PchReuseFrom.cmake b/Tests/RunCMake/PrecompileHeaders/PchReuseFrom.cmake
index 4502456..03a97ed 100644
--- a/Tests/RunCMake/PrecompileHeaders/PchReuseFrom.cmake
+++ b/Tests/RunCMake/PrecompileHeaders/PchReuseFrom.cmake
@@ -1,8 +1,12 @@
cmake_minimum_required(VERSION 3.15)
project(PchReuseFrom C)
+if(CMAKE_C_COMPILE_OPTIONS_USE_PCH)
+ add_definitions(-DHAVE_PCH_SUPPORT)
+endif()
+
add_library(empty empty.c)
-target_precompile_headers(empty PUBLIC
+target_precompile_headers(empty PRIVATE
<stdio.h>
<string.h>
)
@@ -12,6 +16,9 @@ add_library(foo foo.c)
target_include_directories(foo PUBLIC include)
target_precompile_headers(foo REUSE_FROM empty)
+# should not cause problems if configured multiple times
+target_precompile_headers(foo REUSE_FROM empty)
+
add_executable(foobar foobar.c)
target_link_libraries(foobar foo )
set_target_properties(foobar PROPERTIES PRECOMPILE_HEADERS_REUSE_FROM foo)
diff --git a/Tests/RunCMake/PrecompileHeaders/foobar.c b/Tests/RunCMake/PrecompileHeaders/foobar.c
index 7a135ea..97d465c 100644
--- a/Tests/RunCMake/PrecompileHeaders/foobar.c
+++ b/Tests/RunCMake/PrecompileHeaders/foobar.c
@@ -4,5 +4,11 @@
int main()
{
- return foo() + foo2() + bar();
+ int zeroSize = 0;
+
+#ifdef HAVE_PCH_SUPPORT
+ zeroSize = (int)strlen("");
+#endif
+
+ return foo() + foo2() + bar() + zeroSize;
}