release_cmake.cmake 5.08 KB
Newer Older
1
2
3
4
if(NOT DEFINED CVSROOT)
  set(CVSROOT ":pserver:anonymous:cmake@www.cmake.org:/cvsroot/CMake")
endif()

Bill Hoffman's avatar
Bill Hoffman committed
5
6
get_filename_component(SCRIPT_PATH "${CMAKE_CURRENT_LIST_FILE}" PATH)

Bill Hoffman's avatar
Bill Hoffman committed
7
8
9
10
# default to self extracting tgz, tgz, and tar.Z
if(NOT DEFINED CPACK_BINARY_GENERATORS)
  set(CPACK_BINARY_GENERATORS "STGZ TGZ TZ")
endif(NOT DEFINED CPACK_BINARY_GENERATORS)
Andy Cedilnik's avatar
Andy Cedilnik committed
11
12
13
if(DEFINED EXTRA_COPY)
  set(HAS_EXTRA_COPY 1)
endif(DEFINED EXTRA_COPY)
14
15
16
if(NOT DEFINED CMAKE_RELEASE_DIRECTORY)
  set(CMAKE_RELEASE_DIRECTORY "~/CMakeReleaseDirectory")
endif(NOT DEFINED CMAKE_RELEASE_DIRECTORY)
Bill Hoffman's avatar
Bill Hoffman committed
17
18
19
if(NOT DEFINED SCRIPT_NAME)
  set(SCRIPT_NAME "${HOST}")
endif(NOT DEFINED SCRIPT_NAME)
20
21
22
if(NOT DEFINED MAKE_PROGRAM)
  message(FATAL_ERROR "MAKE_PROGRAM must be set")
endif(NOT DEFINED MAKE_PROGRAM)
Bill Hoffman's avatar
Bill Hoffman committed
23
if(NOT DEFINED MAKE)
24
  set(MAKE "${MAKE_PROGRAM}")
Bill Hoffman's avatar
Bill Hoffman committed
25
endif(NOT DEFINED MAKE)
Bill Hoffman's avatar
Bill Hoffman committed
26
27
28
if(NOT DEFINED RUN_SHELL)
  set(RUN_SHELL "/bin/sh")
endif(NOT DEFINED RUN_SHELL)
29
30
31
if(NOT DEFINED PROCESSORS)
  set(PROCESSORS 1)
endif(NOT DEFINED PROCESSORS)
32
33
34
if(NOT DEFINED CMAKE_CREATE_VERSION)
  message(FATAL_ERROR "CMAKE_CREATE_VERSION not defined")
endif(NOT DEFINED CMAKE_CREATE_VERSION)
Bill Hoffman's avatar
Bill Hoffman committed
35
36
37
38
if(NOT DEFINED CVS_COMMAND)
  set(CVS_COMMAND cvs)
endif(NOT DEFINED CVS_COMMAND)

39
if("${CMAKE_CREATE_VERSION}" STREQUAL "CVS")
Bill Hoffman's avatar
Bill Hoffman committed
40
  set( CMAKE_CHECKOUT "${CVS_COMMAND} -q -z3 -d ${CVSROOT} export -D now ")
41
42
43
44
  set( CMAKE_CREATE_VERSION "CurrentCVS")
else("${CMAKE_CREATE_VERSION}" STREQUAL "CVS")
  set( CMAKE_CHECKOUT "${CVS_COMMAND} -q -z3 -d ${CVSROOT} export -r ${CMAKE_CREATE_VERSION} ")
endif("${CMAKE_CREATE_VERSION}" STREQUAL "CVS")
Bill Hoffman's avatar
Bill Hoffman committed
45

Bill Hoffman's avatar
Bill Hoffman committed
46
if(NOT DEFINED FINAL_PATH )
47
  set(FINAL_PATH ${CMAKE_RELEASE_DIRECTORY}/${CMAKE_CREATE_VERSION}-build)
Bill Hoffman's avatar
Bill Hoffman committed
48
49
endif(NOT DEFINED FINAL_PATH )

50
51
52
53
54
55
56
if(NOT HOST)
  message(FATAL_ERROR "HOST must be specified with -DHOST=host")
endif(NOT HOST)
if(NOT DEFINED MAKE)
  message(FATAL_ERROR "MAKE must be specified with -DMAKE=\"make -j2\"")
endif(NOT DEFINED MAKE)
  
57
message("Creating CMake release ${CMAKE_CREATE_VERSION} on ${HOST} with parallel = ${PROCESSORS}")
58
59
60
61

# define a macro to run a remote command
macro(remote_command comment command)
  message("${comment}")
