PchWarnInvalid-check.cmake 824 B

12345678910111213141516171819202122
  1. if (NOT CMAKE_C_COMPILER_ID MATCHES "GNU|Intel" OR
  2. (CMAKE_C_COMPILER_ID STREQUAL "Intel" AND CMAKE_HOST_WIN32))
  3. return()
  4. endif()
  5. file(STRINGS ${RunCMake_TEST_BINARY_DIR}/compile_commands.json empty_dir_commands
  6. REGEX "command.*-Winvalid-pch.*empty.dir/cmake_pch.h")
  7. file(STRINGS ${RunCMake_TEST_BINARY_DIR}/compile_commands.json foo_dir_commands
  8. REGEX "command.*-Winvalid-pch.*foo.dir/cmake_pch.h")
  9. list(LENGTH empty_dir_commands empty_dir_commands_size)
  10. list(LENGTH foo_dir_commands foo_dir_commands_size)
  11. if (empty_dir_commands_size EQUAL 0)
  12. set(RunCMake_TEST_FAILED "empty target should have -Winvalid-pch compile option present")
  13. return()
  14. endif()
  15. if (foo_dir_commands_size GREATER 0)
  16. set(RunCMake_TEST_FAILED "foo target should not have -Winvalid-pch compile option present")
  17. return()
  18. endif()