diff options
author | Friedrich W. H. Kossebau <kossebau@kde.org> | 2021-01-17 22:08:41 +0100 |
---|---|---|
committer | Friedrich W. H. Kossebau <kossebau@kde.org> | 2021-01-17 22:08:41 +0100 |
commit | 1704f7ab86253169615f19a9b10e2a832191b905 (patch) | |
tree | 6106ffc9e1a14ab4a9947134179d63a5e2bea0d1 /tests/ECMQtDeclareLoggingCategoryTest/check.cmake.in | |
parent | 50c0f8b05bd623af927d29dc01e5c7e7fb04dd34 (diff) | |
download | extra-cmake-modules-1704f7ab86253169615f19a9b10e2a832191b905.tar.gz extra-cmake-modules-1704f7ab86253169615f19a9b10e2a832191b905.tar.bz2 |
ECMQtDeclareLoggingCategory: create .categories files in build, not configure
Ensures that the files
* are re-created by build rule when accidentally deleted in the build dir
* are not getting new timestamps on every cmake run, even when content
has not changed
Diffstat (limited to 'tests/ECMQtDeclareLoggingCategoryTest/check.cmake.in')
-rw-r--r-- | tests/ECMQtDeclareLoggingCategoryTest/check.cmake.in | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/ECMQtDeclareLoggingCategoryTest/check.cmake.in b/tests/ECMQtDeclareLoggingCategoryTest/check.cmake.in new file mode 100644 index 00000000..2b684148 --- /dev/null +++ b/tests/ECMQtDeclareLoggingCategoryTest/check.cmake.in @@ -0,0 +1,35 @@ +set(CMAKE_MODULE_PATH "@MODULES_DIR@/../kde-modules") +set(CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@") +set(CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@") + + +########################################################### + +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() + + +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" +) |