~alan-griffiths/compiz-core/fix-leaks

« back to all changes in this revision

Viewing changes to cmake/CompizCommon.cmake

  • Committer: smspillaz
  • Date: 2012-01-29 12:40:47 UTC
  • mfrom: (2961.1.6 trunk)
  • Revision ID: sam.spilsbury@canonical.com-20120129124047-mf9ynaxolxm7ptw9
Cross merge from trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAGS}")
70
70
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS}")
71
71
 
72
 
if (IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.git)
73
 
    set(IS_GIT_REPO 1)
74
 
else (IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.git)
75
 
    set(IS_GIT_REPO 0)
76
 
endif (IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.git)
77
 
 
78
 
if (EXISTS ${CMAKE_SOURCE_DIR}/.gitmodules)
79
 
    set(IS_GIT_SUBMODULES_REPO 1)
80
 
else (EXISTS ${CMAKE_SOURCE_DIR}/.gitmodules)
81
 
    set(IS_GIT_SUBMODULES_REPO 0)
82
 
endif (EXISTS ${CMAKE_SOURCE_DIR}/.gitmodules)
83
 
 
84
72
if (IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.bzr)
85
73
    set(IS_BZR_REPO 1)
86
74
elseif (IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.bzr)
103
91
 
104
92
macro (compiz_add_git_dist)
105
93
 
106
 
        # Try to use the git and bzr inbuilt functions for generating
107
 
        # archives first, otherwise do it manually
108
 
        if (${IS_GIT_REPO})
109
 
 
110
 
                if (${IS_GIT_SUBMODULES_REPO})
111
 
                        find_program (GIT_ARCHIVE_ALL git-archive-all.sh)
112
 
 
113
 
                        if (NOT (${GIT_ARCHIVE_ALL} STREQUAL "GIT_ARCHIVE_ALL-NOTFOUND"))
114
 
                                add_custom_target (dist ${GIT_ARCHIVE_ALL} --prefix ${CMAKE_PROJECT_NAME}-${VERSION}/ ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}-${VERSION}.tar
115
 
                                                   COMMAND bzip2 ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}-${VERSION}.tar
116
 
                                                   WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
117
 
                                                   COMMENT "Creating bz2 archive")
118
 
                        else (NOT (${GIT_ARCHIVE_ALL} STREQUAL "GIT_ARCHIVE_ALL-NOTFOUND"))
119
 
                                add_custom_target (dist
120
 
                                                   COMMAND echo "[WARNING]: git-archive-all.sh is needed to make releases of git submodules, get it from https://github.com/meitar/git-archive-all.sh.git and install it into your PATH"
121
 
                                                   COMMENT "Creating bz2 archive"
122
 
                                                   WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
123
 
                                message ("[WARNING]: git-archive-all.sh is needed to make releases of git submodules, get it from https://github.com/meitar/git-archive-all.sh.git and install it into your PATH")
124
 
                        endif (NOT (${GIT_ARCHIVE_ALL} STREQUAL "GIT_ARCHIVE_ALL-NOTFOUND"))
125
 
                else (${IS_GIT_SUBMODULES_REPO})
126
 
                        add_custom_target (dist git archive --format=tar --prefix ${CMAKE_PROJECT_NAME}-${VERSION}/ -o ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}-${VERSION}.tar HEAD
127
 
                                                   COMMAND bzip2 ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}-${VERSION}.tar
128
 
                                                   WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
129
 
                                                   COMMENT "Creating bz2 archive")
130
 
                endif (${IS_GIT_SUBMODULES_REPO})
131
 
        else (${IS_GIT_REPO})
132
 
                if (${IS_BZR_REPO})
133
 
                        add_custom_target (dist
134
 
                                           COMMAND bzr export --root=${CMAKE_PROJECT_NAME}-${VERSION} ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}-${VERSION}.tar.bz2
135
 
                                           WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
136
 
                else (${IS_BZR_REPO})
137
 
                        add_custom_target (dist)
138
 
                        #add_custom_target (dist 
