diff --git a/CMakeLists.txt b/CMakeLists.txt index cfe84da2..06d6e413 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -151,11 +151,7 @@ if (EXISTS .gitignore) set(CPACK_PACKAGE_VERSION_MAJOR 0) set(CPACK_PACKAGE_VERSION_MINOR 10) set(CPACK_PACKAGE_VERSION_PATCH 0) - set(CPPFORMAT_VERSION - ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}) set(CPACK_SOURCE_PACKAGE_FILE_NAME cppformat-${CPPFORMAT_VERSION}) set(CPACK_RESOURCE_FILE_README ${FORMAT_SOURCE_DIR}/README.rst) include(CPack) endif () - -configure_file(doc/conf.py.in doc/conf.py @ONLY) diff --git a/doc/conf.py.in b/doc/conf.py similarity index 95% rename from doc/conf.py.in rename to doc/conf.py index 20e4706c..ab130b01 100644 --- a/doc/conf.py.in +++ b/doc/conf.py @@ -11,7 +11,7 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys, os +import sys, os, re # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -49,6 +49,16 @@ master_doc = 'index' project = u'C++ Format' copyright = u'2012-2014, Victor Zverovich' +# Get version from CMakeLists.txt. +version = {} +with open('../CMakeLists.txt') as f: + for line in f: + m = re.match(r'set\(CPACK_PACKAGE_VERSION_([A-Z]+) ([0-9]+)\)', line.strip()) + if m: + kind, value = m.groups() + version[kind] = value +version = '{}.{}.{}'.format(version['MAJOR'], version['MINOR'], version['PATCH']) + # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents.