CMake: Only run Sphinx when necessary

develop
lethosor 2015-09-26 17:52:06 -04:00
parent 792eefee9f
commit 6cc399561b
1 changed files with 28 additions and 9 deletions

@ -210,20 +210,39 @@ if (BUILD_DOCS)
"${SPHINX_BINARY_BUILD_DIR}/conf.py" "${SPHINX_BINARY_BUILD_DIR}/conf.py"
@ONLY) @ONLY)
add_custom_target(dfhack_docs ALL file(GLOB SPHINX_DEPS
${SPHINX_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/docs/*.rst"
"${CMAKE_CURRENT_SOURCE_DIR}/docs/images/*.png"
"${CMAKE_CURRENT_SOURCE_DIR}/docs/conf.py.in"
)
set(SPHINX_OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/docs/html/.buildinfo")
set_source_files_properties(${SPHINX_OUTPUT} PROPERTIES GENERATED TRUE)
add_custom_command(OUTPUT ${SPHINX_OUTPUT}
COMMAND ${SPHINX_EXECUTABLE}
-q -b html -q -b html
-c "${SPHINX_BINARY_BUILD_DIR}" -c "${SPHINX_BINARY_BUILD_DIR}"
-d "${SPHINX_CACHE_DIR}" -d "${SPHINX_CACHE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}"
"${SPHINX_HTML_DIR}" "${SPHINX_HTML_DIR}"
COMMENT "Building HTML documentation with Sphinx") DEPENDS ${SPHINX_DEPS}
install(DIRECTORY ${dfhack_SOURCE_DIR}/docs/html COMMENT "Building HTML documentation with Sphinx"
DESTINATION ${DFHACK_USERDOC_DESTINATION} )
#FILES_MATCHING PATTERN "*.lua"
# PATTERN "*.rb" add_custom_target(dfhack_docs ALL
# PATTERN "3rdparty" EXCLUDE DEPENDS ${SPHINX_OUTPUT}
) )
# Sphinx doesn't touch this file if it didn't make changes,
# which makes CMake think it didn't complete
add_custom_command(TARGET dfhack_docs POST_BUILD
COMMAND ${CMAKE_COMMAND} -E touch ${SPHINX_OUTPUT})
install(DIRECTORY ${dfhack_SOURCE_DIR}/docs/html
DESTINATION ${DFHACK_USERDOC_DESTINATION}
#FILES_MATCHING PATTERN "*.lua"
# PATTERN "*.rb"
# PATTERN "3rdparty" EXCLUDE
)
endif() endif()
# Packaging with CPack! # Packaging with CPack!