mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-24 12:14:26 +00:00
Pass version from CMake to Sphinx
This commit is contained in:
parent
646829e34d
commit
b83fd00183
@ -117,6 +117,14 @@ endif ()
|
|||||||
set_target_properties(cppformat
|
set_target_properties(cppformat
|
||||||
PROPERTIES COMPILE_FLAGS "${FMT_EXTRA_COMPILE_FLAGS}")
|
PROPERTIES COMPILE_FLAGS "${FMT_EXTRA_COMPILE_FLAGS}")
|
||||||
|
|
||||||
|
set(CPPFORMAT_VERSION 1.2.0)
|
||||||
|
if (NOT CPPFORMAT_VERSION MATCHES "^([0-9]+).([0-9]+).([0-9]+)$")
|
||||||
|
message(FATAL_ERROR "Invalid version format ${CPPFORMAT_VERSION}.")
|
||||||
|
endif ()
|
||||||
|
set(CPACK_PACKAGE_VERSION_MAJOR ${CMAKE_MATCH_1})
|
||||||
|
set(CPACK_PACKAGE_VERSION_MINOR ${CMAKE_MATCH_2})
|
||||||
|
set(CPACK_PACKAGE_VERSION_PATCH ${CMAKE_MATCH_3})
|
||||||
|
|
||||||
if (FMT_DOC)
|
if (FMT_DOC)
|
||||||
add_subdirectory(doc)
|
add_subdirectory(doc)
|
||||||
endif ()
|
endif ()
|
||||||
@ -126,14 +134,6 @@ if (FMT_TEST)
|
|||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
set(CPPFORMAT_VERSION 1.2.0)
|
|
||||||
if (NOT CPPFORMAT_VERSION MATCHES "^([0-9]+).([0-9]+).([0-9]+)$")
|
|
||||||
message(FATAL_ERROR "Invalid version format ${CPPFORMAT_VERSION}.")
|
|
||||||
endif ()
|
|
||||||
set(CPACK_PACKAGE_VERSION_MAJOR ${CMAKE_MATCH_1})
|
|
||||||
set(CPACK_PACKAGE_VERSION_MINOR ${CMAKE_MATCH_2})
|
|
||||||
set(CPACK_PACKAGE_VERSION_PATCH ${CMAKE_MATCH_3})
|
|
||||||
|
|
||||||
set_target_properties(cppformat PROPERTIES
|
set_target_properties(cppformat PROPERTIES
|
||||||
VERSION ${CPPFORMAT_VERSION} SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR})
|
VERSION ${CPPFORMAT_VERSION} SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR})
|
||||||
|
|
||||||
|
@ -4,7 +4,8 @@ if (NOT DOXYGEN)
|
|||||||
return ()
|
return ()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
add_custom_target(doc COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build.py)
|
add_custom_target(doc
|
||||||
|
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build.py ${CPPFORMAT_VERSION})
|
||||||
|
|
||||||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
|
||||||
DESTINATION share/doc/cppformat)
|
DESTINATION share/doc/cppformat)
|
||||||
|
2
doc/_templates/layout.html
vendored
2
doc/_templates/layout.html
vendored
@ -51,7 +51,7 @@
|
|||||||
<li class="dropdown">
|
<li class="dropdown">
|
||||||
{# TODO: update versions automatically #}
|
{# TODO: update versions automatically #}
|
||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
|
||||||
aria-expanded="false">dev <span class="caret"></span></a>
|
aria-expanded="false">{{ version }} <span class="caret"></span></a>
|
||||||
<ul class="dropdown-menu" role="menu">
|
<ul class="dropdown-menu" role="menu">
|
||||||
<li><a href="http://cppformat.github.io/1.1.0/">1.1.0</a></li>
|
<li><a href="http://cppformat.github.io/1.1.0/">1.1.0</a></li>
|
||||||
<li><a href="http://cppformat.github.io/1.0.0/">1.0.0</a></li>
|
<li><a href="http://cppformat.github.io/1.0.0/">1.0.0</a></li>
|
||||||
|
@ -18,7 +18,7 @@ def pip_install(package, commit=None, **kwargs):
|
|||||||
print('Installing {}'.format(package))
|
print('Installing {}'.format(package))
|
||||||
check_call(['pip', 'install', '--upgrade', package])
|
check_call(['pip', 'install', '--upgrade', package])
|
||||||
|
|
||||||
def build_docs():
|
def build_docs(version='dev'):
|
||||||
# Create virtualenv.
|
# Create virtualenv.
|
||||||
doc_dir = os.path.dirname(os.path.realpath(__file__))
|
doc_dir = os.path.dirname(os.path.realpath(__file__))
|
||||||
virtualenv_dir = 'virtualenv'
|
virtualenv_dir = 'virtualenv'
|
||||||
@ -77,8 +77,9 @@ def build_docs():
|
|||||||
'''.format(os.path.dirname(doc_dir)).encode('UTF-8'))
|
'''.format(os.path.dirname(doc_dir)).encode('UTF-8'))
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
raise CalledProcessError(p.returncode, cmd)
|
raise CalledProcessError(p.returncode, cmd)
|
||||||
check_call(['sphinx-build', '-D',
|
check_call(['sphinx-build',
|
||||||
'breathe_projects.format=' + os.path.join(os.getcwd(), 'doxyxml'),
|
'-Dbreathe_projects.format=' + os.path.join(os.getcwd(), 'doxyxml'),
|
||||||
|
'-Dversion=' + version, '-Drelease=' + version, '-Aversion=' + version,
|
||||||
'-b', 'html', doc_dir, 'html'])
|
'-b', 'html', doc_dir, 'html'])
|
||||||
try:
|
try:
|
||||||
check_call(['lessc', '--clean-css',
|
check_call(['lessc', '--clean-css',
|
||||||
@ -93,4 +94,4 @@ def build_docs():
|
|||||||
return 'html'
|
return 'html'
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
build_docs()
|
build_docs(sys.argv[1])
|
||||||
|
12
doc/conf.py
12
doc/conf.py
@ -47,7 +47,7 @@ source_suffix = '.rst'
|
|||||||
|
|
||||||
# General information about the project.
|
# General information about the project.
|
||||||
project = u'C++ Format'
|
project = u'C++ Format'
|
||||||
copyright = u'2012-2014, Victor Zverovich'
|
copyright = u'2012-2015, Victor Zverovich'
|
||||||
|
|
||||||
# The version info for the project you're documenting, acts as replacement for
|
# The version info for the project you're documenting, acts as replacement for
|
||||||
# |version| and |release|, also used in various other places throughout the
|
# |version| and |release|, also used in various other places throughout the
|
||||||
@ -55,15 +55,11 @@ copyright = u'2012-2014, Victor Zverovich'
|
|||||||
#
|
#
|
||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
|
|
||||||
# Get version from CMakeLists.txt.
|
# Version and release are passed from CMake.
|
||||||
with open('../CMakeLists.txt') as f:
|
#version = None
|
||||||
for line in f:
|
|
||||||
m = re.match(r'set\(CPPFORMAT_VERSION (.+)\)', line.strip())
|
|
||||||
if m:
|
|
||||||
version = m.group(1)
|
|
||||||
|
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = version
|
#release = version
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
# for a list of supported languages.
|
# for a list of supported languages.
|
||||||
|
Loading…
Reference in New Issue
Block a user