RunCPackVerifyResult.cmake 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. message(STATUS "=============================================================")
  2. message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)")
  3. message(STATUS "")
  4. if(NOT CPackIFWGenerator_BINARY_DIR)
  5. message(FATAL_ERROR "CPackIFWGenerator_BINARY_DIR not set")
  6. endif()
  7. message(STATUS "CMAKE_COMMAND: ${CMAKE_COMMAND}")
  8. message(STATUS "CMAKE_CPACK_COMMAND: ${CMAKE_CPACK_COMMAND}")
  9. message(STATUS "CPackIFWGenerator_BINARY_DIR: ${CPackIFWGenerator_BINARY_DIR}")
  10. if(config)
  11. set(_C_config -C ${config})
  12. endif()
  13. execute_process(COMMAND "${CMAKE_CPACK_COMMAND}"
  14. ${_C_config}
  15. RESULT_VARIABLE CPack_result
  16. OUTPUT_VARIABLE CPack_output
  17. ERROR_VARIABLE CPack_error
  18. WORKING_DIRECTORY "${CPackIFWGenerator_BINARY_DIR}")
  19. if(CPack_result)
  20. message(FATAL_ERROR "CPack execution went wrong!, CPack_output=${CPack_output}, CPack_error=${CPack_error}")
  21. else ()
  22. message(STATUS "CPack_output=${CPack_output}")
  23. endif()
  24. set(expected_file_mask "${CPackIFWGenerator_BINARY_DIR}/_CPack_Packages/*/IFW/*/config/config.xml")
  25. file(GLOB project_file "${expected_file_mask}")
  26. message(STATUS "project_file='${project_file}'")
  27. message(STATUS "expected_file_mask='${expected_file_mask}'")
  28. if(NOT project_file)
  29. message(FATAL_ERROR "project_file does not exist.")
  30. endif()
  31. # should match !define MUI_HEADERIMAGE_BITMAP "${PROJECT_SOURCE_DIR}\header-image.bmp"
  32. file(STRINGS "${project_file}" lines)
  33. file(STRINGS "${project_file}" tag_start REGEX [[<ProductImage>]])
  34. file(STRINGS "${project_file}" tag_end REGEX [[</ProductImage>]])
  35. list(LENGTH tag_start tag_start_size)
  36. list(LENGTH tag_end tag_end_size)
  37. if(NOT tag_start_size EQUAL 2)
  38. message(FATAL_ERROR "Expected to have 2 <ProductImage> not ${tag_start_size}")
  39. endif()
  40. if(NOT tag_end_size EQUAL 2)
  41. message(FATAL_ERROR "Expected to have 2 </ProductImage> not ${tag_end_size}")
  42. endif()
  43. file(STRINGS "${project_file}" tag_start REGEX [[<Image>]])
  44. file(STRINGS "${project_file}" tag_end REGEX [[</Image>]])
  45. list(LENGTH tag_start tag_start_size)
  46. list(LENGTH tag_end tag_end_size)
  47. if(NOT tag_start_size EQUAL 2)
  48. message(FATAL_ERROR "Expected to have 2 <Image> not ${tag_start_size}")
  49. endif()
  50. if(NOT tag_end_size EQUAL 2)
  51. message(FATAL_ERROR "Expected to have 2 </Image> not ${tag_end_size}")
  52. endif()
  53. file(STRINGS "${project_file}" tag_start REGEX [[<Url>]])
  54. file(STRINGS "${project_file}" tag_end REGEX [[</Url>]])
  55. list(LENGTH tag_start tag_start_size)
  56. list(LENGTH tag_end tag_end_size)
  57. if(NOT tag_start_size EQUAL 2)
  58. message(FATAL_ERROR "Expected to have 2 <Url> not ${tag_start_size}")
  59. endif()
  60. if(NOT tag_end_size EQUAL 2)
  61. message(FATAL_ERROR "Expected to have 2 </Url> not ${tag_end_size}")
  62. endif()
  63. set(TO_SEARCHES
  64. "<ProductImages>"
  65. "<Image>ApplicationIcon.png</Image>"
  66. "<Url>https://www.ApplicationIcon.org</Url>"
  67. "<Image>SplashScreen.png</Image>"
  68. "<Url>https://www.SplashScreen.org</Url>"
  69. "</ProductImages>"
  70. )
  71. foreach(TO_SEARCH ${TO_SEARCHES})
  72. string(FIND "${lines}" "${TO_SEARCH}" output_index)
  73. message(STATUS "Found the ${TO_SEARCH} at index ${output_index}")
  74. if("${output_index}" EQUAL "-1")
  75. message(FATAL_ERROR "${TO_SEARCH} not found in the project")
  76. endif()
  77. endforeach()