Generate documentation using the FindSphinx.cmake module
Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
This commit is contained in:
		
							parent
							
								
									9cf4b97f1a
								
							
						
					
					
						commit
						b916f0bfb7
					
				
					 23 changed files with 151 additions and 3503 deletions
				
			
		| 
						 | 
				
			
			@ -16,90 +16,14 @@ add_subdirectory(roundtrip)
 | 
			
		|||
add_subdirectory(throughput)
 | 
			
		||||
 | 
			
		||||
if (BUILD_DOCS)
 | 
			
		||||
  message(STATUS "${CMAKE_PROJECT_NAME} Examples documentation: Success (build)")
 | 
			
		||||
  set(EXAMPLES_HTML_ARCHIVE "${CMAKE_PROJECT_NAME}ExamplesHTML.tar.gz")
 | 
			
		||||
  # Process sphinx configuration file
 | 
			
		||||
  set(sph_conf_author "Eclipse Cyclone DDS project")
 | 
			
		||||
  string(TIMESTAMP sph_conf_copyright "%Y")
 | 
			
		||||
  set(sph_conf_version "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
 | 
			
		||||
  set(sph_conf_release "${PROJECT_VERSION}")
 | 
			
		||||
  configure_file(sphinx-conf.py.in conf.py @ONLY)
 | 
			
		||||
 | 
			
		||||
  set(builder_output "examples_html_output")
 | 
			
		||||
  set(builder_log "sphinx-examples-html.log")
 | 
			
		||||
  add_custom_command(OUTPUT ${builder_output}
 | 
			
		||||
    COMMAND ${SPHINX_EXECUTABLE}
 | 
			
		||||
    -b html
 | 
			
		||||
    -d ${CMAKE_CURRENT_BINARY_DIR}/cache
 | 
			
		||||
    -c ${CMAKE_CURRENT_BINARY_DIR}
 | 
			
		||||
    ${CMAKE_CURRENT_SOURCE_DIR}
 | 
			
		||||
    ${CMAKE_CURRENT_BINARY_DIR} > ${builder_log}
 | 
			
		||||
    COMMENT "Running Sphinx for examples html output"
 | 
			
		||||
    VERBATIM)
 | 
			
		||||
 | 
			
		||||
  # OUTPUT is a fake target / symbolic name, not an actual file
 | 
			
		||||
  set_property(SOURCE ${builder_output} PROPERTY SYMBOLIC 1)
 | 
			
		||||
  add_custom_target(examples_docs ALL DEPENDS ${builder_output})
 | 
			
		||||
 | 
			
		||||
  # Archive the output html files, will become a jenkins artifact for use in other jobs
 | 
			
		||||
  # TODO this hardcoded list and archiving should be replaced by ExternalData refs
 | 
			
		||||
  set(html_outputs
 | 
			
		||||
    "_static"
 | 
			
		||||
    "search.html"
 | 
			
		||||
    "searchindex.js"
 | 
			
		||||
    "genindex.html"
 | 
			
		||||
    "examples.html"
 | 
			
		||||
    "helloworld/readme.html"
 | 
			
		||||
    "roundtrip/readme.html"
 | 
			
		||||
    "throughput/readme.html")
 | 
			
		||||
 | 
			
		||||
  add_custom_command(OUTPUT ${builder_output}
 | 
			
		||||
    COMMAND ${CMAKE_COMMAND}
 | 
			
		||||
    -E tar "zcf"
 | 
			
		||||
    "${EXAMPLES_HTML_ARCHIVE}"
 | 
			
		||||
    ${html_outputs}
 | 
			
		||||
    APPEND
 | 
			
		||||
    VERBATIM)
 | 
			
		||||
 | 
			
		||||
  # Remove generated files when cleaning the build tree
 | 
			
		||||
  set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
 | 
			
		||||
    "cache"
 | 
			
		||||
    "${builder_log}"
 | 
			
		||||
    "objects.inv"
 | 
			
		||||
    ${html_outputs}
 | 
			
		||||
    "_sources"
 | 
			
		||||
    "${EXAMPLES_HTML_ARCHIVE}")
 | 
			
		||||
  find_package(Sphinx REQUIRED)
 | 
			
		||||
  sphinx_add_docs(
 | 
			
		||||
    examples_docs
 | 
			
		||||
    BUILDER html
 | 
			
		||||
    SOURCE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
 | 
			
		||||
  install(
 | 
			
		||||
    DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/examples_docs/"
 | 
			
		||||
    DESTINATION "${CMAKE_INSTALL_EXAMPLESDIR}"
 | 
			
		||||
    COMPONENT dev
 | 
			
		||||
    PATTERN "_sources" EXCLUDE)
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
 | 
			
		||||
  set(platform_exclude "examples/helloworld/Makefile")
 | 
			
		||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
 | 
			
		||||
  set(platform_exclude "examples/helloworld/vs|examples/helloworld/HelloWorld\.sln")
 | 
			
		||||
else()
 | 
			
		||||
  set(platform_exclude "this_is_a_placeholder")
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
# Install example source-files
 | 
			
		||||
install(
 | 
			
		||||
  DIRECTORY "${PROJECT_SOURCE_DIR}/examples/"
 | 
			
		||||
  DESTINATION "${CMAKE_INSTALL_EXAMPLESDIR}"
 | 
			
		||||
  COMPONENT dev
 | 
			
		||||
  PATTERN "CMakeLists.export" EXCLUDE
 | 
			
		||||
  PATTERN "examples/CMakeLists.txt" EXCLUDE
 | 
			
		||||
  REGEX ${platform_exclude} EXCLUDE
 | 
			
		||||
  REGEX "\.rst|\.py" EXCLUDE)
 | 
			
		||||
 | 
			
		||||
# Install example html docs files
 | 
			
		||||
# TODO this should be replaced by install commands that use ExternalData refs (preferably in examples' CMakeLists.txt)
 | 
			
		||||
install(
 | 
			
		||||
  DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
 | 
			
		||||
  DESTINATION "${CMAKE_INSTALL_EXAMPLESDIR}"
 | 
			
		||||
  COMPONENT dev
 | 
			
		||||
  FILES_MATCHING
 | 
			
		||||
  PATTERN "CMakeFiles" EXCLUDE
 | 
			
		||||
  PATTERN "cache" EXCLUDE
 | 
			
		||||
  PATTERN "_sources" EXCLUDE
 | 
			
		||||
  PATTERN "*.html"
 | 
			
		||||
  PATTERN "*.js"
 | 
			
		||||
  PATTERN "_static/*")
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue