diff options
Diffstat (limited to 'Help')
-rw-r--r-- | Help/prop_tgt/AUTOGEN_TARGET_DEPENDS.rst | 30 | ||||
-rw-r--r-- | Help/prop_tgt/AUTOMOC_DEPEND_FILTERS.rst | 95 | ||||
-rw-r--r-- | Help/release/dev/0-sample-topic.rst | 7 | ||||
-rw-r--r-- | Help/release/index.rst | 2 | ||||
-rw-r--r-- | Help/variable/CMAKE_NETRC.rst | 2 | ||||
-rw-r--r-- | Help/variable/CMAKE_NETRC_FILE.rst | 2 |
6 files changed, 101 insertions, 37 deletions
diff --git a/Help/prop_tgt/AUTOGEN_TARGET_DEPENDS.rst b/Help/prop_tgt/AUTOGEN_TARGET_DEPENDS.rst index f522c6b..7d3dfd1 100644 --- a/Help/prop_tgt/AUTOGEN_TARGET_DEPENDS.rst +++ b/Help/prop_tgt/AUTOGEN_TARGET_DEPENDS.rst @@ -3,15 +3,29 @@ AUTOGEN_TARGET_DEPENDS Target dependencies of the corresponding ``_autogen`` target. -Targets which have their :prop_tgt:`AUTOMOC` target ``ON`` have a -corresponding ``_autogen`` target which is used to autogenerate generate moc -files. As this ``_autogen`` target is created at generate-time, it is not -possible to define dependencies of it, such as to create inputs for the ``moc`` -executable. +Targets which have their :prop_tgt:`AUTOMOC` or :prop_tgt:`AUTOUIC` property +``ON`` have a corresponding ``_autogen`` target which is used to auto generate +``moc`` and ``uic`` files. As this ``_autogen`` target is created at +generate-time, it is not possible to define dependencies of it, +such as to create inputs for the ``moc`` or ``uic`` executable. -The ``AUTOGEN_TARGET_DEPENDS`` target property can be set instead to a list of -dependencies for the ``_autogen`` target. The buildsystem will be generated to -depend on its contents. +The :prop_tgt:`AUTOGEN_TARGET_DEPENDS` target property can be set instead to a +list of dependencies of the ``_autogen`` target. Dependencies can be target +names or file names. See the :manual:`cmake-qt(7)` manual for more information on using CMake with Qt. + +Use cases +^^^^^^^^^ + +If :prop_tgt:`AUTOMOC` or :prop_tgt:`AUTOUIC` depends on a file that is either + +- a :prop_sf:`GENERATED` non C++ file (e.g. a :prop_sf:`GENERATED` ``.json`` + or ``.ui`` file) or +- a :prop_sf:`GENERATED` C++ file that isn't recognized by :prop_tgt:`AUTOMOC` + and :prop_tgt:`AUTOUIC` because it's skipped by :prop_sf:`SKIP_AUTOMOC`, + :prop_sf:`SKIP_AUTOUIC`, :prop_sf:`SKIP_AUTOGEN` or :policy:`CMP0071` or +- a file that isn't in the target's sources + +it must added to :prop_tgt:`AUTOGEN_TARGET_DEPENDS`. diff --git a/Help/prop_tgt/AUTOMOC_DEPEND_FILTERS.rst b/Help/prop_tgt/AUTOMOC_DEPEND_FILTERS.rst index b738ecf..69957bf 100644 --- a/Help/prop_tgt/AUTOMOC_DEPEND_FILTERS.rst +++ b/Help/prop_tgt/AUTOMOC_DEPEND_FILTERS.rst @@ -1,21 +1,27 @@ AUTOMOC_DEPEND_FILTERS ---------------------- -Filter definitions used by :prop_tgt:`AUTOMOC` to extract file names from -source code as additional dependencies for the ``moc`` file. - -This property is only used if the :prop_tgt:`AUTOMOC` property is ``ON`` -for this target. +Filter definitions used by :prop_tgt:`AUTOMOC` to extract file names from a +source file that are registered as additional dependencies for the +``moc`` file of the source file. Filters are defined as ``KEYWORD;REGULAR_EXPRESSION`` pairs. First the file content is searched for ``KEYWORD``. If it is found at least once, then file names are extracted by successively searching for ``REGULAR_EXPRESSION`` and taking the first match group. -Consider a filter extracts the file name ``DEP`` from the content of a file -``FOO``. If ``DEP`` changes, then the ``moc`` file for ``FOO`` gets rebuilt. -The file ``DEP`` is searched for first in the vicinity -of ``FOO`` and afterwards in the target's :prop_tgt:`INCLUDE_DIRECTORIES`. +The file name found in the first match group is searched for + +- first in the vicinity of the source file +- and afterwards in the target's :prop_tgt:`INCLUDE_DIRECTORIES`. + +If any of the extracted files changes, then the ``moc`` file for the source +file gets rebuilt even when the source file itself doesn't change. + +If any of the extracted files is :prop_sf:`GENERATED` or if it is not in the +target's sources, then it might be necessary to add it to the +``_autogen`` target dependencies. +See :prop_tgt:`AUTOGEN_TARGET_DEPENDS` for reference. By default :prop_tgt:`AUTOMOC_DEPEND_FILTERS` is initialized from :variable:`CMAKE_AUTOMOC_DEPEND_FILTERS`, which is empty by default. @@ -24,22 +30,75 @@ See the :manual:`cmake-qt(7)` manual for more information on using CMake with Qt. -Example -^^^^^^^ +Example 1 +^^^^^^^^^ -Consider a file ``FOO.hpp`` holds a custom macro ``OBJ_JSON_FILE`` and we -want the ``moc`` file to depend on the macro`s file name argument:: +A header file ``my_class.hpp`` uses a custom macro ``JSON_FILE_MACRO`` which +is defined in an other header ``macros.hpp``. +We want the ``moc`` file of ``my_class.hpp`` to depend on the file name +argument of ``JSON_FILE_MACRO``:: + // my_class.hpp class My_Class : public QObject { Q_OBJECT - OBJ_JSON_FILE ( "DEP.json" ) + JSON_FILE_MACRO ( "info.json" ) + ... + }; + +In ``CMakeLists.txt`` we add a filter to +:variable:`CMAKE_AUTOMOC_DEPEND_FILTERS` like this:: + + list( APPEND CMAKE_AUTOMOC_DEPEND_FILTERS + "JSON_FILE_MACRO" + "[\n][ \t]*JSON_FILE_MACRO[ \t]*\\([ \t]*\"([^\"]+)\"" + ) + +We assume ``info.json`` is a plain (not :prop_sf:`GENERATED`) file that is +listed in the target's source. Therefore we do not need to add it to +:prop_tgt:`AUTOGEN_TARGET_DEPENDS`. + +Example 2 +^^^^^^^^^ + +In the target ``my_target`` a header file ``complex_class.hpp`` uses a +custom macro ``JSON_BASED_CLASS`` which is defined in an other header +``macros.hpp``:: + + // macros.hpp ... + #define JSON_BASED_CLASS(name, json) \ + class name : public QObject \ + { \ + Q_OBJECT \ + Q_PLUGIN_METADATA(IID "demo" FILE json) \ + name() {} \ }; + ... + +:: -Then we might use :variable:`CMAKE_AUTOMOC_DEPEND_FILTERS` to -define a filter like this:: + // complex_class.hpp + #pragma once + JSON_BASED_CLASS(Complex_Class, "meta.json") + // end of file - set(CMAKE_AUTOMOC_DEPEND_FILTERS - "OBJ_JSON_FILE" "[\n][ \t]*OBJ_JSON_FILE[ \t]*\\([ \t]*\"([^\"]+)\"" +Since ``complex_class.hpp`` doesn't contain a ``Q_OBJECT`` macro it would be +ignored by :prop_tgt:`AUTOMOC`. We change this by adding ``JSON_BASED_CLASS`` +to :variable:`CMAKE_AUTOMOC_MACRO_NAMES`:: + + list(APPEND CMAKE_AUTOMOC_MACRO_NAMES "JSON_BASED_CLASS") + +We want the ``moc`` file of ``complex_class.hpp`` to depend on +``meta.json``. So we add a filter to +:variable:`CMAKE_AUTOMOC_DEPEND_FILTERS`:: + + list(APPEND CMAKE_AUTOMOC_DEPEND_FILTERS + "JSON_BASED_CLASS" + "[\n^][ \t]*JSON_BASED_CLASS[ \t]*\\([^,]*,[ \t]*\"([^\"]+)\"" ) + +Additionally we assume ``meta.json`` is :prop_sf:`GENERATED` which is +why we have to add it to :prop_tgt:`AUTOGEN_TARGET_DEPENDS`:: + + set_property(TARGET my_target APPEND PROPERTY AUTOGEN_TARGET_DEPENDS "meta.json") diff --git a/Help/release/dev/0-sample-topic.rst b/Help/release/dev/0-sample-topic.rst deleted file mode 100644 index e4cc01e..0000000 --- a/Help/release/dev/0-sample-topic.rst +++ /dev/null @@ -1,7 +0,0 @@ -0-sample-topic --------------- - -* This is a sample release note for the change in a topic. - Developers should add similar notes for each topic branch - making a noteworthy change. Each document should be named - and titled to match the topic name to avoid merge conflicts. diff --git a/Help/release/index.rst b/Help/release/index.rst index 552922e..7375faf 100644 --- a/Help/release/index.rst +++ b/Help/release/index.rst @@ -7,8 +7,6 @@ CMake Release Notes This file should include the adjacent "dev.txt" file in development versions but not in release versions. -.. include:: dev.txt - Releases ======== diff --git a/Help/variable/CMAKE_NETRC.rst b/Help/variable/CMAKE_NETRC.rst index 52f857e..903ec31 100644 --- a/Help/variable/CMAKE_NETRC.rst +++ b/Help/variable/CMAKE_NETRC.rst @@ -2,7 +2,7 @@ CMAKE_NETRC ----------- This variable is used to initialize the ``NETRC`` option for -:command:`file(DOWNLOAD)` and :command:`file(DOWNLOAD)` commands and the +:command:`file(DOWNLOAD)` and :command:`file(UPLOAD)` commands and the module :module:`ExternalProject`. See those commands for additional information. diff --git a/Help/variable/CMAKE_NETRC_FILE.rst b/Help/variable/CMAKE_NETRC_FILE.rst index 1508f1e..0f09afe 100644 --- a/Help/variable/CMAKE_NETRC_FILE.rst +++ b/Help/variable/CMAKE_NETRC_FILE.rst @@ -2,7 +2,7 @@ CMAKE_NETRC_FILE ---------------- This variable is used to initialize the ``NETRC_FILE`` option for -:command:`file(DOWNLOAD)` and :command:`file(DOWNLOAD)` commands and the +:command:`file(DOWNLOAD)` and :command:`file(UPLOAD)` commands and the module :module:`ExternalProject`. See those commands for additional information. |