RunCPackVerifyResult.cmake 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. message(STATUS "=============================================================================")
  2. message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)")
  3. message(STATUS "")
  4. if(NOT CPackComponentsForAll_BINARY_DIR)
  5. message(FATAL_ERROR "CPackComponentsForAll_BINARY_DIR not set")
  6. endif(NOT CPackComponentsForAll_BINARY_DIR)
  7. if(NOT CPackGen)
  8. message(FATAL_ERROR "CPackGen not set")
  9. endif(NOT CPackGen)
  10. if(NOT CPackCommand)
  11. message(FATAL_ERROR "CPackCommand not set")
  12. endif(NOT CPackCommand)
  13. if(NOT CPackComponentWay)
  14. message(FATAL_ERROR "CPackComponentWay not set")
  15. endif(NOT CPackComponentWay)
  16. set(expected_file_mask "")
  17. # The usual default behavior is to expect a single file
  18. # Then some specific generators (Archive, RPM, ...)
  19. # May produce several numbers of files depending on
  20. # CPACK_COMPONENT_xxx values
  21. set(expected_count 1)
  22. execute_process(COMMAND ${CPackCommand} -G ${CPackGen}
  23. RESULT_VARIABLE CPack_result
  24. OUTPUT_VARIABLE CPack_output
  25. ERROR_VARIABLE CPack_error
  26. WORKING_DIRECTORY ${CPackComponentsForAll_BINARY_DIR})
  27. if (CPack_result)
  28. message(SEND_ERROR "CPack_output=${CPack_output}")
  29. message(SEND_ERROR "CPack_error=${CPack_error}")
  30. message(FATAL_ERROR "error: CPack execution went wrong!")
  31. endif(CPack_result)
  32. if(CPackGen MATCHES "ZIP")
  33. set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.zip")
  34. if (${CPackComponentWay} STREQUAL "default")
  35. set(expected_count 1)
  36. endif(${CPackComponentWay} STREQUAL "default")
  37. endif(CPackGen MATCHES "ZIP")
  38. # Now verify if the number of expected file is OK
  39. # - using expected_file_mask and
  40. # - expected_count
  41. if(expected_file_mask)
  42. file(GLOB expected_file "${expected_file_mask}")
  43. message(STATUS "expected_count='${expected_count}'")
  44. message(STATUS "expected_file='${expected_file}'")
  45. message(STATUS "expected_file_mask='${expected_file_mask}'")
  46. if(NOT expected_file)
  47. message(SEND_ERROR "CPack_output=${CPack_output}")
  48. message(SEND_ERROR "CPack_error=${CPack_error}")
  49. message(FATAL_ERROR "error: expected_file=${expected_file} does not exist: CPackComponentsForAll test fails.")
  50. endif(NOT expected_file)
  51. list(LENGTH expected_file actual_count)
  52. message(STATUS "actual_count='${actual_count}'")
  53. if(NOT actual_count EQUAL expected_count)
  54. message(SEND_ERROR "CPack_output=${CPack_output}")
  55. message(SEND_ERROR "CPack_error=${CPack_error}")
  56. message(FATAL_ERROR "error: expected_count=${expected_count} does not match actual_count=${actual_count}: CPackComponents test fails.")
  57. endif(NOT actual_count EQUAL expected_count)
  58. endif(expected_file_mask)