Add CMake target for html documentation
This commit is contained in:
@ -9,6 +9,7 @@ set(SOVERSION 0)
|
|||||||
get_filename_component(LAMMPS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../src ABSOLUTE)
|
get_filename_component(LAMMPS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../src ABSOLUTE)
|
||||||
get_filename_component(LAMMPS_LIB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../lib ABSOLUTE)
|
get_filename_component(LAMMPS_LIB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../lib ABSOLUTE)
|
||||||
get_filename_component(LAMMPS_LIB_BINARY_DIR ${CMAKE_BINARY_DIR}/lib ABSOLUTE)
|
get_filename_component(LAMMPS_LIB_BINARY_DIR ${CMAKE_BINARY_DIR}/lib ABSOLUTE)
|
||||||
|
get_filename_component(LAMMPS_DOC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../doc ABSOLUTE)
|
||||||
|
|
||||||
|
|
||||||
# To avoid conflicts with the conventional Makefile build system, we build everything here
|
# To avoid conflicts with the conventional Makefile build system, we build everything here
|
||||||
@ -900,6 +901,63 @@ if(BUILD_EXE)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Build documentation
|
||||||
|
###############################################################################
|
||||||
|
option(BUILD_DOC "Build LAMMPS documentation" OFF)
|
||||||
|
if(BUILD_DOC)
|
||||||
|
include(ProcessorCount)
|
||||||
|
ProcessorCount(NPROCS)
|
||||||
|
find_package(PythonInterp 3 REQUIRED)
|
||||||
|
|
||||||
|
set(VIRTUALENV ${PYTHON_EXECUTABLE} -m virtualenv)
|
||||||
|
|
||||||
|
file(GLOB DOC_SOURCES ${LAMMPS_DOC_DIR}/src/*.txt)
|
||||||
|
file(GLOB PDF_EXTRA_SOURCES ${LAMMPS_DOC_DIR}/src/lammps_commands*.txt ${LAMMPS_DOC_DIR}/src/lammps_support.txt ${LAMMPS_DOC_DIR}/src/lammps_tutorials.txt)
|
||||||
|
list(REMOVE_ITEM DOC_SOURCES ${PDF_EXTRA_SOURCES})
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT docenv
|
||||||
|
COMMAND ${VIRTUALENV} docenv
|
||||||
|
)
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT requirements.txt
|
||||||
|
DEPENDS docenv
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy ${LAMMPS_DOC_DIR}/utils/requirements.txt requirements.txt
|
||||||
|
COMMAND ./docenv/bin/pip install -r requirements.txt --upgrade
|
||||||
|
COMMAND ./docenv/bin/pip install --upgrade ${LAMMPS_DOC_DIR}/utils/converters
|
||||||
|
)
|
||||||
|
|
||||||
|
set(RST_FILES "")
|
||||||
|
set(RST_DIR ${CMAKE_BINARY_DIR}/rst)
|
||||||
|
file(MAKE_DIRECTORY ${RST_DIR})
|
||||||
|
foreach(TXT_FILE ${DOC_SOURCES})
|
||||||
|
get_filename_component(FILENAME ${TXT_FILE} NAME_WE)
|
||||||
|
set(RST_FILE ${RST_DIR}/${FILENAME}.rst)
|
||||||
|
list(APPEND RST_FILES ${RST_FILE})
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${RST_FILE}
|
||||||
|
DEPENDS requirements.txt docenv ${TXT_FILE}
|
||||||
|
COMMAND ./docenv/bin/txt2rst -o ${RST_DIR} ${TXT_FILE}
|
||||||
|
)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT html
|
||||||
|
DEPENDS ${RST_FILES}
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LAMMPS_DOC_DIR}/src ${RST_DIR}
|
||||||
|
COMMAND ./docenv/bin/sphinx-build -j ${NPROCS} -b html -c ${LAMMPS_DOC_DIR}/utils/sphinx-config -d ${CMAKE_BINARY_DIR}/doctrees ${RST_DIR} html
|
||||||
|
)
|
||||||
|
|
||||||
|
add_custom_target(
|
||||||
|
doc
|
||||||
|
DEPENDS html
|
||||||
|
SOURCES ${LAMMPS_DOC_DIR}/utils/requirements.txt ${DOC_SOURCES}
|
||||||
|
)
|
||||||
|
|
||||||
|
install(DIRECTORY ${CMAKE_BINARY_DIR}/html DESTINATION ${CMAKE_INSTALL_DOCDIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Install potential files in data directory
|
# Install potential files in data directory
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|||||||
1
doc/utils/requirements.txt
Normal file
1
doc/utils/requirements.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
Sphinx
|
||||||
Reference in New Issue
Block a user