From: Erwin Janssen Date: Tue, 20 Dec 2016 19:38:45 +0000 (+0100) Subject: CMake: Add Graphviz version information X-Git-Tag: 2.42.0~213^2^2~30 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a5d8a8bd203b2d8a66b1b4940af46e3f9b8c0018;p=graphviz CMake: Add Graphviz version information 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. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ce651d04..1ee91e3fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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)