-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
93 lines (75 loc) · 2.59 KB
/
CMakeLists.txt
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
cmake_minimum_required(VERSION 2.8)
project(swganh-docs CXX)
# current version
if(NOT DEFINED swganh_VERSION)
set(swganh_VERSION_MAJOR 0)
set(swganh_VERSION_MINOR 4)
set(swganh_VERSION_PATCH 0)
set(swganh_VERSION
${swganh_VERSION_MAJOR}.${swganh_VERSION_MINOR}.${swganh_VERSION_PATCH})
endif()
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/tools/cmake")
find_package(Sphinx REQUIRED)
if(NOT DEFINED SPHINX_THEME)
set(SPHINX_THEME default)
endif()
if(NOT DEFINED SPHINX_THEME_DIR)
set(SPHINX_THEME_DIR)
endif()
# configured documentation tools and intermediate build results
set(BINARY_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/_build")
# Sphinx cache with pickled ReST documents
set(SPHINX_CACHE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_doctrees")
# HTML output directory
set(SPHINX_HTML_DIR "${CMAKE_CURRENT_BINARY_DIR}/html")
if(NOT DEFINED SWGPY_DIR)
set(SWGPY_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()
if(WIN32)
foreach(configuration ${CMAKE_CONFIGURATION_TYPES})
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in"
"${BINARY_BUILD_DIR}/${configuration}/conf.py"
@ONLY)
endforeach()
set(BINARY_BUILD_DIR "${BINARY_BUILD_DIR}/$<CONFIGURATION>")
set(SPHINX_CACHE_DIR "${SPHINX_CACHE_DIR}/$<CONFIGURATION>")
set(SPHINX_HTML_DIR "${SPHINX_HTML_DIR}/$<CONFIGURATION>")
else()
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in"
"${BINARY_BUILD_DIR}/conf.py"
@ONLY)
endif()
file(GLOB_RECURSE DOCUMENTS *.rst *.in)
# Group the source files based on the directory structure.
FOREACH(__source_file ${DOCUMENTS})
STRING(REGEX REPLACE "(${CMAKE_CURRENT_SOURCE_DIR}/)((.*/)*)(.*)" "\\2" __source_dir "${__source_file}")
STRING(REGEX REPLACE "(${CMAKE_CURRENT_SOURCE_DIR}/${__source_dir})(.*)" "\\2" __source_filename "${__source_file}")
STRING(REPLACE "/" "\\\\" __source_group "${__source_dir}")
SOURCE_GROUP("${__source_group}" FILES ${__source_file})
ENDFOREACH()
if(WIN32)
set(WORKING_DIR "${SWGPY_DIR}/$\(Configuration\)")
set(DEPENDENCIES swgpy)
else()
set(WORKING_DIR "${SWGPY_DIR}")
set(DEPENDENCIES)
endif()
add_custom_target(swganh_doc_html ALL
${SPHINX_EXECUTABLE}
-q -b html
-c "${BINARY_BUILD_DIR}"
-d "${SPHINX_CACHE_DIR}"
-n
"${CMAKE_CURRENT_SOURCE_DIR}"
"${SPHINX_HTML_DIR}"
COMMENT "Building HTML documentation with Sphinx"
DEPENDS ${DEPENDENCIES}
WORKING_DIRECTORY "${WORKING_DIR}"
VERBATIM
SOURCES ${DOCUMENTS}
)
configure_file(
${PROJECT_SOURCE_DIR}/tools/windows/user_project.vcxproj.in
${CMAKE_CURRENT_BINARY_DIR}/swganh_doc_html.vcxproj.user @ONLY)