139
 
                        #                  COMMAND tar -cvf ${CMAKE_SOURCE_DIR} | bzip2 > ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}-${VERSION}.tar.bz2
140
 
                        #                  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/../)
141
 
                endif (${IS_BZR_REPO})
142
 
        endif (${IS_GIT_REPO})
 
94
        add_custom_target (dist
 
95
                           COMMAND bzr export --root=${CMAKE_PROJECT_NAME}-${VERSION} ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}-${VERSION}.tar.bz2
 
96
                           WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
143
97
 
144
98
endmacro ()
145
99
 
170
124
        add_custom_target (release-signoff)
171
125
 
172
126
        add_custom_target (release-update-working-tree
173
 
                           COMMAND cp NEWS ${CMAKE_SOURCE_DIR} && git add ${CMAKE_SOURCE_DIR}/NEWS &&
174
 
                                   cp AUTHORS ${CMAKE_SOURCE_DIR} && git add ${CMAKE_SOURCE_DIR}/AUTHORS
 
127
                           COMMAND cp NEWS ${CMAKE_SOURCE_DIR} && bzr add ${CMAKE_SOURCE_DIR}/NEWS &&
 
128
                                   cp AUTHORS ${CMAKE_SOURCE_DIR} && bzr add ${CMAKE_SOURCE_DIR}/AUTHORS
175
129
                           COMMENT "Updating working tree"
176
130
                           WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) 
177
131
 
178
 
        if (${IS_GIT_REPO})
