diff options
author | Cristian Adam <cristian.adam@gmail.com> | 2020-03-18 18:21:08 (GMT) |
---|---|---|
committer | Cristian Adam <cristian.adam@gmail.com> | 2020-03-26 13:24:46 (GMT) |
commit | 2ce08e54891054aeba3f273f9970a7fe8fa8b66c (patch) | |
tree | dddfaec9accd7f9d5c0d5cfa1a036cd35e162b4f /Tests/RunCMake/PrecompileHeaders | |
parent | 863b0fa2aca3ece98d177f2dbafcad56f7037c8a (diff) | |
download | CMake-2ce08e54891054aeba3f273f9970a7fe8fa8b66c.zip CMake-2ce08e54891054aeba3f273f9970a7fe8fa8b66c.tar.gz CMake-2ce08e54891054aeba3f273f9970a7fe8fa8b66c.tar.bz2 |
PCH: add an option to disable `-Winvalid-pch`
Fixes: #20295
Diffstat (limited to 'Tests/RunCMake/PrecompileHeaders')
3 files changed, 41 insertions, 0 deletions
diff --git a/Tests/RunCMake/PrecompileHeaders/PchWarnInvalid-check.cmake b/Tests/RunCMake/PrecompileHeaders/PchWarnInvalid-check.cmake new file mode 100644 index 0000000..3e7fb30 --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/PchWarnInvalid-check.cmake @@ -0,0 +1,22 @@ +if (NOT CMAKE_C_COMPILER_ID MATCHES "GNU|Intel" OR + (CMAKE_C_COMPILER_ID STREQUAL "Intel" AND CMAKE_HOST_WIN32)) + return() +endif() + +file(STRINGS ${RunCMake_TEST_BINARY_DIR}/compile_commands.json empty_dir_commands + REGEX "command.*-Winvalid-pch.*empty.dir/cmake_pch.h") +file(STRINGS ${RunCMake_TEST_BINARY_DIR}/compile_commands.json foo_dir_commands + REGEX "command.*-Winvalid-pch.*foo.dir/cmake_pch.h") + +list(LENGTH empty_dir_commands empty_dir_commands_size) +list(LENGTH foo_dir_commands foo_dir_commands_size) + +if (empty_dir_commands_size EQUAL 0) + set(RunCMake_TEST_FAILED "empty target should have -Winvalid-pch compile option present") + return() +endif() + +if (foo_dir_commands_size GREATER 0) + set(RunCMake_TEST_FAILED "foo target should not have -Winvalid-pch compile option present") + return() +endif() diff --git a/Tests/RunCMake/PrecompileHeaders/PchWarnInvalid.cmake b/Tests/RunCMake/PrecompileHeaders/PchWarnInvalid.cmake new file mode 100644 index 0000000..4525664 --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/PchWarnInvalid.cmake @@ -0,0 +1,16 @@ +enable_language(C) + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +add_library(empty empty.c) +target_precompile_headers(empty PUBLIC + <stdio.h> + <string.h> +) + +add_library(foo foo.c) +target_precompile_headers(foo PUBLIC + <stdio.h> + <string.h> +) +set_target_properties(foo PROPERTIES PCH_WARN_INVALID OFF) diff --git a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake index f587c7d..3f684fc 100644 --- a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake +++ b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake @@ -21,3 +21,6 @@ run_test(PchReuseFrom) run_test(PchReuseFromPrefixed) run_test(PchReuseFromSubdir) run_cmake(PchMultilanguage) +if(RunCMake_GENERATOR MATCHES "Make|Ninja") + run_cmake(PchWarnInvalid) +endif() |