summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-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