179
 
                add_custom_target (release-commits
180
 
                                   COMMAND git commit -a -m "Update NEWS for ${VERSION}"
181
 
                                   COMMENT "Release Commit"
182
 
                                   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
183
 
                add_custom_target (release-tags
184
 
                                   COMMAND git tag -u $ENV{RELEASE_KEY} compiz-${VERSION} HEAD -m "Compiz ${VERSION} Release"
185
 
                                   COMMENT "Release Tags"
186
 
                                   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
187
 
                add_custom_target (release-branch
188
 
                                   COMMAND git checkout -b compiz-${VERSION}-series && 
189
 
                                   touch RELEASED && 
190
 
                                   git add RELEASED &&
191
 
                                   cat VERSION > RELEASED &&
192
 
                                   git commit -a -m "Add RELEASED file"
193
 
                                   COMMENT "Release Branch"
194
 
                                   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
195
 
                add_custom_target (release-update-dist
196
 
                                   COMMAND git checkout master &&
197
 
                                   rm ${CMAKE_PROJECT_NAME}-${VERSION}.tar.bz2 &&
198
 
                                   make dist
199
 
                                   COMMENT "Updating bz2 archive"
200
 
                                   WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
201
 
 
202
 
                if (AUTO_VERSION_UPDATE)
203
 
                        add_custom_target (release-version-bump
204
 
                                           COMMAND git checkout master &&
205
 
                                           echo "${AUTO_VERSION_UPDATE}" > VERSION &&
206
 
                                           git add VERSION &&
207
 
                                           git commit VERSION -m "Bump VERSION"
208
 
                                           COMMENT "Bumping VERSION"
209
 
                                           WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
210
 
                else (AUTO_VERSION_UPDATE)
211
 
                        add_custom_target (release-version-bump
212
 
                                           COMMAND git checkout master &&
213
 
                                           $ENV{EDITOR} VERSION &&
214
 
                                           git add VERSION &&           
215
 
                                           git commit VERSION -m "Bump VERSION"
216
 
                                           COMMENT "Bumping VERSION"
217
 
                                           WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
218
 
                endif (AUTO_VERSION_UPDATE)
219
 
 
220
 
        else (${IS_GIT_REPO})
221
 
            add_custom_target (release-commits)
222
 
            add_custom_target (release-tags)
223
 
            add_custom_target (release-branch)
224
 
            add_custom_target (release-update-dist)
225
 
            add_custom_target (release-version-bump)
226
 
 
227
 
        endif (${IS_GIT_REPO})
 
132
        # TODO
 
133
        add_custom_target (release-commits)
 
134
        add_custom_target (release-tags)
 
135
        add_custom_target (release-branch)
 
136
        add_custom_target (release-update-dist)
 
137
        add_custom_target (release-version-bump)
228
138
 
229
139
        add_custom_target (release-sign-tarballs
230
140
                   COMMAND gpg --armor --sign --detach-sig ${CMAKE_PROJECT_NAME}-${VERSION}.tar.bz2
248
158
        add_dependencies (release-sha1-tarballs release-sign-tarballs)
249
159
        add_dependencies (release-sign-sha1-tarballs release-sha1-tarballs)
250
160
 
251
 
        # This means that releasing needs to be done from a git repo for now
252
 
        # But that's fine
253
161
        add_dependencies (release-signoff release-sign-sha1-tarballs)
254
162
 
255
163
        # Actually pushes the release
256
 
        if (${IS_GIT_REPO})
257
 
                add_custom_target (push-master
258
 
                                   COMMAND git push origin master
259
 
                                   COMMENT "Pushing to master"
260
 
                                   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
261
 
                add_custom_target (push-release-branch
262
 
                                   COMMAND git push origin compiz-${VERSION}-series
263
 
                                   COMMENT "Pushing to compiz-${VERSION}-series"
264
 
                                   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
265
 
                add_custom_target (push-tag
266
 
                                   COMMAND git push origin compiz-${VERSION}
267
 
                                   COMMENT "Pushing tag compiz-${VERSION}"
268
 
                                   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
269
 
        else (${IS_GIT_REPO})
270
 
                add_custom_target (push-master)
271
 
                add_custom_target (push-release-branch)
272
 
                add_custom_target (push-tag)
273
 
        endif (${IS_GIT_REPO})
 
164
        add_custom_target (push-master)
 
165
        add_custom_target (push-release-branch)
 
166
        add_custom_target (push-tag)
274
167
 
275
168
        add_custom_target (release-push)
276
169
 
279
172
        add_dependencies (push-tag push-master)
280
173
 
281
174
        # Push the tarball to releases.compiz.org
282
 
        set (COMPIZ_RELEASE_UPLOAD_HOST         releases.compiz.org)
283
 
        set (COMPIZ_RELEASE_UPLOAD_BASE         /home/releases)
284
 
        set (COMPIZ_RELEASE_UPLOAD_DIR_VERSION  ${COMPIZ_RELEASE_UPLOAD_BASE}/${VERSION}/)
285
 
        set (COMPIZ_RELEASE_UPLOAD_DIR_COMPONENT ${COMPIZ_RELEASE_UPLOAD_BASE}/components/${CMAKE_PROJECT_NAME})
286
 
 
287
 
        add_custom_target (release-upload-version
288
 
                           COMMAND ssh $ENV{USER}@${COMPIZ_RELEASE_UPLOAD_HOST} "mkdir -p ${COMPIZ_RELEASE_UPLOAD_BASE}/${VERSION}" && scp ${CMAKE_PROJECT_NAME}-${VERSION}.tar.bz2 $ENV{USER}@${COMPIZ_RELEASE_UPLOAD_HOST}:${COMPIZ_RELEASE_UPLOAD_DIR_VERSION}
289
 
                           COMMENT "Uploading ${CMAKE_PROJECT_NAME}-${VERSION} to ${VERSION}"
290
 
                           WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
291
175
 
292
176
        # Does nothing for now
293
177
        add_custom_target (release-upload-component)
294
 
        #add_custom_target (release-upload-component
295
 
        #                  COMMAND ssh $ENV{USER}@${COMPIZ_RELEASE_UPLOAD_HOST} "mkdir -p ${COMPIZ_RELEASE_UPLOAD_BASE}/${VERSION}" && scp ${CMAKE_PROJECT_NAME}-${VERSION}.tar.bz2 ${CMAKE_PROJECT_NAME}-${VERSION}.tar.bz2.asc ${CMAKE_PROJECT_NAME}-${VERSION}.tar.bz2.sha1 ${CMAKE_PROJECT_NAME}-${VERSION}.tar.bz2.sha1.asc $ENV{USER}@${COMPIZ_RELEASE_UPLOAD_HOST}:${COMPIZ_RELEASE_UPLOAD_BASE_DIR_COMPONENT}
296
 
        #                  COMMENT "Uploading ${CMAKE_PROJECT_NAME}-${VERSION} to ${CMAKE_PROJECT_NAME}/${VERSION}"
297
 
        #                  WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
298
 
 
299
178
        add_custom_target (release-upload)
300
179
 
301
180
        add_dependencies (release-upload-component release-upload-version)
315
194
                file (WRITE ${CMAKE_SOURCE_DIR}/.AUTHORS.sed "")
316
195
        endif (NOT EXISTS ${CMAKE_SOURCE_DIR}/.AUTHORS.sed)
317
196
 
318
 
        if (${IS_GIT_REPO})
319
 
                find_program (GEN_GIT_LOG gen-git-log.sh)
320
 
                add_custom_target (authors
321
 
                                   COMMAND git shortlog -se | cut -c8- | sed -r -f ${CMAKE_SOURCE_DIR}/.AUTHORS.sed  | sort -u  > AUTHORS
322
 
                                   COMMENT "Generating AUTHORS"
323
 
                                   WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
324
 
 
325
 
                if (AUTO_NEWS_UPDATE)
326
 
                        add_custom_target (news-header echo > ${CMAKE_BINARY_DIR}/NEWS.update
327
 
                                           COMMAND echo 'Release ${VERSION} ('`date +%Y-%m-%d`' '`git config user.name`' <'`git config user.email`'>)' > ${CMAKE_BINARY_DIR}/NEWS.update && seq -s "=" `cat ${CMAKE_BINARY_DIR}/NEWS.update | wc -c` | sed 's/[0-9]//g' >> ${CMAKE_BINARY_DIR}/NEWS.update && echo '${AUTO_NEWS_UPDATE}' >> ${CMAKE_BINARY_DIR}/NEWS.update && echo >> ${CMAKE_BINARY_DIR}/NEWS.update
328
 
                                           COMMENT "Generating NEWS Header"
329
 
                                           WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
330
 
                else (AUTO_NEWS_UPDATE)
331
 
                        add_custom_target (news-header echo > ${CMAKE_BINARY_DIR}/NEWS.update
332
 
                                           COMMAND echo 'Release ${VERSION} ('`date +%Y-%m-%d`' '`git config user.name`' <'`git config user.email`'>)' > ${CMAKE_BINARY_DIR}/NEWS.update && seq -s "=" `cat ${CMAKE_BINARY_DIR}/NEWS.update | wc -c` | sed 's/[0-9]//g' >> ${CMAKE_BINARY_DIR}/NEWS.update && $ENV{EDITOR} ${CMAKE_BINARY_DIR}/NEWS.update && echo >> ${CMAKE_BINARY_DIR}/NEWS.update
333
 
                                           COMMENT "Generating NEWS Header"
334
 
                                           WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
335
 
                endif (AUTO_NEWS_UPDATE)
336
 
 
337
 
        else (${IS_GIT_REPO})
338
 
                if (${IS_BZR_REPO})
339
 
                        add_custom_target (authors
340
 
                                           COMMAND bzr log --long --levels=0 | grep -e "^\\s*author:" -e "^\\s*committer:" | cut -d ":" -f 2 | sed -r -f ${CMAKE_SOURCE_DIR}/.AUTHORS.sed  | sort -u > AUTHORS
341
 
                                           COMMENT "Generating AUTHORS")
342
 
 
343
 
                        if (AUTO_NEWS_UPDATE)
344
 
 
345
 
                                add_custom_target (news-header echo > ${CMAKE_BINARY_DIR}/NEWS.update
346
 
                                                   COMMAND echo 'Release ${VERSION} ('`date +%Y-%m-%d`' '`bzr config email`')' > ${CMAKE_BINARY_DIR}/NEWS.update && seq -s "=" `cat ${CMAKE_BINARY_DIR}/NEWS.update | wc -c` | sed 's/[0-9]//g' >> ${CMAKE_BINARY_DIR}/NEWS.update && echo '${AUTO_NEWS_UPDATE}' >> ${CMAKE_BINARY_DIR}/NEWS.update && echo >> ${CMAKE_BINARY_DIR}/NEWS.update
347
 
                                                   COMMENT "Generating NEWS Header"
348
 
                                                   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
349
 
                        else (AUTO_NEWS_UPDATE)
350
 
                                add_custom_target (news-header echo > ${CMAKE_BINARY_DIR}/NEWS.update
351
 
                                                   COMMAND echo 'Release ${VERSION} ('`date +%Y-%m-%d`' '`bzr config email`')' > ${CMAKE_BINARY_DIR}/NEWS.update && seq -s "=" `cat ${CMAKE_BINARY_DIR}/NEWS.update | wc -c` | sed 's/[0-9]//g' >> ${CMAKE_BINARY_DIR}/NEWS.update && $ENV{EDITOR} ${CMAKE_BINARY_DIR}/NEWS.update && echo >> ${CMAKE_BINARY_DIR}/NEWS.update
352
 
                                                   COMMENT "Generating NEWS Header"
353
 
                                                   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
354
 
                        endif (AUTO_NEWS_UPDATE)
355
 
 
356
 
                else (${IS_BZR_REPO})
357
 
                        add_custom_target (authors)
358
 
                        add_custom_target (news-header)
359
 
                endif (${IS_BZR_REPO})
360
 
        endif (${IS_GIT_REPO})
 
197
        add_custom_target (authors
 
198
                           COMMAND bzr log --long --levels=0 | grep -e "^\\s*author:" -e "^\\s*committer:" | cut -d ":" -f 2 | sed -r -f ${CMAKE_SOURCE_DIR}/.AUTHORS.sed  | sort -u > AUTHORS
 
199
                           COMMENT "Generating AUTHORS")
 
200
 
 
201
        if (AUTO_NEWS_UPDATE)
 
202
 
 
203
                add_custom_target (news-header echo > ${CMAKE_BINARY_DIR}/NEWS.update
 
204
                                   COMMAND echo 'Release ${VERSION} ('`date +%Y-%m-%d`' '`bzr config email`')' > ${CMAKE_BINARY_DIR}/NEWS.update && seq -s "=" `cat ${CMAKE_BINARY_DIR}/NEWS.update | wc -c` | sed 's/[0-9]//g' >> ${CMAKE_BINARY_DIR}/NEWS.update && echo '${AUTO_NEWS_UPDATE}' >> ${CMAKE_BINARY_DIR}/NEWS.update && echo >> ${CMAKE_BINARY_DIR}/NEWS.update
 
205
                                   COMMENT "Generating NEWS Header"
 
206
                                   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
 
207
        else (AUTO_NEWS_UPDATE)
 
208
                add_custom_target (news-header echo > ${CMAKE_BINARY_DIR}/NEWS.update
 
209
                                   COMMAND echo 'Release ${VERSION} ('`date +%Y-%m-%d`' '`bzr config email`')' > ${CMAKE_BINARY_DIR}/NEWS.update && seq -s "=" `cat ${CMAKE_BINARY_DIR}/NEWS.update | wc -c` | sed 's/[0-9]//g' >> ${CMAKE_BINARY_DIR}/NEWS.update && $ENV{EDITOR} ${CMAKE_BINARY_DIR}/NEWS.update && echo >> ${CMAKE_BINARY_DIR}/NEWS.update
 
210
                                   COMMENT "Generating NEWS Header"
 
211
                                   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
 
212
        endif (AUTO_NEWS_UPDATE)
361
213
 
362
214
        add_custom_target (news
363
215
                           COMMAND cat ${CMAKE_SOURCE_DIR}/NEWS > NEWS.old &&