summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authoralbert-github <albert.tests@gmail.com>2019-05-31 18:03:45 (GMT)
committeralbert-github <albert.tests@gmail.com>2019-05-31 18:03:45 (GMT)
commit4ad23e5d18fc294e00844fd8557f8c5dd6254d6e (patch)
tree54add50b60dc75b677dc62afc84aad4014b0d9a2 /cmake
parentfa9dda01e6c013c7fe9be99b21d8bbf3c95c0482 (diff)
downloadDoxygen-4ad23e5d18fc294e00844fd8557f8c5dd6254d6e.zip
Doxygen-4ad23e5d18fc294e00844fd8557f8c5dd6254d6e.tar.gz
Doxygen-4ad23e5d18fc294e00844fd8557f8c5dd6254d6e.tar.bz2
Show git version information
The original version has as features: - getting the git version number for usage in doxygen - making the doxygen version number inclusion dependent on the VERSION file The disadvantage of the chosen methodology was that an extra correction step was necessary, by defining getter methods to retrieve the values this correction can be hidden. The information is coming from different sources: - the VERSION file - the git "repository and build system (when present) Furthermore there are a couple of places where the version information is used (a.o. doxygen and doxywizard executable, though the doxygenwizard was only done "half hearted") The handling of the VERSION file has been made in such a way that it is comparable with the generation of the git version changes. For a better abstraction the version handling is all done in a separate directory.
Diffstat (limited to 'cmake')
-rw-r--r--cmake/doxygen_version.cmake96
1 files changed, 96 insertions, 0 deletions
diff --git a/cmake/doxygen_version.cmake b/cmake/doxygen_version.cmake
new file mode 100644
index 0000000..2433889
--- /dev/null
+++ b/cmake/doxygen_version.cmake
@@ -0,0 +1,96 @@
+# doxygen_version.cmake
+#
+
+# This file defines the functions and targets needed to monitor
+# doxygen VERSION file.
+#
+# The behavior of this script can be modified by defining any of these variables:
+#
+# PRE_CONFIGURE_DOXYGEN_VERSION_FILE (REQUIRED)
+# -- The path to the file that'll be configured.
+#
+# POST_CONFIGURE_DOXYGEN_VERSION_FILE (REQUIRED)
+# -- The path to the configured PRE_CONFIGURE_DOXYGEN_VERSION_FILE.
+#
+# DOXY_STATE_FILE (OPTIONAL)
+# -- The path to the file used to store the doxygen version information.
+#
+# This file is based on git_watcher.cmake
+
+# Short hand for converting paths to absolute.
+macro(PATH_TO_ABSOLUTE var_name)
+ get_filename_component(${var_name} "${${var_name}}" ABSOLUTE)
+endmacro()
+
+# Check that a required variable is set.
+macro(CHECK_REQUIRED_VARIABLE var_name)
+ if(NOT DEFINED ${var_name})
+ message(FATAL_ERROR "The \"${var_name}\" variable must be defined.")
+ endif()
+ PATH_TO_ABSOLUTE(${var_name})
+endmacro()
+
+# Check that an optional variable is set, or, set it to a default value.
+macro(CHECK_OPTIONAL_VARIABLE var_name default_value)
+ if(NOT DEFINED ${var_name})
+ set(${var_name} ${default_value})
+ endif()
+ PATH_TO_ABSOLUTE(${var_name})
+endmacro()
+
+CHECK_REQUIRED_VARIABLE(PRE_CONFIGURE_DOXYGEN_VERSION_FILE)
+CHECK_REQUIRED_VARIABLE(POST_CONFIGURE_DOXYGEN_VERSION_FILE)
+CHECK_OPTIONAL_VARIABLE(DOXY_STATE_FILE "${CMAKE_SOURCE_DIR}/VERSION")
+
+# Function: DoxygenStateChangedAction
+# Description: this function is executed when the
+# doxygen version file has changed.
+function(DoxygenStateChangedAction _state_as_list)
+ # Set variables by index, then configure the file w/ these variables defined.
+ LIST(GET _state_as_list 0 DOXYGEN_VERSION)
+ configure_file("${PRE_CONFIGURE_DOXYGEN_VERSION_FILE}" "${POST_CONFIGURE_DOXYGEN_VERSION_FILE}" @ONLY)
+endfunction()
+
+
+
+# Function: SetupDoxyMonitoring
+# Description: this function sets up custom commands that make the build system
+# check the doxygen version file before every build. If it has
+# changed, then a file is configured.
+function(SetupDoxyMonitoring)
+ add_custom_target(check_doxygen_version
+ ALL
+ DEPENDS ${PRE_CONFIGURE_DOXYGEN_VERSION_FILE}
+ BYPRODUCTS ${POST_CONFIGURE_DOXYGEN_VERSION_FILE}
+ COMMENT "Checking the doxygen version for changes..."
+ COMMAND
+ ${CMAKE_COMMAND}
+ -D_BUILD_TIME_CHECK_DOXY=TRUE
+ -DDOXY_STATE_FILE=${DOXY_STATE_FILE}
+ -DPRE_CONFIGURE_DOXYGEN_VERSION_FILE=${PRE_CONFIGURE_DOXYGEN_VERSION_FILE}
+ -DPOST_CONFIGURE_DOXYGEN_VERSION_FILE=${POST_CONFIGURE_DOXYGEN_VERSION_FILE}
+ -P "${CMAKE_CURRENT_LIST_FILE}")
+endfunction()
+
+
+
+# Function: Main
+# Description: primary entry-point to the script. Functions are selected based
+# on whether it's configure or build time.
+function(Main)
+ file(STRINGS "${DOXY_STATE_FILE}" DOXYGEN_VERSION)
+ if(_BUILD_TIME_CHECK_DOXY)
+ # Check if the doxygen version file has changed.
+ # If so, run the change action.
+ if(${DOXY_STATE_FILE} IS_NEWER_THAN ${POST_CONFIGURE_DOXYGEN_VERSION_FILE})
+ DoxygenStateChangedAction("${DOXYGEN_VERSION}")
+ endif()
+ else()
+ # >> Executes at configure time.
+ SetupDoxyMonitoring()
+ DoxygenStateChangedAction("${DOXYGEN_VERSION}")
+ endif()
+endfunction()
+
+# And off we go...
+Main()