RunCPack.cmake 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. if(NOT DEFINED cpack)
  2. message(FATAL_ERROR "cpack not defined")
  3. endif()
  4. if(NOT DEFINED dir)
  5. message(FATAL_ERROR "dir not defined")
  6. endif()
  7. # Analyze 'cpack --help' output for list of available generators:
  8. #
  9. execute_process(COMMAND ${cpack} --help
  10. RESULT_VARIABLE result
  11. OUTPUT_VARIABLE stdout
  12. ERROR_VARIABLE stderr
  13. WORKING_DIRECTORY ${dir})
  14. string(REPLACE ";" "\\;" stdout "${stdout}")
  15. string(REPLACE "\n" "E;" stdout "${stdout}")
  16. set(collecting 0)
  17. set(generators)
  18. foreach(eline ${stdout})
  19. string(REGEX REPLACE "^(.*)E$" "\\1" line "${eline}")
  20. if(collecting AND NOT line STREQUAL "")
  21. string(REGEX REPLACE "^ ([^ ]+) += (.*)$" "\\1" gen "${line}")
  22. string(REGEX REPLACE "^ ([^ ]+) += (.*)$" "\\2" doc "${line}")
  23. set(generators ${generators} ${gen})
  24. endif()
  25. if(line STREQUAL "Generators")
  26. set(collecting 1)
  27. endif()
  28. endforeach()
  29. # Call cpack with -G on each available generator. We do not care if this
  30. # succeeds or not. We expect it *not* to succeed if the underlying packaging
  31. # tools are not installed on the system... This test is here simply to add
  32. # coverage for the various cpack generators, even/especially to test ones
  33. # where the tools are not installed.
  34. #
  35. message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)")
  36. message(STATUS "CPack generators='${generators}'")
  37. foreach(g ${generators})
  38. message(STATUS "Calling cpack -G ${g}...")
  39. execute_process(COMMAND ${cpack} -G ${g}
  40. RESULT_VARIABLE result
  41. OUTPUT_VARIABLE stdout
  42. ERROR_VARIABLE stderr
  43. WORKING_DIRECTORY ${dir})
  44. message(STATUS "result='${result}'")
  45. message(STATUS "stdout='${stdout}'")
  46. message(STATUS "stderr='${stderr}'")
  47. message(STATUS "")
  48. endforeach()