Merge pull request #2582 from mpilman/features/documentation-server
Add `docpreview` target
This commit is contained in:
commit
297a56c219
|
@ -59,6 +59,38 @@ endfunction()
|
|||
message(STATUS "Add html target")
|
||||
add_documentation_target(GENERATOR html)
|
||||
|
||||
set(DOCSERVER_PORT "-1" CACHE STRING "Port to which the documentation server should bind (negative means cmake will choose one)")
|
||||
|
||||
if(DOCSERVER_PORT GREATER_EQUAL 0)
|
||||
set(port ${DOCSERVER_PORT})
|
||||
else()
|
||||
if(WIN32)
|
||||
if(DEFINED $ENV{USERNAME})
|
||||
set(username $ENV{USERNAME})
|
||||
else()
|
||||
set(username "dummy_user")
|
||||
endif()
|
||||
else()
|
||||
if(DEFINED $ENV{USER})
|
||||
set(username $ENV{USER})
|
||||
else()
|
||||
set(username "dummy_user")
|
||||
endif()
|
||||
endif()
|
||||
string(MD5 username_hash ${username})
|
||||
# cmake math function can only use 64 bit signed integers - so we just truncate the string
|
||||
string(SUBSTRING "${username_hash}" 0 15 username_hash_small)
|
||||
message(STATUS math(EXPR port "(0x${username_hash_small} % 8000) + 8000" OUTPUT_FORMAT DECIMAL))
|
||||
math(EXPR port "(0x${username_hash_small} % 8000) + 8000" OUTPUT_FORMAT DECIMAL)
|
||||
message(STATUS "Port is ${port}")
|
||||
endif()
|
||||
|
||||
add_custom_target(docpreview
|
||||
COMMAND ${python_command} -m SimpleHTTPServer ${port}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
|
||||
USES_TERMINAL)
|
||||
add_dependencies(docpreview html)
|
||||
|
||||
set(tar_file ${CMAKE_BINARY_DIR}/packages/${CMAKE_PROJECT_NAME}-docs-${FDB_VERSION}.tar.gz)
|
||||
add_custom_command(
|
||||
OUTPUT ${tar_file}
|
||||
|
|
Loading…
Reference in New Issue