aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorFriedrich W. H. Kossebau <kossebau@kde.org>2021-01-28 20:55:37 +0100
committerFriedrich W. H. Kossebau <kossebau@kde.org>2021-02-22 14:42:18 +0100
commit3ee63fed9cb6e063e3ac0fc0d9763fafd85df7e2 (patch)
tree056a12a82b507f8ab63bca17df53b81080c667c9 /modules
parent944c81500b712c1951fb545ce2b9e61bd01e0ac5 (diff)
downloadextra-cmake-modules-3ee63fed9cb6e063e3ac0fc0d9763fafd85df7e2.tar.gz
extra-cmake-modules-3ee63fed9cb6e063e3ac0fc0d9763fafd85df7e2.tar.bz2
ecm_qt_declare_logging_category: support target arg to append source file to
Diffstat (limited to 'modules')
-rw-r--r--modules/ECMQtDeclareLoggingCategory.cmake22
1 files changed, 15 insertions, 7 deletions
diff --git a/modules/ECMQtDeclareLoggingCategory.cmake b/modules/ECMQtDeclareLoggingCategory.cmake
index 720a5013..a6562333 100644
--- a/modules/ECMQtDeclareLoggingCategory.cmake
+++ b/modules/ECMQtDeclareLoggingCategory.cmake
@@ -12,7 +12,7 @@
#
# ::
#
-# ecm_qt_declare_logging_category(<sources_var>
+# ecm_qt_declare_logging_category(<sources_var_name(|target (since 5.80))>
# HEADER <filename>
# IDENTIFIER <identifier>
# CATEGORY_NAME <category_name>
@@ -23,11 +23,15 @@
# )
#
# A header file, ``<filename>``, will be generated along with a corresponding
-# source file, which will be added to ``<sources_var>``. These will provide a
-# QLoggingCategory category that can be referred to from C++ code using
-# ``<identifier>``, and from the logging configuration using
+# source file. These will provide a QLoggingCategory category that can be referred
+# to from C++ code using ``<identifier>``, and from the logging configuration using
# ``<category_name>``.
#
+# The generated source file will be added to the variable with the name
+# ``<sources_var_name>``. If the given argument is a target though, instead both the
+# generated header file and the generated source file will be added to the target as
+# private sources (since 5.80).
+#
# If ``<filename>`` is not absolute, it will be taken relative to the current
# binary directory.
#
@@ -265,9 +269,13 @@ function(ecm_qt_declare_logging_category sources_var)
configure_file("${_ECM_QT_DECLARE_LOGGING_CATEGORY_TEMPLATE_CPP}" "${cpp_filename}")
configure_file("${_ECM_QT_DECLARE_LOGGING_CATEGORY_TEMPLATE_H}" "${ARG_HEADER}")
- set(sources "${${sources_var}}")
- list(APPEND sources "${cpp_filename}")
- set(${sources_var} "${sources}" PARENT_SCOPE)
+ if(TARGET ${sources_var})
+ target_sources(${sources_var} PRIVATE ${cpp_filename} "${ARG_HEADER}")
+ else()
+ set(sources "${${sources_var}}")
+ list(APPEND sources "${cpp_filename}")
+ set(${sources_var} "${sources}" PARENT_SCOPE)
+ endif()
# note data in global properties
if (ARG_EXPORT)