diff options
author | Friedrich W. H. Kossebau <kossebau@kde.org> | 2020-02-04 06:11:54 +0100 |
---|---|---|
committer | Friedrich W. H. Kossebau <kossebau@kde.org> | 2020-02-11 00:21:54 +0100 |
commit | 86041b6d8634a87e80e68fba44ad00bc4b4549ba (patch) | |
tree | d01060f502ae7bdb06a7661ccbca55dc3c9cceae /tests | |
parent | d8047a4654d0b4e541578747b3397d7bfb6f27fb (diff) | |
download | extra-cmake-modules-86041b6d8634a87e80e68fba44ad00bc4b4549ba.tar.gz extra-cmake-modules-86041b6d8634a87e80e68fba44ad00bc4b4549ba.tar.bz2 |
Add ecm_qt_install_logging_categories & ecm_qt_export_logging_category
Summary:
Having to manually maintain a separate copy of all the data about qt logging
categories in the categories files comes with the usual disadvantages.
The new macro ecm_qt_install_logging_categories together with the additions
of arguments DESCRIPTION & EXPORT to ecm_qt_declare_logging_category allows
to have just one place with one copy of the data, and have the categories
file automatically generated from that data, linked via the EXPORT id.
For cases not using ecm_qt_declare_logging_category, but having categories
manually defined in code, yet wanting to have info about those categories in
the installed fiel, ecm_qt_export_logging_category allows to add those data
to the system.
Test Plan:
Added unit tests work, porting of some repos created categories files whose
diff against the manually created files were only the DO_NOT_EDIT header.
Reviewers: #build_system, #frameworks, broulik, mlaurent
Reviewed By: mlaurent
Subscribers: kde-frameworks-devel, kde-buildsystem
Tags: #frameworks, #build_system
Differential Revision: https://phabricator.kde.org/D27150
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ECMQtDeclareLoggingCategoryTest/CMakeLists.txt | 50 | ||||
-rw-r--r-- | tests/ECMQtDeclareLoggingCategoryTest/log.categories | 6 | ||||
-rw-r--r-- | tests/ECMQtDeclareLoggingCategoryTest/log.renamecategories | 6 |
3 files changed, 62 insertions, 0 deletions
diff --git a/tests/ECMQtDeclareLoggingCategoryTest/CMakeLists.txt b/tests/ECMQtDeclareLoggingCategoryTest/CMakeLists.txt index 74f24317..a921fd3b 100644 --- a/tests/ECMQtDeclareLoggingCategoryTest/CMakeLists.txt +++ b/tests/ECMQtDeclareLoggingCategoryTest/CMakeLists.txt @@ -5,12 +5,35 @@ set(ECM_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../modules") set(CMAKE_MODULE_PATH ${ECM_MODULE_DIR}) include(ECMQtDeclareLoggingCategory) +include(CMakeParseArguments) + +function (check_file) + set(options) + set(oneValueArgs GENERATED EXPECTED) + set(multiValueArgs) + cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if (NOT EXISTS "${ARGS_GENERATED}") + message(FATAL_ERROR "${ARGS_GENERATED} was not generated") + endif() + file(READ "${ARGS_GENERATED}" generated_contents) + if (NOT EXISTS "${ARGS_EXPECTED}") + message(FATAL_ERROR "Original ${ARGS_EXPECTED} was not found") + endif() + file(READ "${ARGS_EXPECTED}" original_contents) + if (NOT "${generated_contents}" STREQUAL "${original_contents}") + message(FATAL_ERROR "${generated_file} contains '${generated_contents}' instead of '${original_contents}'") + endif() +endfunction() ecm_qt_declare_logging_category( sources HEADER "log1.h" IDENTIFIER "log1" CATEGORY_NAME "log.one" + OLD_CATEGORY_NAMES "log1old" + DESCRIPTION "log 1" + EXPORT LOG ) ecm_qt_declare_logging_category( @@ -18,6 +41,9 @@ ecm_qt_declare_logging_category( HEADER "log2.h" IDENTIFIER "foo::bar::log2" CATEGORY_NAME "log.two" + DEFAULT_SEVERITY Info + DESCRIPTION "log 2" + EXPORT LOG ) ecm_qt_declare_logging_category( @@ -28,6 +54,15 @@ ecm_qt_declare_logging_category( DEFAULT_SEVERITY Critical ) +ecm_qt_export_logging_category( + IDENTIFIER "log4" + CATEGORY_NAME "log.four" + OLD_CATEGORY_NAMES "logfouroldest" "log4old" + DEFAULT_SEVERITY Warning + EXPORT LOG + DESCRIPTION "log 4" +) + find_package(Qt5Core REQUIRED) add_executable(testmain testmain.cpp ${sources}) @@ -40,3 +75,18 @@ target_link_libraries(testmain Qt5::Core ) +ecm_qt_install_logging_categories( + EXPORT LOG + FILE log.categories + DESTINATION "${CMAKE_BINARY_DIR}/dummyinstall" +) + +check_file( + GENERATED "${CMAKE_CURRENT_BINARY_DIR}/log.categories" + EXPECTED "${CMAKE_CURRENT_SOURCE_DIR}/log.categories" +) +check_file( + GENERATED "${CMAKE_CURRENT_BINARY_DIR}/log.renamecategories" + EXPECTED "${CMAKE_CURRENT_SOURCE_DIR}/log.renamecategories" +) + diff --git a/tests/ECMQtDeclareLoggingCategoryTest/log.categories b/tests/ECMQtDeclareLoggingCategoryTest/log.categories new file mode 100644 index 00000000..267c5064 --- /dev/null +++ b/tests/ECMQtDeclareLoggingCategoryTest/log.categories @@ -0,0 +1,6 @@ +# KDebugSettings data file +# This file was generated by ecm_qt_install_logging_categories(). DO NOT EDIT! + +log.one log 1 IDENTIFIER [log1] +log.two log 2 DEFAULT_SEVERITY [INFO] IDENTIFIER [foo::bar::log2] +log.four log 4 DEFAULT_SEVERITY [WARNING] IDENTIFIER [log4] diff --git a/tests/ECMQtDeclareLoggingCategoryTest/log.renamecategories b/tests/ECMQtDeclareLoggingCategoryTest/log.renamecategories new file mode 100644 index 00000000..7bcac2fb --- /dev/null +++ b/tests/ECMQtDeclareLoggingCategoryTest/log.renamecategories @@ -0,0 +1,6 @@ +# KDebugSettings data file +# This file was generated by ecm_qt_install_logging_categories(). DO NOT EDIT! + +log1old log.one +logfouroldest log4old +log4old log.four |