summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorCristian Adam <cristian.adam@gmail.com>2019-12-05 10:30:51 (GMT)
committerCristian Adam <cristian.adam@gmail.com>2019-12-08 19:22:34 (GMT)
commit93becd61d19baa718bb10f2df25fedf31dfc2ded (patch)
treed1c8a24e62409734db9a484c4ac145ab0453d150 /Tests
parenta033bafbe01fcb4654f075955e0b3de7be81b0f7 (diff)
downloadCMake-93becd61d19baa718bb10f2df25fedf31dfc2ded.zip
CMake-93becd61d19baa718bb10f2df25fedf31dfc2ded.tar.gz
CMake-93becd61d19baa718bb10f2df25fedf31dfc2ded.tar.bz2
PCH: Use the target's PREFIX for building the pdb file name
Also copy the REUSE_FROM pdb file only if the file is newer than the existing one. Fixes: #19731 Fixes: #20068
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/PrecompileHeaders/PchReuseFromPrefixed-build-stderr.txt2
-rw-r--r--Tests/RunCMake/PrecompileHeaders/PchReuseFromPrefixed.cmake29
-rw-r--r--Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake1
3 files changed, 32 insertions, 0 deletions
diff --git a/Tests/RunCMake/PrecompileHeaders/PchReuseFromPrefixed-build-stderr.txt b/Tests/RunCMake/PrecompileHeaders/PchReuseFromPrefixed-build-stderr.txt
new file mode 100644
index 0000000..8cdcfd9
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/PchReuseFromPrefixed-build-stderr.txt
@@ -0,0 +1,2 @@
+^(|Warning #670: precompiled header file [^
+]* was not generated in this directory)$
diff --git a/Tests/RunCMake/PrecompileHeaders/PchReuseFromPrefixed.cmake b/Tests/RunCMake/PrecompileHeaders/PchReuseFromPrefixed.cmake
new file mode 100644
index 0000000..e306d8e
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/PchReuseFromPrefixed.cmake
@@ -0,0 +1,29 @@
+cmake_minimum_required(VERSION 3.15)
+project(PchReuseFromPrefixed C)
+
+if(CMAKE_C_COMPILE_OPTIONS_USE_PCH)
+ add_definitions(-DHAVE_PCH_SUPPORT)
+endif()
+
+add_library(empty empty.c)
+target_precompile_headers(empty PRIVATE
+ <stdio.h>
+ <string.h>
+)
+target_include_directories(empty PUBLIC include)
+
+add_library(foo foo.c)
+target_include_directories(foo PUBLIC include)
+target_precompile_headers(foo REUSE_FROM empty)
+
+# Visual Studio 2017 and greater
+if (NOT (CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND CMAKE_C_COMPILER_VERSION VERSION_LESS_EQUAL 19.10))
+ set_target_properties(foo PROPERTIES PREFIX "lib" IMPORT_PREFIX "lib")
+endif()
+
+add_executable(foobar foobar.c)
+target_link_libraries(foobar foo )
+set_target_properties(foobar PROPERTIES PRECOMPILE_HEADERS_REUSE_FROM empty)
+
+enable_testing()
+add_test(NAME foobar COMMAND foobar)
diff --git a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake
index ec13663..8d2f4f9 100644
--- a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake
+++ b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake
@@ -17,5 +17,6 @@ run_test(PchInterface)
run_cmake(PchPrologueEpilogue)
run_test(SkipPrecompileHeaders)
run_test(PchReuseFrom)
+run_test(PchReuseFromPrefixed)
run_test(PchReuseFromSubdir)
run_cmake(PchMultilanguage)