RunCPackVerifyResult.cmake 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. 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 "${CPackWiXGenerator_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 "*.msi")
  25. file(GLOB installer_file "${expected_file_mask}")
  26. message(STATUS "installer_file='${installer_file}'")
  27. message(STATUS "expected_file_mask='${expected_file_mask}'")
  28. if(NOT installer_file)
  29. message(FATAL_ERROR "installer_file does not exist.")
  30. endif()
  31. function(run_wix_command command)
  32. file(TO_CMAKE_PATH "$ENV{WIX}" WIX_ROOT)
  33. set(WIX_PROGRAM "${WIX_ROOT}/bin/${command}.exe")
  34. if(NOT EXISTS "${WIX_PROGRAM}")
  35. message(FATAL_ERROR "Failed to find WiX Tool: ${WIX_PROGRAM}")
  36. endif()
  37. message(STATUS "Running WiX Tool: ${command} ${ARGN}")
  38. execute_process(COMMAND "${WIX_PROGRAM}" ${ARGN}
  39. RESULT_VARIABLE WIX_result
  40. OUTPUT_VARIABLE WIX_output
  41. ERROR_VARIABLE WIX_output
  42. WORKING_DIRECTORY "${CPackWiXGenerator_BINARY_DIR}")
  43. message(STATUS "${command} Output: \n${WIX_output}")
  44. if(WIX_result)
  45. message(FATAL_ERROR "WiX ${command} failed: ${WIX_result}")
  46. endif()
  47. endfunction()
  48. file(GLOB WXS_SOURCE_FILES
  49. "${CPackWiXGenerator_BINARY_DIR}/_CPack_Packages/*/WIX/*.wxs")
  50. if(NOT WXS_SOURCE_FILES)
  51. message(FATAL_ERROR "Failed finding WiX source files to validate.")
  52. endif()
  53. foreach(WXS_SOURCE_FILE IN LISTS WXS_SOURCE_FILES)
  54. run_wix_command(wixcop "${WXS_SOURCE_FILE}")
  55. endforeach()
  56. # error SMOK1076 : ICE61: This product should remove only older
  57. # versions of itself. The Maximum version is not less
  58. # than the current product. (1.0.0 1.0.0)
  59. run_wix_command(smoke -nologo -wx -sw1076 "${installer_file}")