Add custom targets to generate tarballs with stored versions
[oonf.git] / cmake / generate_archive.cmake
1 #!/bin/cmake
2 SET(VERSIONFILE version.cmake)
3
4 # look for git executable
5 SET(found_git false) 
6 find_program(found_git git)
7
8 IF(${found_git} STREQUAL "found_git-NOTFOUND")
9   message (FATAL "Git executable not found")
10 ENDIF()
11
12 SET(found_tar false) 
13 find_program(found_tar tar)
14
15 IF(${found_tar} STREQUAL "found_tar-NOTFOUND")
16   message (FATAL "Tar executable not found")
17 ENDIF()
18
19 # add fixed version data
20 FILE (COPY ${BINARY}/${VERSIONFILE} DESTINATION ${SOURCE})
21
22 # add it to git and stash it away
23 execute_process(COMMAND git add ${SOURCE}/${VERSIONFILE} WORKING_DIRECTORY ${SOURCE})
24 execute_process(COMMAND git stash create OUTPUT_VARIABLE COMMIT WORKING_DIRECTORY ${SOURCE} OUTPUT_STRIP_TRAILING_WHITESPACE)
25
26 # generate archive
27 execute_process(COMMAND git archive --prefix=oonf_${VERSION}/ -o ${SOURCE}/oonf_${VERSION}.${FORMAT} ${COMMIT} WORKING_DIRECTORY ${SOURCE})
28
29 # remove version file
30 FILE (REMOVE ${SOURCE}/${VERSIONFILE})
31 execute_process(COMMAND git rm --quiet ${SOURCE}/${VERSIONFILE} WORKING_DIRECTORY ${SOURCE})