Merge topic 'pch-warn-invalid'

2ce08e5489 PCH: add an option to disable `-Winvalid-pch`

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4499
This commit is contained in:
Brad King
2020-03-27 12:03:21 +00:00
committed by Kitware Robot
13 changed files with 86 additions and 7 deletions
+1 -1
View File
@@ -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)
@@ -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()
@@ -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)
@@ -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()