forked from Eyescale/CMake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CommonDocumentation.cmake
60 lines (55 loc) · 2.38 KB
/
CommonDocumentation.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Copyright (c) 2012-2014 Raphael Dumusc <[email protected]>
# Configure the build for a documentation project:
# common_documentation()
#
# Generates:
# * doxygit target
# * install target (optional)
#
# The doxygit target executes Doxygit.cmake as a script in the source
# directory of the project. It updates the index page, removes outdated
# documentation folders and 'git add' the changes.
#
# Input (optional):
# * DOXYGIT_GENERATE_INDEX generate an index.html page (default: OFF)
# * DOXYGIT_MAX_VERSIONS number of versions to keep in directory (default: 10)
# * DOXYGIT_TOC_POST html content to insert in 'index.html' (default: '')
#
# * COMMON_INSTALL_DOCUMENTATION if set to ON, generate a 'make install' target
# which installs all the documentation under share/${PROJECT_NAME}/.
# Default: OFF because it is called by each dependant project when doing a
# regular release build using Buildyard, which can be very time consuming.
function(COMMON_DOCUMENTATION)
add_custom_command(OUTPUT ${PROJECT_NAME}-index-generated
COMMAND ${CMAKE_COMMAND}
-DPROJECT_NAME="${PROJECT_NAME}"
-DDOXYGIT_GENERATE_INDEX="${DOXYGIT_GENERATE_INDEX}"
-DDOXYGIT_TOC_POST:STRING="${DOXYGIT_TOC_POST}"
-DDOXYGIT_MAX_VERSIONS="${DOXYGIT_MAX_VERSIONS}"
-DDOXYGIT_STATE_FILE="${PROJECT_BINARY_DIR}/doxygit-generated"
-P "${CMAKE_SOURCE_DIR}/CMake/common/Doxygit.cmake"
COMMENT "Updating ${PROJECT_NAME} pages in ${PROJECT_SOURCE_DIR}"
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}")
add_custom_target(${PROJECT_NAME}-doxygit ALL
DEPENDS ${PROJECT_NAME}-index-generated)
set_property(GLOBAL APPEND PROPERTY
${PROJECT_NAME}_ALL_DEP_TARGETS ${PROJECT_NAME}-doxygit)
# For meta project, separate doxygit and ${PROJECT_NAME}-doxygit
if(NOT TARGET doxygit)
add_custom_target(doxygit ALL)
endif()
add_dependencies(doxygit ${PROJECT_NAME}-doxygit)
if(COMMON_INSTALL_DOCUMENTATION)
file(GLOB Folders RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *-*)
foreach(FOLDER ${Folders})
install(DIRECTORY ${FOLDER} DESTINATION share/${PROJECT_NAME}
CONFIGURATIONS Release)
endforeach()
# need at least one file for 'make install'
install(FILES index.html DESTINATION share/${PROJECT_NAME}
CONFIGURATIONS Release)
else()
# Buildyard expects an install target for all projects
install(CODE "MESSAGE(\"Nothing to install, done.\")")
endif()
endfunction()