RunCPack.cmake 1.6 KB

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