Merge topic 'automoc-specific-include-dirs'

39677f4cc6 AUTOMOC: Add option to specify moc include directories explicitly

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Acked-by: Osyotr <zhenchik35026@gmail.com>
Merge-request: !10640
This commit is contained in:
Brad King
2025-05-21 12:46:00 +00:00
committed by Kitware Robot
13 changed files with 199 additions and 22 deletions

View File

@@ -145,6 +145,7 @@ Properties on Targets
/prop_tgt/AUTOMOC_COMPILER_PREDEFINES
/prop_tgt/AUTOMOC_DEPEND_FILTERS
/prop_tgt/AUTOMOC_EXECUTABLE
/prop_tgt/AUTOMOC_INCLUDE_DIRECTORIES
/prop_tgt/AUTOMOC_MACRO_NAMES
/prop_tgt/AUTOMOC_MOC_OPTIONS
/prop_tgt/AUTOMOC_PATH_PREFIX

View File

@@ -427,6 +427,7 @@ Variables that Control the Build
/variable/CMAKE_AUTOMOC
/variable/CMAKE_AUTOMOC_COMPILER_PREDEFINES
/variable/CMAKE_AUTOMOC_DEPEND_FILTERS
/variable/CMAKE_AUTOMOC_INCLUDE_DIRECTORIES
/variable/CMAKE_AUTOMOC_MACRO_NAMES
/variable/CMAKE_AUTOMOC_MOC_OPTIONS
/variable/CMAKE_AUTOMOC_PATH_PREFIX

View File

@@ -34,6 +34,11 @@ At configuration time, a list of header files that should be scanned by
and adds these to the scan list.
- The :prop_tgt:`AUTOMOC_INCLUDE_DIRECTORIES` target property may be set
to explicitly tell ``moc`` what include directories to search. If not
set, the default is to use the include directories from the target and
its transitive closure of dependencies.
At build time, CMake scans each unknown or modified header file from the
list and searches for
@@ -222,6 +227,10 @@ defining file name filters in this target property.
Compiler pre definitions for ``moc`` are written to the ``moc_predefs.h`` file.
The generation of this file can be enabled or disabled in this target property.
:prop_tgt:`AUTOMOC_INCLUDE_DIRECTORIES`:
Specifies one or more include directories for ``AUTOMOC`` to pass explicitly to ``moc``
instead of automatically discovering a targets include directories.
:prop_sf:`SKIP_AUTOMOC`:
Sources and headers can be excluded from ``AUTOMOC`` processing by
setting this source file property.

View File

@@ -0,0 +1,30 @@
AUTOMOC_INCLUDE_DIRECTORIES
---------------------------
.. versionadded:: 4.1
Specifies zero or more include directories for AUTOMOC to pass explicitly to
the Qt MetaObject Compiler (``moc``) instead of automatically discovering a
target's include directories.
When this property is set on a target, only the directories listed here will be
used by :prop_tgt:`AUTOMOC`, and any other include paths will be ignored.
This property may contain :manual:`generator expressions <cmake-generator-expressions(7)>`.
All directory paths in the final evaluated result **must be absolute**. If any
non-absolute paths are present after generator expression evaluation,
configuration will fail with an error.
See also the :variable:`CMAKE_AUTOMOC_INCLUDE_DIRECTORIES` variable, which can
be used to initialize this property on all targets.
Example
^^^^^^^
.. code-block:: cmake
add_library(myQtLib ...)
set_property(TARGET myQtLib PROPERTY AUTOMOC_INCLUDE_DIRECTORIES
"${CMAKE_CURRENT_SOURCE_DIR}/include/myQtLib"
)

View File

@@ -0,0 +1,7 @@
automoc-include-directories
---------------------------
* The :prop_tgt:`AUTOMOC_INCLUDE_DIRECTORIES` target property and associated
:variable:`CMAKE_AUTOMOC_INCLUDE_DIRECTORIES` variable were added to
override the automatic discovery of moc includes from a target's transitive
include directories.

View File

@@ -0,0 +1,15 @@
CMAKE_AUTOMOC_INCLUDE_DIRECTORIES
---------------------------------
.. versionadded:: 4.1
Specifies zero or more include directories for AUTOMOC to pass explicitly to
the Qt MetaObject Compiler (``moc``) instead of automatically discovering
each target's include directories.
The directories listed here will replace any include paths discovered from
target properties such as :prop_tgt:`INCLUDE_DIRECTORIES`.
This variable is used to initialize the :prop_tgt:`AUTOMOC_INCLUDE_DIRECTORIES`
property on all the targets. See that target property for additional
information.