RunCPackVerifyResult.cmake 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. message(STATUS "=============================================================")
  2. message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)")
  3. message(STATUS "")
  4. if(NOT CPackWiXGenerator_BINARY_DIR)
  5. message(FATAL_ERROR "CPackWiXGenerator_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 "CPackWiXGenerator_BINARY_DIR: ${CPackWiXGenerator_BINARY_DIR}")
  10. execute_process(COMMAND "${CMAKE_CPACK_COMMAND}"
  11. RESULT_VARIABLE CPack_result
  12. OUTPUT_VARIABLE CPack_output
  13. ERROR_VARIABLE CPack_error
  14. WORKING_DIRECTORY "${CPackWiXGenerator_BINARY_DIR}")
  15. if(CPack_result)
  16. message(FATAL_ERROR "CPack execution went wrong!, CPack_output=${CPack_output}, CPack_error=${CPack_error}")
  17. else ()
  18. message(STATUS "CPack_output=${CPack_output}")
  19. endif()
  20. set(expected_file_mask "*.msi")
  21. file(GLOB installer_file "${expected_file_mask}")
  22. message(STATUS "installer_file='${installer_file}'")
  23. message(STATUS "expected_file_mask='${expected_file_mask}'")
  24. if(NOT installer_file)
  25. message(FATAL_ERROR "installer_file does not exist.")
  26. endif()
  27. function(run_wix_command command)
  28. file(TO_CMAKE_PATH "$ENV{WIX}" WIX_ROOT)
  29. set(WIX_PROGRAM "${WIX_ROOT}/bin/${command}.exe")
  30. if(NOT EXISTS "${WIX_PROGRAM}")
  31. message(FATAL_ERROR "Failed to find WiX Tool: ${WIX_PROGRAM}")
  32. endif()
  33. message(STATUS "Running WiX Tool: ${command} ${ARGN}")
  34. execute_process(COMMAND "${WIX_PROGRAM}" ${ARGN}
  35. RESULT_VARIABLE WIX_result
  36. OUTPUT_VARIABLE WIX_output
  37. ERROR_VARIABLE WIX_output
  38. WORKING_DIRECTORY "${CPackWiXGenerator_BINARY_DIR}")
  39. message(STATUS "${command} Output: \n${WIX_output}")
  40. if(WIX_result)
  41. message(FATAL_ERROR "WiX ${command} failed: ${WIX_result}")
  42. endif()
  43. endfunction()
  44. file(GLOB WXS_SOURCE_FILES
  45. "${CPackWiXGenerator_BINARY_DIR}/_CPack_Packages/*/WIX/*.wxs")
  46. if(NOT WXS_SOURCE_FILES)
  47. message(FATAL_ERROR "Failed finding WiX source files to validate.")
  48. endif()
  49. foreach(WXS_SOURCE_FILE IN LISTS WXS_SOURCE_FILES)
  50. run_wix_command(wixcop "${WXS_SOURCE_FILE}")
  51. endforeach()
  52. # error SMOK1076 : ICE61: This product should remove only older
  53. # versions of itself. The Maximum version is not less
  54. # than the current product. (1.0.0 1.0.0)
  55. run_wix_command(smoke -nologo -wx -sw1076 "${installer_file}")