Bill Hoffman's avatar
Bill Hoffman committed
62
63
64
65
66
67
68
  if(${ARGC} GREATER 2)
    message("ssh ${HOST} ${EXTRA_HOP} ${command}")
    execute_process(COMMAND ssh ${HOST} ${EXTRA_HOP} ${command} RESULT_VARIABLE result INPUT_FILE ${ARGV2})
  else(${ARGC} GREATER 2)
    message("ssh ${HOST} ${EXTRA_HOP} ${command}") 
    execute_process(COMMAND ssh ${HOST} ${EXTRA_HOP} ${command} RESULT_VARIABLE result) 
  endif(${ARGC} GREATER 2)
69
70
71
72
73
  if(${result} GREATER 0)
    message(FATAL_ERROR "Error running command: ${command}, return value = ${result}")
  endif(${result} GREATER 0)
endmacro(remote_command)

74
# set this so configure file will work from script mode
Bill Hoffman's avatar
Bill Hoffman committed
75
set(CMAKE_BACKWARDS_COMPATIBILITY 2.4)
76
# create the script specific for the given host
Bill Hoffman's avatar
Bill Hoffman committed
77
78
set(SCRIPT_FILE release_cmake-${SCRIPT_NAME}.sh)
configure_file(${SCRIPT_PATH}/release_cmake.sh.in ${SCRIPT_FILE} @ONLY)
Bill Hoffman's avatar
Bill Hoffman committed
79

Bill Hoffman's avatar
Bill Hoffman committed
80
81
# run the script by starting a shell on the remote machine
# then using the script file as input to the shell
82
83
84
85
86
87
IF(RUN_LOCAL)
  message(FATAL_ERROR "run this command: ${RUN_SHELL} ${SCRIPT_FILE}")
ELSE(RUN_LOCAL)
  remote_command("run release_cmake-${HOST}.sh on server"
    "${RUN_SHELL}" ${SCRIPT_FILE})
ENDIF(RUN_LOCAL)
Bill Hoffman's avatar
Bill Hoffman committed
88

Bill Hoffman's avatar
Bill Hoffman committed
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# now figure out which types of packages were created 
set(generators ${CPACK_BINARY_GENERATORS} ${CPACK_SOURCE_GENERATORS})
separate_arguments(generators)
foreach(gen ${generators})
  if("${gen}" STREQUAL "TGZ")
    set(SUFFIXES ${SUFFIXES} "*.tar.gz")
  endif("${gen}" STREQUAL "TGZ")
  if("${gen}" STREQUAL "STGZ")
    set(SUFFIXES ${SUFFIXES} "*.sh")
  endif("${gen}" STREQUAL "STGZ")
  if("${gen}" STREQUAL "PackageMaker")
    set(SUFFIXES ${SUFFIXES} "*.dmg")
  endif("${gen}" STREQUAL "PackageMaker")
  if("${gen}" STREQUAL "TBZ2")
    set(SUFFIXES ${SUFFIXES} "*.tar.bz2")
  endif("${gen}" STREQUAL "TBZ2")
105
106
  if("${gen}" MATCHES "Cygwin")
    set(SUFFIXES ${SUFFIXES} "*.tar.bz2")
107
108
    set(extra_files setup.hint)
  endif("${gen}" MATCHES "Cygwin")
Bill Hoffman's avatar
Bill Hoffman committed
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
  if("${gen}" STREQUAL "TZ")
    set(SUFFIXES ${SUFFIXES} "*.tar.Z")
  endif("${gen}" STREQUAL "TZ")
  if("${gen}" STREQUAL "ZIP")
    set(SUFFIXES ${SUFFIXES} "*.zip")
  endif("${gen}" STREQUAL "ZIP")
  if("${gen}" STREQUAL "NSIS")
    set(SUFFIXES ${SUFFIXES} "*.exe")
  endif("${gen}" STREQUAL "NSIS")
endforeach(gen)
# copy all the files over from the remote machine
set(PROJECT_PREFIX cmake-)
foreach(suffix ${SUFFIXES})
  message("scp ${HOST}:${FINAL_PATH}/${PROJECT_PREFIX}${suffix} .")
  execute_process(COMMAND 
    scp ${HOST}:${FINAL_PATH}/${PROJECT_PREFIX}${suffix} .
    RESULT_VARIABLE result)   
  if(${result} GREATER 0)
    message("error getting file back scp ${HOST}:${FINAL_PATH}/${PROJECT_PREFIX}${suffix} .")
  endif(${result} GREATER 0)
endforeach(suffix)
130
131
132
133
134
135
136
137
138
139
140
141
142

# if there are extra files to copy get them as well
if(extra_files)
  foreach(f ${extra_files})
    message("scp ${HOST}:${FINAL_PATH}/${f} .")
    execute_process(COMMAND 
      scp ${HOST}:${FINAL_PATH}/${f} .
      RESULT_VARIABLE result)
    if(${result} GREATER 0)
      message("error getting file back scp ${HOST}:${FINAL_PATH}/${f} .")
    endif(${result} GREATER 0)
  endforeach(f)
endif(extra_files)