mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-24 07:08:38 -05:00
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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user