release_cmake.cmake 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. set(CVSROOT ":pserver:[email protected]:/cvsroot/CMake")
  2. get_filename_component(SCRIPT_PATH "${CMAKE_CURRENT_LIST_FILE}" PATH)
  3. # default to self extracting tgz, tgz, and tar.Z
  4. if(NOT DEFINED CPACK_BINARY_GENERATORS)
  5. set(CPACK_BINARY_GENERATORS "STGZ TGZ TZ")
  6. endif(NOT DEFINED CPACK_BINARY_GENERATORS)
  7. if(DEFINED EXTRA_COPY)
  8. set(HAS_EXTRA_COPY 1)
  9. endif(DEFINED EXTRA_COPY)
  10. if(NOT DEFINED CMAKE_RELEASE_DIRECTORY)
  11. set(CMAKE_RELEASE_DIRECTORY "~/CMakeReleaseDirectory")
  12. endif(NOT DEFINED CMAKE_RELEASE_DIRECTORY)
  13. if(NOT DEFINED SCRIPT_NAME)
  14. set(SCRIPT_NAME "${HOST}")
  15. endif(NOT DEFINED SCRIPT_NAME)
  16. if(NOT DEFINED MAKE_PROGRAM)
  17. message(FATAL_ERROR "MAKE_PROGRAM must be set")
  18. endif(NOT DEFINED MAKE_PROGRAM)
  19. if(NOT DEFINED MAKE)
  20. set(MAKE "${MAKE_PROGRAM}")
  21. endif(NOT DEFINED MAKE)
  22. if(NOT DEFINED RUN_SHELL)
  23. set(RUN_SHELL "/bin/sh")
  24. endif(NOT DEFINED RUN_SHELL)
  25. if(NOT DEFINED PROCESSORS)
  26. set(PROCESSORS 1)
  27. endif(NOT DEFINED PROCESSORS)
  28. if(NOT DEFINED CMAKE_VERSION)
  29. message(FATAL_ERROR "CMAKE_VERSION not defined")
  30. endif(NOT DEFINED CMAKE_VERSION)
  31. if(NOT DEFINED CVS_COMMAND)
  32. set(CVS_COMMAND cvs)
  33. endif(NOT DEFINED CVS_COMMAND)
  34. if("${CMAKE_VERSION}" STREQUAL "CVS")
  35. set( CMAKE_CHECKOUT "${CVS_COMMAND} -q -z3 -d ${CVSROOT} export -D now ")
  36. set( CMAKE_VERSION "CurrentCVS")
  37. else("${CMAKE_VERSION}" STREQUAL "CVS")
  38. set( CMAKE_CHECKOUT "${CVS_COMMAND} -q -z3 -d ${CVSROOT} export -r ${CMAKE_VERSION} ")
  39. endif("${CMAKE_VERSION}" STREQUAL "CVS")
  40. if(NOT DEFINED FINAL_PATH )
  41. set(FINAL_PATH ${CMAKE_RELEASE_DIRECTORY}/${CMAKE_VERSION}-build)
  42. endif(NOT DEFINED FINAL_PATH )
  43. if(NOT HOST)
  44. message(FATAL_ERROR "HOST must be specified with -DHOST=host")
  45. endif(NOT HOST)
  46. if(NOT DEFINED MAKE)
  47. message(FATAL_ERROR "MAKE must be specified with -DMAKE=\"make -j2\"")
  48. endif(NOT DEFINED MAKE)
  49. message("Creating CMake release ${CMAKE_VERSION} on ${HOST} with parallel = ${PROCESSORS}")
  50. # define a macro to run a remote command
  51. macro(remote_command comment command)
  52. message("${comment}")
  53. if(${ARGC} GREATER 2)
  54. message("ssh ${HOST} ${EXTRA_HOP} ${command}")
  55. execute_process(COMMAND ssh ${HOST} ${EXTRA_HOP} ${command} RESULT_VARIABLE result INPUT_FILE ${ARGV2})
  56. else(${ARGC} GREATER 2)
  57. message("ssh ${HOST} ${EXTRA_HOP} ${command}")
  58. execute_process(COMMAND ssh ${HOST} ${EXTRA_HOP} ${command} RESULT_VARIABLE result)
  59. endif(${ARGC} GREATER 2)
  60. if(${result} GREATER 0)
  61. message(FATAL_ERROR "Error running command: ${command}, return value = ${result}")
  62. endif(${result} GREATER 0)
  63. endmacro(remote_command)
  64. # set this so configure file will work from script mode
  65. set(CMAKE_BACKWARDS_COMPATIBILITY 2.4)
  66. # create the script specific for the given host
  67. set(SCRIPT_FILE release_cmake-${SCRIPT_NAME}.sh)
  68. configure_file(${SCRIPT_PATH}/release_cmake.sh.in ${SCRIPT_FILE} @ONLY)
  69. # run the script by starting a shell on the remote machine
  70. # then using the script file as input to the shell
  71. IF(RUN_LOCAL)
  72. message(FATAL_ERROR "run this command: ${RUN_SHELL} ${SCRIPT_FILE}")
  73. ELSE(RUN_LOCAL)
  74. remote_command("run release_cmake-${HOST}.sh on server"
  75. "${RUN_SHELL}" ${SCRIPT_FILE})
  76. ENDIF(RUN_LOCAL)
  77. # now figure out which types of packages were created
  78. set(generators ${CPACK_BINARY_GENERATORS} ${CPACK_SOURCE_GENERATORS})
  79. separate_arguments(generators)
  80. foreach(gen ${generators})
  81. if("${gen}" STREQUAL "TGZ")
  82. set(SUFFIXES ${SUFFIXES} "*.tar.gz")
  83. endif("${gen}" STREQUAL "TGZ")
  84. if("${gen}" STREQUAL "STGZ")
  85. set(SUFFIXES ${SUFFIXES} "*.sh")
  86. endif("${gen}" STREQUAL "STGZ")
  87. if("${gen}" STREQUAL "PackageMaker")
  88. set(SUFFIXES ${SUFFIXES} "*.dmg")
  89. endif("${gen}" STREQUAL "PackageMaker")
  90. if("${gen}" STREQUAL "TBZ2")
  91. set(SUFFIXES ${SUFFIXES} "*.tar.bz2")
  92. endif("${gen}" STREQUAL "TBZ2")
  93. if("${gen}" MATCHES "Cygwin")
  94. set(SUFFIXES ${SUFFIXES} "*.tar.bz2")
  95. set(extra_files setup.hint)
  96. endif("${gen}" MATCHES "Cygwin")
  97. if("${gen}" STREQUAL "TZ")
  98. set(SUFFIXES ${SUFFIXES} "*.tar.Z")
  99. endif("${gen}" STREQUAL "TZ")
  100. if("${gen}" STREQUAL "ZIP")
  101. set(SUFFIXES ${SUFFIXES} "*.zip")
  102. endif("${gen}" STREQUAL "ZIP")
  103. if("${gen}" STREQUAL "NSIS")
  104. set(SUFFIXES ${SUFFIXES} "*.exe")
  105. endif("${gen}" STREQUAL "NSIS")
  106. endforeach(gen)
  107. # copy all the files over from the remote machine
  108. set(PROJECT_PREFIX cmake-)
  109. foreach(suffix ${SUFFIXES})
  110. message("scp ${HOST}:${FINAL_PATH}/${PROJECT_PREFIX}${suffix} .")
  111. execute_process(COMMAND
  112. scp ${HOST}:${FINAL_PATH}/${PROJECT_PREFIX}${suffix} .
  113. RESULT_VARIABLE result)
  114. if(${result} GREATER 0)
  115. message("error getting file back scp ${HOST}:${FINAL_PATH}/${PROJECT_PREFIX}${suffix} .")
  116. endif(${result} GREATER 0)
  117. endforeach(suffix)
  118. # if there are extra files to copy get them as well
  119. if(extra_files)
  120. foreach(f ${extra_files})
  121. message("scp ${HOST}:${FINAL_PATH}/${f} .")
  122. execute_process(COMMAND
  123. scp ${HOST}:${FINAL_PATH}/${f} .
  124. RESULT_VARIABLE result)
  125. if(${result} GREATER 0)
  126. message("error getting file back scp ${HOST}:${FINAL_PATH}/${f} .")
  127. endif(${result} GREATER 0)
  128. endforeach(f)
  129. endif(extra_files)