2013-09-18 00:08:05 +04:00
|
|
|
#=============================================================================
|
|
|
|
# CMake - Cross Platform Makefile Generator
|
|
|
|
# Copyright 2000-2013 Kitware, Inc., Insight Software Consortium
|
|
|
|
#
|
|
|
|
# Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
# see accompanying file Copyright.txt for details.
|
|
|
|
#
|
|
|
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
# See the License for more information.
|
|
|
|
#=============================================================================
|
|
|
|
if(NOT CMake_SOURCE_DIR)
|
|
|
|
set(CMakeHelp_STANDALONE 1)
|
2016-09-15 16:23:39 +03:00
|
|
|
cmake_minimum_required(VERSION 2.8.12.2 FATAL_ERROR)
|
2013-09-18 00:08:05 +04:00
|
|
|
get_filename_component(tmp "${CMAKE_CURRENT_SOURCE_DIR}" PATH)
|
|
|
|
get_filename_component(CMake_SOURCE_DIR "${tmp}" PATH)
|
2013-10-29 19:08:22 +04:00
|
|
|
include(${CMake_SOURCE_DIR}/Modules/CTestUseLaunchers.cmake)
|
2013-09-18 00:08:05 +04:00
|
|
|
include(${CMake_SOURCE_DIR}/Source/CMakeVersionCompute.cmake)
|
|
|
|
include(${CMake_SOURCE_DIR}/Source/CMakeInstallDestinations.cmake)
|
|
|
|
unset(CMAKE_DATA_DIR)
|
|
|
|
unset(CMAKE_DATA_DIR CACHE)
|
2015-07-07 16:38:48 +03:00
|
|
|
macro(CMake_OPTIONAL_COMPONENT)
|
|
|
|
set(COMPONENT "")
|
|
|
|
endmacro()
|
2013-09-18 00:08:05 +04:00
|
|
|
endif()
|
|
|
|
project(CMakeHelp NONE)
|
|
|
|
|
|
|
|
option(SPHINX_MAN "Build man pages with Sphinx" OFF)
|
|
|
|
option(SPHINX_HTML "Build html help with Sphinx" OFF)
|
2014-04-24 22:59:34 +04:00
|
|
|
option(SPHINX_SINGLEHTML "Build html single page help with Sphinx" OFF)
|
2014-03-31 17:44:27 +04:00
|
|
|
option(SPHINX_QTHELP "Build Qt help with Sphinx" OFF)
|
2014-02-04 19:09:40 +04:00
|
|
|
option(SPHINX_TEXT "Build text help with Sphinx (not installed)" OFF)
|
2013-09-18 00:08:05 +04:00
|
|
|
find_program(SPHINX_EXECUTABLE
|
|
|
|
NAMES sphinx-build
|
|
|
|
DOC "Sphinx Documentation Builder (sphinx-doc.org)"
|
|
|
|
)
|
2015-04-30 16:30:14 +03:00
|
|
|
set(SPHINX_FLAGS "" CACHE STRING "Flags to pass to sphinx-build")
|
|
|
|
separate_arguments(sphinx_flags UNIX_COMMAND "${SPHINX_FLAGS}")
|
2013-09-18 00:08:05 +04:00
|
|
|
|
2014-02-04 19:09:40 +04:00
|
|
|
mark_as_advanced(SPHINX_TEXT)
|
2015-04-30 16:30:14 +03:00
|
|
|
mark_as_advanced(SPHINX_FLAGS)
|
2014-02-04 19:09:40 +04:00
|
|
|
|
2014-04-24 23:31:45 +04:00
|
|
|
if(NOT SPHINX_MAN AND NOT SPHINX_HTML AND NOT SPHINX_SINGLEHTML AND NOT SPHINX_QTHELP AND NOT SPHINX_TEXT)
|
2013-09-18 00:08:05 +04:00
|
|
|
return()
|
|
|
|
elseif(NOT SPHINX_EXECUTABLE)
|
|
|
|
message(FATAL_ERROR "SPHINX_EXECUTABLE (sphinx-build) is not found!")
|
|
|
|
endif()
|
|
|
|
|
2013-11-13 18:18:57 +04:00
|
|
|
set(copyright_line_regex "^Copyright (2000-20[0-9][0-9] Kitware.*)")
|
|
|
|
file(STRINGS "${CMake_SOURCE_DIR}/Copyright.txt" copyright_line
|
|
|
|
LIMIT_COUNT 1 REGEX "${copyright_line_regex}")
|
|
|
|
if(copyright_line MATCHES "${copyright_line_regex}")
|
|
|
|
set(conf_copyright "${CMAKE_MATCH_1}")
|
|
|
|
else()
|
|
|
|
set(conf_copyright "Kitware, Inc.")
|
|
|
|
endif()
|
|
|
|
|
2013-10-30 17:58:25 +04:00
|
|
|
set(conf_docs "${CMake_SOURCE_DIR}/Help")
|
2013-09-18 00:08:05 +04:00
|
|
|
set(conf_path "${CMAKE_CURRENT_SOURCE_DIR}")
|
2013-11-04 23:14:29 +04:00
|
|
|
set(conf_version "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}")
|
2013-09-18 00:08:05 +04:00
|
|
|
set(conf_release "${CMake_VERSION}")
|
|
|
|
configure_file(conf.py.in conf.py @ONLY)
|
|
|
|
|
|
|
|
set(doc_formats "")
|
|
|
|
if(SPHINX_HTML)
|
|
|
|
list(APPEND doc_formats html)
|
|
|
|
endif()
|
|
|
|
if(SPHINX_MAN)
|
|
|
|
list(APPEND doc_formats man)
|
|
|
|
endif()
|
2014-04-24 22:59:34 +04:00
|
|
|
if(SPHINX_SINGLEHTML)
|
|
|
|
list(APPEND doc_formats singlehtml)
|
|
|
|
endif()
|
2014-02-04 19:09:40 +04:00
|
|
|
if(SPHINX_TEXT)
|
|
|
|
list(APPEND doc_formats text)
|
|
|
|
endif()
|
2014-03-31 17:44:27 +04:00
|
|
|
if(SPHINX_QTHELP)
|
2014-07-28 23:07:53 +04:00
|
|
|
find_package(PythonInterp REQUIRED)
|
|
|
|
|
2014-03-31 17:44:27 +04:00
|
|
|
find_program(QCOLLECTIONGENERATOR_EXECUTABLE
|
|
|
|
NAMES qcollectiongenerator
|
|
|
|
DOC "qcollectiongenerator tool"
|
|
|
|
)
|
|
|
|
if (NOT QCOLLECTIONGENERATOR_EXECUTABLE)
|
|
|
|
message(FATAL_ERROR "QCOLLECTIONGENERATOR_EXECUTABLE (qcollectiongenerator) not found!")
|
|
|
|
endif()
|
|
|
|
list(APPEND doc_formats qthelp)
|
|
|
|
|
|
|
|
set(qthelp_extra_commands
|
2014-04-01 21:04:28 +04:00
|
|
|
# Workaround for assistant prior to
|
|
|
|
# https://codereview.qt-project.org/#change,82250 in Qt 4.
|
|
|
|
COMMAND ${CMAKE_COMMAND} "-DCSS_DIR=${CMAKE_CURRENT_BINARY_DIR}/qthelp/_static"
|
|
|
|
-P "${CMAKE_CURRENT_SOURCE_DIR}/apply_qthelp_css_workaround.cmake"
|
2014-04-10 12:36:43 +04:00
|
|
|
# Workaround sphinx configurability:
|
|
|
|
# https://bitbucket.org/birkenfeld/sphinx/issue/1448/make-qthelp-more-configurable
|
|
|
|
COMMAND ${CMAKE_COMMAND} "-DQTHELP_DIR=${CMAKE_CURRENT_BINARY_DIR}/qthelp/"
|
|
|
|
"-DCMake_VERSION=${CMake_VERSION_MAJOR}${CMake_VERSION_MINOR}${CMake_VERSION_PATCH}"
|
|
|
|
-P "${CMAKE_CURRENT_SOURCE_DIR}/fixup_qthelp_names.cmake"
|
2014-06-13 17:27:59 +04:00
|
|
|
|
|
|
|
# Create proper identifiers. Workaround for
|
|
|
|
# https://bitbucket.org/birkenfeld/sphinx/issue/1491/qthelp-should-generate-identifiers-for
|
2014-07-28 23:07:53 +04:00
|
|
|
COMMAND "${PYTHON_EXECUTABLE}"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/create_identifiers.py"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/qthelp/"
|
2014-06-13 17:27:59 +04:00
|
|
|
|
2014-07-28 23:07:53 +04:00
|
|
|
COMMAND ${QCOLLECTIONGENERATOR_EXECUTABLE}
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/qthelp/CMake.qhcp
|
2014-03-31 17:44:27 +04:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2013-09-18 00:08:05 +04:00
|
|
|
|
|
|
|
set(doc_format_outputs "")
|
|
|
|
set(doc_format_last "")
|
|
|
|
foreach(format ${doc_formats})
|
|
|
|
set(doc_format_output "doc_format_${format}")
|
|
|
|
set(doc_format_log "build-${format}.log")
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${doc_format_output}
|
|
|
|
COMMAND ${SPHINX_EXECUTABLE}
|
|
|
|
-c ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
-d ${CMAKE_CURRENT_BINARY_DIR}/doctrees
|
|
|
|
-b ${format}
|
2015-04-30 16:30:14 +03:00
|
|
|
${sphinx_flags}
|
2013-09-18 00:08:05 +04:00
|
|
|
${CMake_SOURCE_DIR}/Help
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${format}
|
|
|
|
> ${doc_format_log} # log stdout, pass stderr
|
2014-03-31 17:44:27 +04:00
|
|
|
${${format}_extra_commands}
|
2013-09-18 00:08:05 +04:00
|
|
|
DEPENDS ${doc_format_last}
|
|
|
|
COMMENT "sphinx-build ${format}: see Utilities/Sphinx/${doc_format_log}"
|
|
|
|
VERBATIM
|
|
|
|
)
|
|
|
|
set_property(SOURCE ${doc_format_output} PROPERTY SYMBOLIC 1)
|
|
|
|
list(APPEND doc_format_outputs ${doc_format_output})
|
|
|
|
set(doc_format_last ${doc_format_output})
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
add_custom_target(documentation ALL DEPENDS ${doc_format_outputs})
|
|
|
|
|
|
|
|
foreach(t
|
|
|
|
cmake
|
|
|
|
ccmake
|
|
|
|
cmake-gui
|
|
|
|
cpack
|
|
|
|
ctest
|
|
|
|
)
|
|
|
|
if(TARGET ${t})
|
|
|
|
# Build documentation after main executables.
|
|
|
|
add_dependencies(documentation ${t})
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
if(SPHINX_MAN)
|
|
|
|
file(GLOB man_rst RELATIVE ${CMake_SOURCE_DIR}/Help/manual
|
|
|
|
${CMake_SOURCE_DIR}/Help/manual/*.[1-9].rst)
|
|
|
|
foreach(m ${man_rst})
|
|
|
|
if("x${m}" MATCHES "^x(.+)\\.([1-9])\\.rst$")
|
|
|
|
set(name "${CMAKE_MATCH_1}")
|
|
|
|
set(sec "${CMAKE_MATCH_2}")
|
2016-08-01 23:16:55 +03:00
|
|
|
set(skip FALSE)
|
2016-02-08 17:37:24 +03:00
|
|
|
if(NOT CMakeHelp_STANDALONE)
|
|
|
|
if(name STREQUAL "ccmake" AND NOT BUILD_CursesDialog)
|
2016-08-01 23:16:55 +03:00
|
|
|
set(skip TRUE)
|
|
|
|
elseif(name STREQUAL "cmake-gui" AND NOT BUILD_QtDialog)
|
|
|
|
set(skip TRUE)
|
2016-02-08 17:37:24 +03:00
|
|
|
endif()
|
|
|
|
endif()
|
2016-08-01 23:16:55 +03:00
|
|
|
if(NOT skip)
|
|
|
|
CMake_OPTIONAL_COMPONENT(sphinx-man)
|
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/man/${name}.${sec}
|
|
|
|
DESTINATION ${CMAKE_MAN_DIR}/man${sec}
|
|
|
|
${COMPONENT})
|
|
|
|
endif()
|
|
|
|
unset(skip)
|
2013-09-18 00:08:05 +04:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(SPHINX_HTML)
|
2015-07-03 12:58:22 +03:00
|
|
|
CMake_OPTIONAL_COMPONENT(sphinx-html)
|
2013-09-18 00:08:05 +04:00
|
|
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
|
2014-01-28 18:12:44 +04:00
|
|
|
DESTINATION ${CMAKE_DOC_DIR}
|
2015-07-03 12:58:22 +03:00
|
|
|
${COMPONENT}
|
2014-01-28 18:12:44 +04:00
|
|
|
PATTERN .buildinfo EXCLUDE
|
|
|
|
)
|
2013-09-18 00:08:05 +04:00
|
|
|
endif()
|
2014-04-24 22:59:34 +04:00
|
|
|
|
|
|
|
if(SPHINX_SINGLEHTML)
|
2015-07-03 12:58:22 +03:00
|
|
|
CMake_OPTIONAL_COMPONENT(sphinx-singlehtml)
|
2014-04-24 22:59:34 +04:00
|
|
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/singlehtml
|
|
|
|
DESTINATION ${CMAKE_DOC_DIR}
|
2015-07-03 12:58:22 +03:00
|
|
|
${COMPONENT}
|
2014-04-24 22:59:34 +04:00
|
|
|
PATTERN .buildinfo EXCLUDE
|
|
|
|
)
|
|
|
|
endif()
|
2014-04-24 23:31:45 +04:00
|
|
|
|
2014-03-31 17:44:27 +04:00
|
|
|
if(SPHINX_QTHELP)
|
2015-07-03 12:58:22 +03:00
|
|
|
CMake_OPTIONAL_COMPONENT(sphinx-qthelp)
|
2014-04-14 15:14:31 +04:00
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qthelp/CMake-${CMake_VERSION_MAJOR}${CMake_VERSION_MINOR}${CMake_VERSION_PATCH}.qch
|
2015-07-03 12:58:22 +03:00
|
|
|
DESTINATION ${CMAKE_DOC_DIR} ${COMPONENT}
|
2014-03-31 17:44:27 +04:00
|
|
|
)
|
|
|
|
endif()
|