endif()
# ============================ Set Graphviz version ============================
-set(GRAPHVIZ_VERSION_MAJOR 2)
-set(GRAPHVIZ_VERSION_MINOR 45)
-set(GRAPHVIZ_VERSION_PATCH 0)
-set(GRAPHVIZ_VERSION_STRING "${GRAPHVIZ_VERSION_MAJOR}.${GRAPHVIZ_VERSION_MINOR}.${GRAPHVIZ_VERSION_PATCH}")
configure_file(graphviz_version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/graphviz_version.h @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/graphviz_version.h DESTINATION ${HEADER_INSTALL_DIR})
+execute_process(
+ COMMAND grep "^m4_define.*graphviz_version_major" autogen.sh
+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+ RESULT_VARIABLE major_version_result
+ OUTPUT_VARIABLE AUTOGEN_MAJOR_VERSION_LINE
+ ERROR_VARIABLE major_version_error
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_STRIP_TRAILING_WHITESPACE
+)
+if (major_version_result EQUAL 0)
+ string(REGEX REPLACE ".*\\[([0-9]*)\\].*"
+ "\\1" GRAPHVIZ_VERSION_MAJOR
+ ${AUTOGEN_MAJOR_VERSION_LINE})
+else()
+ message(FATAL_ERROR "Failed to set major version: ${major_version_error}")
+ set(GRAPHVIZ_VERSION_MAJOR {$major_version_result})
+endif()
+
+execute_process(
+ COMMAND grep "^m4_define.*graphviz_version_minor" autogen.sh
+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+ RESULT_VARIABLE minor_version_result
+ OUTPUT_VARIABLE AUTOGEN_MINOR_VERSION_LINE
+ ERROR_VARIABLE minor_version_error
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_STRIP_TRAILING_WHITESPACE
+)
+if (minor_version_result EQUAL 0)
+ string(REGEX REPLACE ".*\\[([0-9]*)\\].*"
+ "\\1" GRAPHVIZ_VERSION_MINOR
+ ${AUTOGEN_MINOR_VERSION_LINE})
+else()
+ message(FATAL_ERROR "Failed to set minor version: ${minor_version_error}")
+ set(GRAPHVIZ_VERSION_MINOR {$minor_version_result})
+endif()
+
+execute_process(
+ COMMAND grep "^m4_define.*graphviz_version_micro" autogen.sh
+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+ RESULT_VARIABLE patch_version_result
+ OUTPUT_VARIABLE AUTOGEN_PATCH_VERSION_LINE
+ ERROR_VARIABLE patch_version_error
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_STRIP_TRAILING_WHITESPACE
+)
+if (patch_version_result EQUAL 0)
+ string(REGEX REPLACE ".*,\\[(.*)\\].*"
+ "\\1" GRAPHVIZ_VERSION_PATCH
+ ${AUTOGEN_PATCH_VERSION_LINE})
+else()
+ message(FATAL_ERROR "Failed to set patch version: ${patch_version_error}")
+ set(GRAPHVIZ_VERSION_PATCH {$patch_version_result})
+endif()
+
# 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
set(GRAPHVIZ_VERSION_BUILD 0)
endif()
+if (GRAPHVIZ_VERSION_PATCH STREQUAL "\$GRAPHVIZ_VERSION_DATE")
+ set(GRAPHVIZ_VERSION_PATCH ${GRAPHVIZ_VERSION_BUILD})
+endif()
+
+set(GRAPHVIZ_VERSION_STRING "${GRAPHVIZ_VERSION_MAJOR}.${GRAPHVIZ_VERSION_MINOR}.${GRAPHVIZ_VERSION_PATCH}")
set(GRAPHVIZ_VERSION_FULL "${GRAPHVIZ_VERSION_MAJOR}.${GRAPHVIZ_VERSION_MINOR}.${GRAPHVIZ_VERSION_BUILD}")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/builddate.h "#define BUILDDATE \"${GRAPHVIZ_VERSION_BUILD}\"")