summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorCristian Adam <cristian.adam@gmail.com>2019-09-19 21:56:31 (GMT)
committerBrad King <brad.king@kitware.com>2019-09-23 15:13:13 (GMT)
commitacb9511044a230126289c1e99cfed134c3be3c52 (patch)
tree4beb957a681b2baa9095c4f18f0254fbb29555d9 /Tests
parentebb9346490741ddc2ce6f552bc1be57dfc730cfa (diff)
downloadCMake-acb9511044a230126289c1e99cfed134c3be3c52.zip
CMake-acb9511044a230126289c1e99cfed134c3be3c52.tar.gz
CMake-acb9511044a230126289c1e99cfed134c3be3c52.tar.bz2
Precompile headers: Treat headers as relative to current source directory
Teach `target_precompile_headers` to treat relative paths the same way as `target_sources`. Fixes: #19733
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/PrecompileHeaders/DisabledPch.cmake2
-rw-r--r--Tests/RunCMake/PrecompileHeaders/PchInterface-check.cmake13
-rw-r--r--Tests/RunCMake/PrecompileHeaders/PchInterface.cmake5
-rw-r--r--Tests/RunCMake/PrecompileHeaders/foo.c6
-rw-r--r--Tests/RunCMake/PrecompileHeaders/foobar.c3
-rw-r--r--Tests/RunCMake/PrecompileHeaders/include/foo2.h6
6 files changed, 22 insertions, 13 deletions
diff --git a/Tests/RunCMake/PrecompileHeaders/DisabledPch.cmake b/Tests/RunCMake/PrecompileHeaders/DisabledPch.cmake
index ee47980..59ee14b 100644
--- a/Tests/RunCMake/PrecompileHeaders/DisabledPch.cmake
+++ b/Tests/RunCMake/PrecompileHeaders/DisabledPch.cmake
@@ -4,7 +4,7 @@ project(DisabledPch C)
add_library(foo foo.c)
target_include_directories(foo PUBLIC include)
target_precompile_headers(foo PUBLIC
- foo.h
+ include/foo.h
<stdio.h>
\"string.h\"
)
diff --git a/Tests/RunCMake/PrecompileHeaders/PchInterface-check.cmake b/Tests/RunCMake/PrecompileHeaders/PchInterface-check.cmake
index cbd6ede..caeb22b 100644
--- a/Tests/RunCMake/PrecompileHeaders/PchInterface-check.cmake
+++ b/Tests/RunCMake/PrecompileHeaders/PchInterface-check.cmake
@@ -18,19 +18,14 @@ endif()
file(STRINGS ${foo_pch_header} foo_pch_header_strings)
-if (NOT "#include \"foo.h\"" IN_LIST foo_pch_header_strings OR
- NOT "#include <stdio.h>" IN_LIST foo_pch_header_strings OR
- NOT "#include \"string.h\"" IN_LIST foo_pch_header_strings)
- set(RunCMake_TEST_FAILED "Generated foo pch header ${foo_pch_header} has bad content")
+if (NOT foo_pch_header_strings MATCHES ";#include \"[^\"]*PrecompileHeaders/include/foo.h\";#include \"foo2.h\";#include <stdio.h>;#include \"string.h\"(;|$)")
+ set(RunCMake_TEST_FAILED "Generated foo pch header\n ${foo_pch_header}\nhas bad content:\n ${foo_pch_header_strings}")
return()
endif()
file(STRINGS ${foobar_pch_header} foobar_pch_header_strings)
-if (NOT "#include \"foo.h\"" IN_LIST foobar_pch_header_strings OR
- NOT "#include <stdio.h>" IN_LIST foobar_pch_header_strings OR
- NOT "#include \"string.h\"" IN_LIST foobar_pch_header_strings OR
- NOT "#include \"bar.h\"" IN_LIST foobar_pch_header_strings)
- set(RunCMake_TEST_FAILED "Generated foobar pch header ${foobar_pch_header} has bad content")
+if (NOT foobar_pch_header_strings MATCHES ";#include \"[^\"]*PrecompileHeaders/include/foo.h\";#include \"foo2.h\";#include <stdio.h>;#include \"string.h\";#include \"[^\"]*PrecompileHeaders/include/bar.h\"(;|$)")
+ set(RunCMake_TEST_FAILED "Generated foobar pch header\n ${foobar_pch_header}\nhas bad content:\n ${foobar_pch_header_strings}")
return()
endif()
diff --git a/Tests/RunCMake/PrecompileHeaders/PchInterface.cmake b/Tests/RunCMake/PrecompileHeaders/PchInterface.cmake
index 9041b09..a1e0792 100644
--- a/Tests/RunCMake/PrecompileHeaders/PchInterface.cmake
+++ b/Tests/RunCMake/PrecompileHeaders/PchInterface.cmake
@@ -4,14 +4,15 @@ project(PchInterface C)
add_library(foo foo.c)
target_include_directories(foo PUBLIC include)
target_precompile_headers(foo PUBLIC
- foo.h
+ include/foo.h
+ \"foo2.h\"
<stdio.h>
\"string.h\"
)
add_library(bar INTERFACE)
target_include_directories(bar INTERFACE include)
-target_precompile_headers(bar INTERFACE bar.h)
+target_precompile_headers(bar INTERFACE include/bar.h)
add_executable(foobar foobar.c)
target_link_libraries(foobar foo bar)
diff --git a/Tests/RunCMake/PrecompileHeaders/foo.c b/Tests/RunCMake/PrecompileHeaders/foo.c
index 974a248..85ea230 100644
--- a/Tests/RunCMake/PrecompileHeaders/foo.c
+++ b/Tests/RunCMake/PrecompileHeaders/foo.c
@@ -1,6 +1,12 @@
#include "foo.h"
+#include "foo2.h"
int foo()
{
return 0;
}
+
+int foo2()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/PrecompileHeaders/foobar.c b/Tests/RunCMake/PrecompileHeaders/foobar.c
index 6dbf8ce..7a135ea 100644
--- a/Tests/RunCMake/PrecompileHeaders/foobar.c
+++ b/Tests/RunCMake/PrecompileHeaders/foobar.c
@@ -1,7 +1,8 @@
#include "bar.h"
#include "foo.h"
+#include "foo2.h"
int main()
{
- return foo() + bar();
+ return foo() + foo2() + bar();
}
diff --git a/Tests/RunCMake/PrecompileHeaders/include/foo2.h b/Tests/RunCMake/PrecompileHeaders/include/foo2.h
new file mode 100644
index 0000000..4bf9c81
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/include/foo2.h
@@ -0,0 +1,6 @@
+#ifndef foo2_h
+#define foo2_h
+
+int foo2(void);
+
+#endif