summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-06-24 17:45:50 +0200
committerFlorent Le Coz <louiz@louiz.org>2014-06-24 17:48:31 +0200
commit2cf64e10b51579d0bb1d270f82c4fdebf92a6ce6 (patch)
treef944fdade8ba10075fe03ff159bdc01b0eb2deb5
parent39175e1ad6fe6507bbe2874c6ce413cbe9c3366e (diff)
downloadbiboumi-2cf64e10b51579d0bb1d270f82c4fdebf92a6ce6.tar.gz
biboumi-2cf64e10b51579d0bb1d270f82c4fdebf92a6ce6.tar.bz2
biboumi-2cf64e10b51579d0bb1d270f82c4fdebf92a6ce6.tar.xz
biboumi-2cf64e10b51579d0bb1d270f82c4fdebf92a6ce6.zip
Provide a make dist target
-rw-r--r--CMakeLists.txt21
1 files changed, 18 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 947e8fe..a33fffe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,16 +27,22 @@ find_package(Botan)
#
## Get the software version
#
-if(${PROJECT_NAME}_VERSION_SUFFIX MATCHES "~dev")
+set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR})
+if(${PROJECT_NAME}_VERSION_SUFFIX MATCHES ".+")
+ set(ARCHIVE_NAME ${ARCHIVE_NAME}-${${PROJECT_NAME}_VERSION_SUFFIX})
+endif()
+
+if(${PROJECT_NAME}_VERSION_SUFFIX MATCHES "^~dev$")
# If we are on a dev version, append the hash of the current git HEAD to
# the version
include(FindGit)
- if(GIT_FOUND)
+ if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
execute_process(COMMAND git --git-dir=${CMAKE_SOURCE_DIR}/.git rev-parse --short HEAD
OUTPUT_VARIABLE GIT_REVISION
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(GIT_REVISION)
set(${PROJECT_NAME}_VERSION_SUFFIX "${${PROJECT_NAME}_VERSION_SUFFIX} (${GIT_REVISION})")
+ set(ARCHIVE_NAME ${ARCHIVE_NAME}-${GIT_REVISION})
endif()
endif()
endif()
@@ -193,4 +199,13 @@ install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin)
if(WITH_DOC)
install(FILES ${MAN_PAGE} DESTINATION man/man1)
-endif() \ No newline at end of file
+endif()
+
+#
+## Dist target
+## Generate a release tarball from the git sources
+#
+add_custom_target(dist
+ COMMAND git archive --prefix=${ARCHIVE_NAME}/ --format=tar HEAD
+ | xz > ${CMAKE_CURRENT_BINARY_DIR}/${ARCHIVE_NAME}.tar.xz
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) \ No newline at end of file