diff options
author | Brad King <brad.king@kitware.com> | 2020-03-27 12:03:21 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-03-27 12:03:30 (GMT) |
commit | f6704357159366fc404491e02f1ea6cee87f0989 (patch) | |
tree | a75b6eb21ecb556276b2b4c09424ee1321d24b0c /Tests/RunCMake | |
parent | cc1d5a436b4b2b7630b892890989d3b5ef59dba9 (diff) | |
parent | 2ce08e54891054aeba3f273f9970a7fe8fa8b66c (diff) | |
download | CMake-f6704357159366fc404491e02f1ea6cee87f0989.zip CMake-f6704357159366fc404491e02f1ea6cee87f0989.tar.gz CMake-f6704357159366fc404491e02f1ea6cee87f0989.tar.bz2 |
Merge topic 'pch-warn-invalid'
2ce08e5489 PCH: add an option to disable `-Winvalid-pch`
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4499
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/PrecompileHeaders/PchWarnInvalid-check.cmake | 22 | ||||
-rw-r--r-- | Tests/RunCMake/PrecompileHeaders/PchWarnInvalid.cmake | 16 | ||||
-rw-r--r-- | Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake | 3 |
4 files changed, 42 insertions, 1 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 101e10c..2a4af3e 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -665,7 +665,7 @@ endif() add_RunCMake_test("CTestCommandExpandLists") -add_RunCMake_test(PrecompileHeaders) +add_RunCMake_test(PrecompileHeaders -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}) add_RunCMake_test("UnityBuild") add_RunCMake_test(cmake_command) 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() |