Advance Wayland and KDE package bring-up
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -0,0 +1,138 @@
|
||||
#=============================================================================
|
||||
# SPDX-FileCopyrightText: 2000-2013 Kitware, Inc.
|
||||
# SPDX-FileCopyrightText: 2014-2015 Alex Merry <alex.merry@kde.org>
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#=============================================================================
|
||||
|
||||
include(CMakeDependentOption)
|
||||
enable_language(CXX)
|
||||
|
||||
find_package(Sphinx 1.2 MODULE)
|
||||
set_package_properties(
|
||||
Sphinx
|
||||
PROPERTIES
|
||||
URL "https://www.sphinx-doc.org/"
|
||||
DESCRIPTION "Tool to generate documentation."
|
||||
TYPE OPTIONAL
|
||||
PURPOSE "Required to build documentation for Extra CMake Modules."
|
||||
)
|
||||
|
||||
find_package(Qt6 COMPONENTS ToolsTools)
|
||||
set_package_properties(
|
||||
Qt6ToolsTools
|
||||
PROPERTIES
|
||||
URL "https://www.qt.io/"
|
||||
DESCRIPTION "Qt help collection generator."
|
||||
TYPE OPTIONAL
|
||||
PURPOSE "Required to build Extra CMake Modules documentation in Qt Help format."
|
||||
)
|
||||
|
||||
cmake_dependent_option(
|
||||
BUILD_HTML_DOCS "Build html help with Sphinx" ON
|
||||
"Sphinx_FOUND" OFF
|
||||
)
|
||||
add_feature_info(BUILD_HTML_DOCS BUILD_HTML_DOCS "Generate HTML documentation for installed modules.")
|
||||
|
||||
cmake_dependent_option(
|
||||
BUILD_MAN_DOCS "Build man pages with Sphinx" ON
|
||||
"Sphinx_FOUND" OFF
|
||||
)
|
||||
add_feature_info(BUILD_MAN_DOCS BUILD_MAN_DOCS "Generate man page documentation for installed modules.")
|
||||
|
||||
if(TARGET Qt6::qhelpgenerator)
|
||||
set(QHelpGenerator_FOUND TRUE)
|
||||
endif()
|
||||
|
||||
cmake_dependent_option(
|
||||
BUILD_QTHELP_DOCS "Build Qt help with Sphinx" ON
|
||||
"Sphinx_FOUND;QHelpGenerator_FOUND" OFF
|
||||
)
|
||||
add_feature_info(BUILD_QTHELP_DOCS BUILD_QTHELP_DOCS "Generate QtHelp documentation for installed modules.")
|
||||
|
||||
|
||||
set(doc_formats "")
|
||||
if(BUILD_HTML_DOCS)
|
||||
list(APPEND doc_formats html)
|
||||
endif()
|
||||
if(BUILD_MAN_DOCS)
|
||||
list(APPEND doc_formats man)
|
||||
endif()
|
||||
if(BUILD_QTHELP_DOCS)
|
||||
list(APPEND doc_formats qthelp)
|
||||
set(qthelp_extra_commands
|
||||
COMMAND
|
||||
Qt6::qhelpgenerator
|
||||
${CMAKE_CURRENT_BINARY_DIR}/qthelp/ExtraCMakeModules.qhcp
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT doc_formats)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if (Sphinx_VERSION VERSION_LESS 1.3)
|
||||
set(sphinx_theme default)
|
||||
else()
|
||||
set(sphinx_theme classic)
|
||||
endif()
|
||||
configure_file(sphinx/conf.py.in conf.py @ONLY)
|
||||
configure_file(sphinx/ecm.css.in static/ecm.css)
|
||||
|
||||
|
||||
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::Build
|
||||
-D man_make_section_directory=0
|
||||
-c ${CMAKE_CURRENT_BINARY_DIR}
|
||||
-d ${CMAKE_CURRENT_BINARY_DIR}/doctrees
|
||||
-b ${format}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${format}
|
||||
> ${doc_format_log} # log stdout, pass stderr
|
||||
${${format}_extra_commands}
|
||||
DEPENDS ${doc_format_last}
|
||||
COMMENT "sphinx-build ${format}: see ${CMAKE_CURRENT_BINARY_DIR}/${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})
|
||||
|
||||
if(BUILD_MAN_DOCS)
|
||||
file(GLOB man_rst RELATIVE ${ECM_SOURCE_DIR}/docs/manual
|
||||
${ECM_SOURCE_DIR}/docs/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}")
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/man/${name}.${sec}
|
||||
DESTINATION ${MAN_INSTALL_DIR}/man${sec}
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
if(BUILD_HTML_DOCS)
|
||||
install(
|
||||
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
|
||||
DESTINATION ${DOC_INSTALL_DIR}
|
||||
PATTERN .buildinfo EXCLUDE
|
||||
PATTERN objects.inv EXCLUDE
|
||||
)
|
||||
endif()
|
||||
if(BUILD_QTHELP_DOCS)
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/qthelp/ExtraCMakeModules.qch
|
||||
DESTINATION ${DOC_INSTALL_DIR}
|
||||
)
|
||||
endif()
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/Find7Zip.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/Find7z.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/FindCanberra.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/FindEGL.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/FindGLIB2.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/FindGperf.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/FindGradle.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/FindIcoTool.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/FindInotify.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/FindIsoCodes.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/FindKF5.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/FindLibExiv2.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/FindLibGit2.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/FindLibMount.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/FindLibcap.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/FindOpenEXR.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/FindPhoneNumber.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/FindPoppler.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/FindPulseAudio.cmake
|
||||
+1
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/FindQtWaylandScanner.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/FindSasl2.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/FindSeccomp.cmake
|
||||
+1
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/FindSharedMimeInfo.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/FindTaglib.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/FindUDev.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/FindWayland.cmake
|
||||
+1
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/FindWaylandProtocols.cmake
|
||||
+1
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/FindWaylandScanner.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/FindX11_XCB.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/FindXCB.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/Findepoxy.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../find-modules/Findgzip.cmake
|
||||
@@ -0,0 +1,19 @@
|
||||
.. title:: Extra CMake Modules Reference Documentation
|
||||
|
||||
Reference Manuals
|
||||
#################
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:glob:
|
||||
|
||||
/manual/ecm.7
|
||||
/manual/*
|
||||
|
||||
.. only:: html
|
||||
|
||||
Index and Search
|
||||
################
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`search`
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../kde-modules/KDECMakeSettings.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../kde-modules/KDEClangFormat.cmake
|
||||
+1
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../kde-modules/KDECompilerSettings.cmake
|
||||
+1
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../kde-modules/KDEFrameworkCompilerSettings.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../kde-modules/KDEGitCommitHooks.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../kde-modules/KDEInstallDirs.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../kde-modules/KDEInstallDirs5.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../kde-modules/KDEInstallDirs6.cmake
|
||||
+1
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../kde-modules/KDEMetaInfoPlatformCheck.cmake
|
||||
+1
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../kde-modules/KDEPackageAppTemplates.cmake
|
||||
@@ -0,0 +1,239 @@
|
||||
.. ecm-manual-description: ECM Developer Reference
|
||||
|
||||
ecm-developer(7)
|
||||
****************
|
||||
|
||||
.. only:: html or latex
|
||||
|
||||
.. contents::
|
||||
|
||||
|
||||
Writing Modules
|
||||
===============
|
||||
|
||||
The CMake 3 documentation (and `cmake-developer(7)`_ in particular) has a lot of
|
||||
useful information about writing CMake modules, including a large section
|
||||
devoted to find modules. This guide will only highlight things that are
|
||||
particular to the Extra CMake Modules project.
|
||||
|
||||
Most of these are stylistic points. For example, the license header for a module
|
||||
in ECM should look like:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
# SPDX-FileCopyrightText: 20XX Your Name <your.email@example.com>
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
Documentation is written in reStructuredText format and put inside a bracket
|
||||
comment with a ``.rst:`` id after the opening bracket:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
The docs
|
||||
#]=======================================================================]
|
||||
|
||||
(docs/sphinx/ext/ecm.py has code to extract the rst text from a comment with
|
||||
such wrapping)
|
||||
|
||||
Functions should be used instead of macros unless there is a good reason not to
|
||||
(and that reason should be noted in a comment), and lowercase should be used for
|
||||
macros, functions and commands.
|
||||
|
||||
4 spaces is the generally-recommended indent, although there are several files
|
||||
that use 2 spaces; consistency within a file is more important than consistency
|
||||
across files.
|
||||
|
||||
If in doubt, look at how other modules in Extra CMake Modules are written, and
|
||||
follow the same pattern.
|
||||
|
||||
|
||||
Find Modules
|
||||
------------
|
||||
|
||||
A good template for find module documentation is:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
FindFoo
|
||||
-------
|
||||
|
||||
Finds the Foo library.
|
||||
|
||||
This will define the following variables:
|
||||
|
||||
``Foo_FOUND``
|
||||
True if (the requested version of) Foo is available
|
||||
``Foo_VERSION``
|
||||
The version of Foo, if it is found
|
||||
``Foo_LIBRARIES``
|
||||
This can be passed to target_link_libraries() instead of the ``Foo::Foo``
|
||||
target
|
||||
``Foo_INCLUDE_DIRS``
|
||||
This should be passed to target_include_directories() if the target is not
|
||||
used for linking
|
||||
``Foo_DEFINITIONS``
|
||||
This should be passed to target_compile_options() if the target is not
|
||||
used for linking
|
||||
|
||||
If ``Foo_FOUND`` is TRUE, it will also define the following imported target:
|
||||
|
||||
``Foo::Foo``
|
||||
The Foo library
|
||||
|
||||
In general we recommend using the imported target, as it is easier to use.
|
||||
Bear in mind, however, that if the target is in the link interface of an
|
||||
exported library, it must be made available by the package config file.
|
||||
#]=======================================================================]
|
||||
|
||||
Note the use of definition lists for the variables.
|
||||
|
||||
Because of the :module:`ECMUseFindModules` module, projects may easily make
|
||||
local copies of find modules, and may install those copies with their own CMake
|
||||
project config files. For this reason, find modules should include the full BSD
|
||||
3-clause license::
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 20XX Your Name <your.email@example.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of the author may not be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#=============================================================================
|
||||
|
||||
Find modules should always provide imported targets in addition to the
|
||||
traditional variables (like ``Foo_LIBRARIES``, etc).
|
||||
|
||||
Unlike find modules shipped with CMake, if the module requires a specific CMake
|
||||
version it is not enough to warn when the minimum required version is not high
|
||||
enough: you should also produce an error when the actual CMake version being
|
||||
used is not high enough. This can be done with:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
if(CMAKE_VERSION VERSION_LESS 3.16.0)
|
||||
message(FATAL_ERROR "CMake 3.16.0 is required by FindFoo.cmake")
|
||||
endif()
|
||||
if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 3.16.0)
|
||||
message(AUTHOR_WARNING "Your project should require at least CMake 3.16.0 to use FindFoo.cmake")
|
||||
endif()
|
||||
|
||||
The :module:`ECMFindModuleHelpers` module has several useful functions and
|
||||
macros. For example, it allows you to replace the above version check with:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
ecm_find_package_version_check(Foo)
|
||||
|
||||
Components
|
||||
~~~~~~~~~~
|
||||
|
||||
Using :module:`ECMFindModuleHelpers`, creating a find module for a library with
|
||||
several inter-dependent components is reasonably straightforward. After the
|
||||
documentation, you need to include the module and do the usual version check:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
include(ECMFindModuleHelpers)
|
||||
ecm_find_package_version_check(Foo)
|
||||
|
||||
The important macros are ``ecm_find_package_parse_components`` and
|
||||
``ecm_find_package_handle_library_components``. These take a list of
|
||||
components, and query other variables you provide to find out the information
|
||||
they require. The documentation for :module:`ECMFindModuleHelpers` provides
|
||||
more information, but a simple setup might look like:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
set(Foo_known_components Bar Baz)
|
||||
set(Foo_Bar_pkg_config "foo-bar")
|
||||
set(Foo_Bar_lib "bar")
|
||||
set(Foo_Bar_header "foo/bar.h")
|
||||
set(Foo_Bar_pkg_config "foo-baz")
|
||||
set(Foo_Baz_lib "baz")
|
||||
set(Foo_Baz_header "foo/baz.h")
|
||||
|
||||
If ``Baz`` depends on ``Bar``, for example, you can specify this with
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
set(Foo_Baz_component_deps "Bar")
|
||||
|
||||
Then call the macros:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
ecm_find_package_parse_components(Foo
|
||||
RESULT_VAR Foo_components
|
||||
KNOWN_COMPONENTS ${Foo_known_components}
|
||||
)
|
||||
ecm_find_package_handle_library_components(Foo
|
||||
COMPONENTS ${Foo_components}
|
||||
)
|
||||
|
||||
Of course, if your components need unusual handling, you may want to replace
|
||||
``ecm_find_package_handle_library_components`` with, for example, a ``foreach``
|
||||
loop over the components (the body of which should implement most of what a
|
||||
normal find module does, including setting ``Foo_<component>_FOUND``).
|
||||
|
||||
At this point, you should set ``Foo_VERSION`` using whatever information you
|
||||
have available (such as from parsing header files). Note that
|
||||
``ecm_find_package_handle_library_components`` will set it to the version
|
||||
reported by pkg-config of the first component found, but this depends on the
|
||||
presence of pkg-config files, and the version of a component may not be the same
|
||||
as the version of the whole package. After that, finish off with
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Foo
|
||||
FOUND_VAR
|
||||
Foo_FOUND
|
||||
REQUIRED_VARS
|
||||
Foo_LIBRARIES
|
||||
VERSION_VAR
|
||||
Foo_VERSION
|
||||
HANDLE_COMPONENTS
|
||||
)
|
||||
|
||||
include(FeatureSummary)
|
||||
set_package_properties(Foo PROPERTIES
|
||||
URL "https://www.foo.example.com/"
|
||||
DESCRIPTION "A library for doing useful things")
|
||||
|
||||
|
||||
Submitting Modules
|
||||
==================
|
||||
|
||||
Proposed new modules should be submitted using the `KDE Review Board instance`_,
|
||||
and be assigned to the ``buildsystem`` and ``extracmakemodules`` groups. You
|
||||
should be able to point to two separate projects that will make use of the
|
||||
module.
|
||||
|
||||
The mailing list can be found at
|
||||
https://mail.kde.org/mailman/listinfo/kde-buildsystem\ .
|
||||
|
||||
|
||||
.. _KDE Review Board instance: https://git.reviewboard.kde.org/
|
||||
.. _cmake-developer(7): https://www.cmake.org/cmake/help/git-master/manual/cmake-developer.7.html
|
||||
@@ -0,0 +1,64 @@
|
||||
.. ecm-manual-description: ECM Find Modules Reference
|
||||
|
||||
ecm-find-modules(7)
|
||||
*******************
|
||||
|
||||
.. only:: html or latex
|
||||
|
||||
.. contents::
|
||||
|
||||
Introduction
|
||||
============
|
||||
|
||||
Find modules are used by the CMake ``find_package`` command to search for
|
||||
packages that do not provide their own CMake package config files. CMake
|
||||
provides an extensive set of find modules, and Extra CMake Modules (ECM) adds
|
||||
to that.
|
||||
|
||||
To use ECM's find modules, you need to tell CMake to find the ECM package, and
|
||||
then add either ``${ECM_MODULE_PATH}`` or ``${ECM_FIND_MODULE_DIR}`` to the
|
||||
``CMAKE_MODULE_PATH`` variable:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
find_package(ECM REQUIRED NO_MODULE)
|
||||
set(CMAKE_MODULE_PATH ${ECM_FIND_MODULE_DIR})
|
||||
|
||||
Using ``${ECM_MODULE_PATH}`` will also make the modules intended for direct use
|
||||
by CMake scripts available (see :manual:`ecm-modules(7)` and
|
||||
:manual:`ecm-kde-modules(7)`).
|
||||
|
||||
You can also make local copies of find modules using the
|
||||
``ecm_use_find_modules`` function from :module:`ECMUseFindModules`, which is
|
||||
automatically included when ECM is found:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
find_package(ECM REQUIRED NO_MODULE)
|
||||
ecm_use_find_modules(
|
||||
DIR "${CMAKE_BINARY_DIR}/cmake"
|
||||
MODULES FindEGL.cmake
|
||||
)
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_BINARY_DIR}/cmake")
|
||||
|
||||
This allows selective use of ECM's find modules, and the NO_OVERRIDE argument
|
||||
can be used to ensure that if CMake ships its own version of that find module,
|
||||
it will be used instead.
|
||||
|
||||
|
||||
All Find Modules
|
||||
================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:glob:
|
||||
|
||||
/find-module/*
|
||||
|
||||
.. only:: man
|
||||
|
||||
See Also
|
||||
========
|
||||
|
||||
:manual:`ecm(7)`, :manual:`ecm-modules(7)`, :manual:`ecm-kde-modules(7)`
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
.. ecm-manual-description: ECM KDE Modules Reference
|
||||
|
||||
ecm-kde-modules(7)
|
||||
******************
|
||||
|
||||
.. only:: html or latex
|
||||
|
||||
.. contents::
|
||||
|
||||
Introduction
|
||||
============
|
||||
|
||||
Extra CMake Modules (ECM) provides several modules that provide default settings
|
||||
(like installation directories, compiler flags and other CMake options) aimed at
|
||||
software produced by the KDE modules; these are documented here. ECM also
|
||||
provides modules with more general functionality, documented in
|
||||
:manual:`ecm-modules(7)`, and ones that extend the functionality of the
|
||||
``find_package`` command, documented in :manual:`ecm-find-modules(7)`.
|
||||
|
||||
To use these modules, you need to tell CMake to find the ECM package, and
|
||||
then add either ``${ECM_MODULE_PATH}`` or ``${ECM_KDE_MODULE_DIR}`` to the
|
||||
``CMAKE_MODULE_PATH`` variable:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
find_package(ECM REQUIRED NO_MODULE)
|
||||
set(CMAKE_MODULE_PATH ${ECM_MODULE_DIR})
|
||||
|
||||
Using ``${ECM_MODULE_PATH}`` will also make the other types of modules
|
||||
available.
|
||||
|
||||
All KDE Modules
|
||||
===============
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:glob:
|
||||
|
||||
/kde-module/*
|
||||
|
||||
.. only:: man
|
||||
|
||||
See Also
|
||||
========
|
||||
|
||||
:manual:`ecm(7)`, :manual:`ecm-modules(7)`, :manual:`ecm-find-modules(7)`
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
.. ecm-manual-description: ECM Modules Reference
|
||||
|
||||
ecm-modules(7)
|
||||
**************
|
||||
|
||||
.. only:: html or latex
|
||||
|
||||
.. contents::
|
||||
|
||||
Introduction
|
||||
============
|
||||
|
||||
Extra CMake Modules (ECM) provides various modules that provide useful functions
|
||||
for CMake scripts. ECM actually provides three types of modules that can be
|
||||
used from CMake scripts: those that extend the functionality of the
|
||||
``find_package`` command are documented in :manual:`ecm-find-modules(7)`; those
|
||||
that provide standard settings for software produced by the KDE community are
|
||||
documented in :manual:`ecm-kde-modules(7)`. The rest provide macros and
|
||||
functions for general use by CMake scripts and are documented here.
|
||||
|
||||
To use these modules, you need to tell CMake to find the ECM package, and
|
||||
then add either ``${ECM_MODULE_PATH}`` or ``${ECM_MODULE_DIR}`` to the
|
||||
``CMAKE_MODULE_PATH`` variable:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
find_package(ECM REQUIRED NO_MODULE)
|
||||
set(CMAKE_MODULE_PATH ${ECM_MODULE_DIR})
|
||||
|
||||
Using ``${ECM_MODULE_PATH}`` will also make the find modules and KDE modules
|
||||
available.
|
||||
|
||||
Note that there are also toolchain modules, documented in
|
||||
:manual:`ecm-toolchains(7)`, but these are used by users building the software
|
||||
rather than developers writing CMake scripts.
|
||||
|
||||
|
||||
All Modules
|
||||
===========
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:glob:
|
||||
|
||||
/module/*
|
||||
|
||||
.. only:: man
|
||||
|
||||
See Also
|
||||
========
|
||||
|
||||
:manual:`ecm(7)`, :manual:`ecm-find-modules(7)`, :manual:`ecm-kde-modules(7)`
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
.. ecm-manual-description: ECM Toolchains Reference
|
||||
|
||||
ecm-toolchains(7)
|
||||
*****************
|
||||
|
||||
.. only:: html or latex
|
||||
|
||||
.. contents::
|
||||
|
||||
Introduction
|
||||
============
|
||||
|
||||
Extra CMake Modules (ECM) provides some toolchain modules. Unlike normal
|
||||
modules, these are not included directly in projects, but specified with
|
||||
the ``CMAKE_TOOLCHAIN_FILE`` cache variable on the commandline.
|
||||
|
||||
|
||||
All Modules
|
||||
===========
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:glob:
|
||||
|
||||
/toolchain/*
|
||||
|
||||
.. only:: man
|
||||
|
||||
See Also
|
||||
========
|
||||
|
||||
:manual:`ecm(7)`
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
.. ecm-manual-description: Extra CMake Modules
|
||||
|
||||
ecm(7)
|
||||
******
|
||||
|
||||
.. only:: html or latex
|
||||
|
||||
.. contents::
|
||||
|
||||
.. include:: ../../README.rst
|
||||
:start-line: 2
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/CheckAtomic.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMAddAndroidApk.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMAddAppIcon.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMAddQch.cmake
|
||||
+1
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMAddQtDesignerPlugin.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMAddTests.cmake
|
||||
+1
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMCheckOutboundLicense.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMConfiguredInstall.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMCoverageOption.cmake
|
||||
+1
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMCreateQmFromPoFiles.cmake
|
||||
+1
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMDeprecationSettings.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMEnableSanitizers.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMFindModuleHelpers.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMFindQmlModule.cmake
|
||||
+1
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMGenerateDBusServiceFile.cmake
|
||||
+1
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMGenerateExportHeader.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMGenerateHeaders.cmake
|
||||
+1
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMGeneratePkgConfigFile.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMGeneratePriFile.cmake
|
||||
+1
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMGeneratePythonBindings.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMGenerateQmlTypes.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMInstallIcons.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMMarkAsTest.cmake
|
||||
+1
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMMarkNonGuiExecutable.cmake
|
||||
+1
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMOptionalAddSubdirectory.cmake
|
||||
+1
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMPackageConfigHelpers.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMPoQmTools.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMQmlModule.cmake
|
||||
+1
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMQtDeclareLoggingCategory.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMQueryQt.cmake
|
||||
+1
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMSetupQtPluginMacroNames.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMSetupVersion.cmake
|
||||
+1
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMSourceVersionControl.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMUninstallTarget.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMUseFindModules.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/ECMWinResolveSymlinks.cmake
|
||||
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../modules/QtVersionOption.cmake
|
||||
@@ -0,0 +1 @@
|
||||
*.pyc
|
||||
@@ -0,0 +1,56 @@
|
||||
#=============================================================================
|
||||
# CMake - Cross Platform Makefile Generator
|
||||
# SPDX-FileCopyrightText: 2000-2013 Kitware Inc., Insight Software Consortium
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#=============================================================================
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
import glob
|
||||
|
||||
sys.path.insert(0, r'@CMAKE_CURRENT_SOURCE_DIR@/sphinx/ext')
|
||||
|
||||
source_suffix = '.rst'
|
||||
master_doc = 'index'
|
||||
|
||||
project = 'Extra CMake Modules'
|
||||
copyright = 'KDE Developers'
|
||||
version = '@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@' # feature version
|
||||
release = '@PROJECT_VERSION@' # full version string
|
||||
|
||||
primary_domain = 'ecm'
|
||||
|
||||
exclude_patterns = []
|
||||
|
||||
extensions = ['ecm']
|
||||
|
||||
ecm_manuals = sorted(glob.glob(r'@CMAKE_CURRENT_SOURCE_DIR@/manual/*.rst'))
|
||||
ecm_manual_description = re.compile(r'^\.\. ecm-manual-description:(.*)$')
|
||||
man_pages = []
|
||||
for fpath in ecm_manuals:
|
||||
try:
|
||||
name, sec, rst = os.path.basename(fpath).split('.')
|
||||
desc = None
|
||||
f = open(fpath, 'r')
|
||||
for l in f:
|
||||
m = ecm_manual_description.match(l)
|
||||
if m:
|
||||
desc = m.group(1).strip()
|
||||
break
|
||||
f.close()
|
||||
if desc:
|
||||
man_pages.append(('manual/%s.%s' % (name, sec),
|
||||
name, desc, [], int(sec)))
|
||||
else:
|
||||
sys.stderr.write("ERROR: No ecm-manual-description in '%s'\n" % fpath)
|
||||
except Exception as e:
|
||||
sys.stderr.write("ERROR: %s\n" % str(e))
|
||||
man_show_urls = False
|
||||
|
||||
html_show_sourcelink = True
|
||||
html_static_path = ['@CMAKE_CURRENT_BINARY_DIR@/static']
|
||||
html_style = 'ecm.css'
|
||||
html_theme = '@sphinx_theme@'
|
||||
html_short_title = 'ECM %s documentation' % version
|
||||
html_favicon = '@CMAKE_CURRENT_SOURCE_DIR@/sphinx/kde-favicon.ico'
|
||||
@@ -0,0 +1,8 @@
|
||||
/* Import the Sphinx theme style. */
|
||||
@import url("${sphinx_theme}.css");
|
||||
|
||||
/* Wrap sidebar content even within words so that long
|
||||
document names do not escape sidebar borders. */
|
||||
div.sphinxsidebarwrapper {
|
||||
word-wrap: break-word;
|
||||
}
|
||||
@@ -0,0 +1,290 @@
|
||||
# SPDX-FileCopyrightText: 2014 Alex Merry <alex.merry@kde.org>
|
||||
#
|
||||
# Based on cmake.py from CMake:
|
||||
# SPDX-FileCopyrightText: 2000-2013 Kitware Inc., Insight Software Consortium
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
import html
|
||||
import os
|
||||
import re
|
||||
|
||||
# Monkey patch for pygments reporting an error when generator expressions are
|
||||
# used.
|
||||
# https://bitbucket.org/birkenfeld/pygments-main/issue/942/cmake-generator-expressions-not-handled
|
||||
from pygments.lexers import CMakeLexer
|
||||
from pygments.token import Name, Operator
|
||||
from pygments.lexer import bygroups
|
||||
CMakeLexer.tokens["args"].append(('(\\$<)(.+?)(>)',
|
||||
bygroups(Operator, Name.Variable, Operator)))
|
||||
|
||||
# Monkey patch for sphinx generating invalid content for qcollectiongenerator
|
||||
# https://bitbucket.org/birkenfeld/sphinx/issue/1435/qthelp-builder-should-htmlescape-keywords
|
||||
try:
|
||||
from sphinxcontrib.qthelp import QtHelpBuilder
|
||||
except ImportError:
|
||||
# sphinx < 4.0
|
||||
from sphinx.builders.qthelp import QtHelpBuilder
|
||||
old_build_keywords = QtHelpBuilder.build_keywords
|
||||
def new_build_keywords(self, title, refs, subitems):
|
||||
old_items = old_build_keywords(self, title, refs, subitems)
|
||||
new_items = []
|
||||
for item in old_items:
|
||||
before, rest = item.split("ref=\"", 1)
|
||||
ref, after = rest.split("\"")
|
||||
if ("<" in ref and ">" in ref):
|
||||
new_items.append(before + "ref=\"" + html.escape(ref) + "\"" + after)
|
||||
else:
|
||||
new_items.append(item)
|
||||
return new_items
|
||||
QtHelpBuilder.build_keywords = new_build_keywords
|
||||
|
||||
from docutils.parsers.rst import Directive, directives
|
||||
from docutils.transforms import Transform
|
||||
try:
|
||||
from docutils.utils.error_reporting import SafeString, ErrorString
|
||||
except ImportError:
|
||||
# error_reporting was not in utils before version 0.11:
|
||||
from docutils.error_reporting import SafeString, ErrorString
|
||||
|
||||
from docutils import io, nodes
|
||||
|
||||
from sphinx.directives import ObjectDescription
|
||||
from sphinx.domains import Domain, ObjType
|
||||
from sphinx.roles import XRefRole
|
||||
from sphinx.util.nodes import make_refnode
|
||||
from sphinx import addnodes
|
||||
|
||||
class ECMModule(Directive):
|
||||
required_arguments = 1
|
||||
optional_arguments = 0
|
||||
final_argument_whitespace = True
|
||||
option_spec = {'encoding': directives.encoding}
|
||||
|
||||
def __init__(self, *args, **keys):
|
||||
self.re_start = re.compile(r'^#\[(?P<eq>=*)\[\.rst:$')
|
||||
Directive.__init__(self, *args, **keys)
|
||||
|
||||
def run(self):
|
||||
settings = self.state.document.settings
|
||||
if not settings.file_insertion_enabled:
|
||||
raise self.warning('"%s" directive disabled.' % self.name)
|
||||
|
||||
env = self.state.document.settings.env
|
||||
rel_path, path = env.relfn2path(self.arguments[0])
|
||||
path = os.path.normpath(path)
|
||||
encoding = self.options.get('encoding', settings.input_encoding)
|
||||
e_handler = settings.input_encoding_error_handler
|
||||
try:
|
||||
settings.record_dependencies.add(path)
|
||||
f = io.FileInput(source_path=path, encoding=encoding,
|
||||
error_handler=e_handler)
|
||||
except UnicodeEncodeError:
|
||||
raise self.severe('Problems with "%s" directive path:\n'
|
||||
'Cannot encode input file path "%s" '
|
||||
'(wrong locale?).' %
|
||||
(self.name, SafeString(path)))
|
||||
except IOError as error:
|
||||
raise self.severe('Problems with "%s" directive path:\n%s.' %
|
||||
(self.name, ErrorString(error)))
|
||||
raw_lines = f.read().splitlines()
|
||||
f.close()
|
||||
rst = None
|
||||
lines = []
|
||||
for line in raw_lines:
|
||||
if rst is not None and rst != '#':
|
||||
# Bracket mode: check for end bracket
|
||||
pos = line.find(rst)
|
||||
if pos >= 0:
|
||||
if line[0] == '#':
|
||||
line = ''
|
||||
else:
|
||||
line = line[0:pos]
|
||||
rst = None
|
||||
else:
|
||||
# Line mode: check for .rst start (bracket or line)
|
||||
m = self.re_start.match(line)
|
||||
if m:
|
||||
rst = ']%s]' % m.group('eq')
|
||||
line = ''
|
||||
elif line == '#.rst:':
|
||||
rst = '#'
|
||||
line = ''
|
||||
elif rst == '#':
|
||||
if line == '#' or line[:2] == '# ':
|
||||
line = line[2:]
|
||||
else:
|
||||
rst = None
|
||||
line = ''
|
||||
elif rst is None:
|
||||
line = ''
|
||||
lines.append(line)
|
||||
if rst is not None and rst != '#':
|
||||
raise self.warning('"%s" found unclosed bracket "#[%s[.rst:" in %s' %
|
||||
(self.name, rst[1:-1], path))
|
||||
self.state_machine.insert_input(lines, path)
|
||||
return []
|
||||
|
||||
class _ecm_index_entry:
|
||||
def __init__(self, desc):
|
||||
self.desc = desc
|
||||
|
||||
def __call__(self, title, targetid):
|
||||
return ('pair', u'%s ; %s' % (self.desc, title), targetid, 'main', None)
|
||||
|
||||
_ecm_index_objs = {
|
||||
'manual': _ecm_index_entry('manual'),
|
||||
'module': _ecm_index_entry('module'),
|
||||
'find-module': _ecm_index_entry('find-module'),
|
||||
'kde-module': _ecm_index_entry('kde-module'),
|
||||
'toolchain': _ecm_index_entry('toolchain'),
|
||||
}
|
||||
|
||||
def _ecm_object_inventory(env, document, line, objtype, targetid):
|
||||
inv = env.domaindata['ecm']['objects']
|
||||
if targetid in inv:
|
||||
document.reporter.warning(
|
||||
'ECM object "%s" also described in "%s".' %
|
||||
(targetid, env.doc2path(inv[targetid][0])), line=line)
|
||||
inv[targetid] = (env.docname, objtype)
|
||||
|
||||
class ECMTransform(Transform):
|
||||
|
||||
# Run this transform early since we insert nodes we want
|
||||
# treated as if they were written in the documents.
|
||||
default_priority = 210
|
||||
|
||||
def __init__(self, document, startnode):
|
||||
Transform.__init__(self, document, startnode)
|
||||
self.titles = {}
|
||||
|
||||
def parse_title(self, docname):
|
||||
"""Parse a document title as the first line starting in [A-Za-z0-9<]
|
||||
or fall back to the document basename if no such line exists.
|
||||
Return the title or False if the document file does not exist.
|
||||
"""
|
||||
env = self.document.settings.env
|
||||
title = self.titles.get(docname)
|
||||
if title is None:
|
||||
fname = os.path.join(env.srcdir, docname+'.rst')
|
||||
try:
|
||||
f = open(fname, 'r')
|
||||
except IOError:
|
||||
title = False
|
||||
else:
|
||||
for line in f:
|
||||
if len(line) > 0 and (line[0].isalnum() or line[0] == '<'):
|
||||
title = line.rstrip()
|
||||
break
|
||||
f.close()
|
||||
if title is None:
|
||||
title = os.path.basename(docname)
|
||||
self.titles[docname] = title
|
||||
return title
|
||||
|
||||
def apply(self):
|
||||
env = self.document.settings.env
|
||||
|
||||
# Treat some documents as ecm domain objects.
|
||||
objtype, sep, tail = env.docname.rpartition('/')
|
||||
make_index_entry = _ecm_index_objs.get(objtype)
|
||||
if make_index_entry:
|
||||
title = self.parse_title(env.docname)
|
||||
# Insert the object link target.
|
||||
targetid = '%s:%s' % (objtype, title)
|
||||
targetnode = nodes.target('', '', ids=[targetid])
|
||||
self.document.insert(0, targetnode)
|
||||
# Insert the object index entry.
|
||||
indexnode = addnodes.index()
|
||||
indexnode['entries'] = [make_index_entry(title, targetid)]
|
||||
self.document.insert(0, indexnode)
|
||||
# Add to ecm domain object inventory
|
||||
_ecm_object_inventory(env, self.document, 1, objtype, targetid)
|
||||
|
||||
class ECMObject(ObjectDescription):
|
||||
|
||||
def handle_signature(self, sig, signode):
|
||||
# called from sphinx.directives.ObjectDescription.run()
|
||||
signode += addnodes.desc_name(sig, sig)
|
||||
return sig
|
||||
|
||||
def add_target_and_index(self, name, sig, signode):
|
||||
targetid = '%s:%s' % (self.objtype, name)
|
||||
if targetid not in self.state.document.ids:
|
||||
signode['names'].append(targetid)
|
||||
signode['ids'].append(targetid)
|
||||
signode['first'] = (not self.names)
|
||||
self.state.document.note_explicit_target(signode)
|
||||
_ecm_object_inventory(self.env, self.state.document,
|
||||
self.lineno, self.objtype, targetid)
|
||||
|
||||
make_index_entry = _ecm_index_objs.get(self.objtype)
|
||||
if make_index_entry:
|
||||
self.indexnode['entries'].append(make_index_entry(name, targetid))
|
||||
|
||||
class ECMXRefRole(XRefRole):
|
||||
|
||||
# See sphinx.util.nodes.explicit_title_re; \x00 escapes '<'.
|
||||
_re = re.compile(r'^(.+?)(\s*)(?<!\x00)<(.*?)>$', re.DOTALL)
|
||||
_re_sub = re.compile(r'^([^()\s]+)\s*\(([^()]*)\)$', re.DOTALL)
|
||||
|
||||
def __call__(self, typ, rawtext, text, *args, **keys):
|
||||
# CMake cross-reference targets may contain '<' so escape
|
||||
# any explicit `<target>` with '<' not preceded by whitespace.
|
||||
while True:
|
||||
m = ECMXRefRole._re.match(text)
|
||||
if m and len(m.group(2)) == 0:
|
||||
text = '%s\x00<%s>' % (m.group(1), m.group(3))
|
||||
else:
|
||||
break
|
||||
return XRefRole.__call__(self, typ, rawtext, text, *args, **keys)
|
||||
|
||||
class ECMDomain(Domain):
|
||||
"""ECM domain."""
|
||||
name = 'ecm'
|
||||
label = 'ECM'
|
||||
object_types = {
|
||||
'module': ObjType('module', 'module'),
|
||||
'kde-module': ObjType('kde-module', 'kde-module'),
|
||||
'find-module': ObjType('find-module', 'find-module'),
|
||||
'manual': ObjType('manual', 'manual'),
|
||||
'toolchain': ObjType('toolchain', 'toolchain'),
|
||||
}
|
||||
directives = {}
|
||||
roles = {
|
||||
'module': XRefRole(),
|
||||
'kde-module': XRefRole(),
|
||||
'find-module': XRefRole(),
|
||||
'manual': XRefRole(),
|
||||
'toolchain': XRefRole(),
|
||||
}
|
||||
initial_data = {
|
||||
'objects': {}, # fullname -> docname, objtype
|
||||
}
|
||||
|
||||
def clear_doc(self, docname):
|
||||
to_clear = []
|
||||
for fullname, (fn, _) in self.data['objects'].items():
|
||||
if fn == docname:
|
||||
to_clear.append(fullname)
|
||||
for fullname in to_clear:
|
||||
del self.data['objects'][fullname]
|
||||
|
||||
def resolve_xref(self, env, fromdocname, builder,
|
||||
typ, target, node, contnode):
|
||||
targetid = '%s:%s' % (typ, target)
|
||||
obj = self.data['objects'].get(targetid)
|
||||
if obj is None:
|
||||
# TODO: warn somehow?
|
||||
return None
|
||||
return make_refnode(builder, fromdocname, obj[0], targetid,
|
||||
contnode, target)
|
||||
|
||||
def get_objects(self):
|
||||
for refname, (docname, type) in self.data['objects'].items():
|
||||
yield (refname, refname, type, docname, refname, 1)
|
||||
|
||||
def setup(app):
|
||||
app.add_directive('ecm-module', ECMModule)
|
||||
app.add_transform(ECMTransform)
|
||||
app.add_domain(ECMDomain)
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
@@ -0,0 +1 @@
|
||||
.. ecm-module:: ../../toolchain/Android.cmake
|
||||
Reference in New Issue
Block a user