From 3066c08a0db54729af639e128b4e9fe4fdc8c008 Mon Sep 17 00:00:00 2001 From: Hector Martin Date: Sun, 11 Apr 2010 17:11:08 +0200 Subject: Add automatic git versioning and tag for archives --- CMakeLists.txt | 12 +++++++++--- Modules/VersionTag.cmake | 13 +++++++++++++ Modules/describe.sh | 17 +++++++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 Modules/VersionTag.cmake create mode 100755 Modules/describe.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index fb99b4c..7dbeec1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,16 @@ PROJECT(usbmuxd) -set(USBMUXD_VERSION "1.0.0") -set(LIBUSBMUXD_VERSION "${USBMUXD_VERSION}") +cmake_minimum_required(VERSION 2.6) + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/Modules/") + +include(VersionTag) + +set(USBMUXD_VERSION "${VERSION_TAG}") +set(LIBUSBMUXD_VERSION "${VERSION_TAG}") set(LIBUSBMUXD_SOVERSION "1") -cmake_minimum_required(VERSION 2.6) +message("-- Configuring usbmuxd v${VERSION_TAG}") if(NOT DEFINED LIB_SUFFIX) if(CMAKE_SIZEOF_VOID_P EQUAL 8) diff --git a/Modules/VersionTag.cmake b/Modules/VersionTag.cmake new file mode 100644 index 0000000..682ab3e --- /dev/null +++ b/Modules/VersionTag.cmake @@ -0,0 +1,13 @@ +execute_process( + COMMAND "sh" "${CMAKE_SOURCE_DIR}/Modules/describe.sh" + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + OUTPUT_VARIABLE DESCRIBE + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +if(DESCRIBE STREQUAL "") + set (VERSION_TAG "UNKNOWN") +else() + string(REGEX REPLACE "^v" "" VERSION_TAG "${DESCRIBE}") +endif() + diff --git a/Modules/describe.sh b/Modules/describe.sh new file mode 100755 index 0000000..91730b8 --- /dev/null +++ b/Modules/describe.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# Check for git and a git repo. +if head=`git rev-parse --verify HEAD 2>/dev/null`; then + echo -n `git describe` + + # Are there uncommitted changes? + git update-index --refresh --unmerged > /dev/null + git diff-index --quiet HEAD || echo -n -dirty +else +# Check for version tag + if [ -e version.tag ]; then + echo -n `cat version.tag` + fi +fi + +echo -- cgit v1.1-32-gdbae