]> granicus.if.org Git - graphviz/commitdiff
CMake: Add Graphviz version information
authorErwin Janssen <erwinjanssen@outlook.com>
Tue, 20 Dec 2016 19:38:45 +0000 (20:38 +0100)
committerErwin Janssen <erwinjanssen@outlook.com>
Thu, 19 Jan 2017 11:53:48 +0000 (12:53 +0100)
Adds version numbers to the main CMakeLists.txt. The build version is set
to the date and time of the most recent commit, similar to the Autotools
build.

CMakeLists.txt

index 4ce651d048db189751980ac74ef6da72c0bc234e..1ee91e3fe1701cc21ab7dc8ae81e295163350d42 100644 (file)
@@ -1,5 +1,31 @@
 cmake_minimum_required (VERSION 2.8 FATAL_ERROR)
 
+# Build dependencies
+# ==================
+find_package(Git REQUIRED)
+
+# General project information
+# ===========================
 project (Graphviz)
 
+set(GRAPHVIZ_VERSION_MAJROR 2)
+set(GRAPHVIZ_VERSION_MINOR 39)
+
+# Set GRAPHVIZ_VERSION_BUILD to time of last commit, or to 0 if that fails.
+execute_process(
+    COMMAND           "${GIT_EXECUTABLE}" log -n 1 --format=%cd --date=format:%Y%m%d.%H%M
+    WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+    RESULT_VARIABLE   git_result
+    OUTPUT_VARIABLE   GRAPHVIZ_VERSION_BUILD
+    ERROR_VARIABLE    git_error
+    OUTPUT_STRIP_TRAILING_WHITESPACE
+    ERROR_STRIP_TRAILING_WHITESPACE
+)
+if(NOT git_result EQUAL 0)
+    message(WARNING "Failed to set build version: ${git_error}")
+    set(GRAPHVIZ_VERSION_BUILD 0)
+endif()
+
+message(STATUS "Graphviz version: ${GRAPHVIZ_VERSION_MAJROR}.${GRAPHVIZ_VERSION_MINOR}.${GRAPHVIZ_VERSION_BUILD}")
+
 add_subdirectory(lib)