Helpers.cmake 970 B

12345678910111213141516171819202122232425262728293031
  1. function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_VAR)
  2. set(${RESULT_VAR} "${NAME}-${VERSION}-*.json" PARENT_SCOPE)
  3. endfunction()
  4. function(getPackageContentList FILE RESULT_VAR)
  5. set("${RESULT_VAR}" "" PARENT_SCOPE)
  6. endfunction()
  7. function(toExpectedContentList FILE_NO CONTENT_VAR)
  8. set("${CONTENT_VAR}" "" PARENT_SCOPE)
  9. endfunction()
  10. set(ALL_FILES_GLOB "*.json")
  11. function(check_ext_json EXPECTED_FILE ACTUAL_FILE)
  12. file(READ "${EXPECTED_FILE}" _expected_regex)
  13. file(READ "${ACTUAL_FILE}" _actual_contents)
  14. string(REGEX REPLACE "\n+$" "" _expected_regex "${_expected_regex}")
  15. string(REGEX REPLACE "\n+$" "" _actual_contents "${_actual_contents}")
  16. if(NOT "${_actual_contents}" MATCHES "${_expected_regex}")
  17. message(FATAL_ERROR
  18. "Output JSON does not match expected regex.\n"
  19. "Expected regex:\n"
  20. "${_expected_regex}\n"
  21. "Actual output:\n"
  22. "${_actual_contents}\n"
  23. )
  24. endif()
  25. endfunction()