export-compile-commands-check.cmake 714 B

12345678910111213141516171819202122232425
  1. if (NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/compile_commands.json")
  2. list(APPEND RunCMake_TEST_FAILED
  3. "No compile commands database detected.")
  4. endif ()
  5. file(READ "${RunCMake_TEST_BINARY_DIR}/compile_commands.json" compile_commands)
  6. string(JSON length
  7. LENGTH "${compile_commands}")
  8. math(EXPR length "${length} - 1")
  9. foreach (item RANGE "${length}")
  10. string(JSON entry
  11. GET "${compile_commands}"
  12. "${item}")
  13. string(JSON command
  14. GET "${entry}"
  15. "command")
  16. if (NOT command MATCHES "(@|-fmodule-mapper=).*\\.modmap")
  17. string(JSON output
  18. GET "${entry}"
  19. "output")
  20. list(APPEND RunCMake_TEST_FAILED
  21. "Missing `.modmap` argument for '${output}'")
  22. endif ()
  23. endforeach ()