diff options
author | Cristian Adam <cristian.adam@gmail.com> | 2019-08-30 14:21:19 (GMT) |
---|---|---|
committer | Cristian Adam <cristian.adam@gmail.com> | 2019-09-17 09:58:38 (GMT) |
commit | 729d997f1073c7a177da5b46b073a08b95adfa74 (patch) | |
tree | 0b419aebe0dcb8a30686861954c4e8515d448a1d /Tests | |
parent | 1ac4e0ef1b29affc9e4f2cd86c4fc8c2252f2ab2 (diff) | |
download | CMake-729d997f1073c7a177da5b46b073a08b95adfa74.zip CMake-729d997f1073c7a177da5b46b073a08b95adfa74.tar.gz CMake-729d997f1073c7a177da5b46b073a08b95adfa74.tar.bz2 |
Precompile Headers: Add REUSE_FROM signature
Add the ability to share precompiled headers artifacts between
targets.
Fixes: #19659
Diffstat (limited to 'Tests')
7 files changed, 49 insertions, 1 deletions
diff --git a/Tests/RunCMake/PrecompileHeaders/PchReuseFrom.cmake b/Tests/RunCMake/PrecompileHeaders/PchReuseFrom.cmake new file mode 100644 index 0000000..4502456 --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/PchReuseFrom.cmake @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.15) +project(PchReuseFrom C) + +add_library(empty empty.c) +target_precompile_headers(empty PUBLIC + <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) + +add_executable(foobar foobar.c) +target_link_libraries(foobar foo ) +set_target_properties(foobar PROPERTIES PRECOMPILE_HEADERS_REUSE_FROM foo) + +enable_testing() +add_test(NAME foobar COMMAND foobar) diff --git a/Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir-build-stderr.txt b/Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir-build-stderr.txt new file mode 100644 index 0000000..8cdcfd9 --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir-build-stderr.txt @@ -0,0 +1,2 @@ +^(|Warning #670: precompiled header file [^ +]* was not generated in this directory)$ diff --git a/Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir.cmake b/Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir.cmake new file mode 100644 index 0000000..fff74dc --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir.cmake @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.15) +project(PchReuseFromSubdir C) + +add_library(empty empty.c) +target_precompile_headers(empty PUBLIC + <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) + +subdirs(subdir) + +enable_testing() +add_test(NAME foobar COMMAND foobar) diff --git a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake index fffcc47..bd3b1b8 100644 --- a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake +++ b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake @@ -16,3 +16,5 @@ run_cmake(DisabledPch) run_test(PchInterface) run_cmake(PchPrologueEpilogue) run_test(SkipPrecompileHeaders) +run_test(PchReuseFrom) +run_test(PchReuseFromSubdir) diff --git a/Tests/RunCMake/PrecompileHeaders/empty.c b/Tests/RunCMake/PrecompileHeaders/empty.c new file mode 100644 index 0000000..30ae1c4 --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/empty.c @@ -0,0 +1,3 @@ +void nothing() +{ +} diff --git a/Tests/RunCMake/PrecompileHeaders/include/foo.h b/Tests/RunCMake/PrecompileHeaders/include/foo.h index 4a49474..fc0ae14 100644 --- a/Tests/RunCMake/PrecompileHeaders/include/foo.h +++ b/Tests/RunCMake/PrecompileHeaders/include/foo.h @@ -1,6 +1,6 @@ #ifndef foo_h #define foo_h -extern int foo(); +int foo(void); #endif diff --git a/Tests/RunCMake/PrecompileHeaders/subdir/CMakeLists.txt b/Tests/RunCMake/PrecompileHeaders/subdir/CMakeLists.txt new file mode 100644 index 0000000..fa926c4 --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/subdir/CMakeLists.txt @@ -0,0 +1,3 @@ +add_executable(foobar ../foobar.c) +target_link_libraries(foobar foo ) +set_target_properties(foobar PROPERTIES PRECOMPILE_HEADERS_REUSE_FROM foo) |