From a959e34971f917a6141b826a5c08e3a96be78336 Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Mon, 15 May 2017 16:27:16 +0200 Subject: ecm_qt_declare_logging_category(): more unique include guard for header Summary: The old guard was created just from the identifier + _H, which runs the chance to clash in projects which use an identifier matching the project name and which also have a class or central file header which is named by the project and then has an include guard matching the filename. Example: project ABC -> abc.h with ABC_H guard identifier ABC, header debug.h -> debug.h with ABC_H guard any.cpp including both abc.h and debug.h will see only one content Using both the header file name and identifier for the guard name and prefixing it additionally with a macro specific term should make the guard both follow the usual pattern for guards matching the file name and also add some namespacing to allow for similar named header files in bigger projects (e.g. "debug.h") which could be included in the same include tree. Reviewers: #frameworks, #build_system Subscribers: elvisangelaccio Tags: #frameworks, #build_system Differential Revision: https://phabricator.kde.org/D5866 --- modules/ECMQtDeclareLoggingCategory.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules/ECMQtDeclareLoggingCategory.cmake') diff --git a/modules/ECMQtDeclareLoggingCategory.cmake b/modules/ECMQtDeclareLoggingCategory.cmake index bbed53ca..0db401c4 100644 --- a/modules/ECMQtDeclareLoggingCategory.cmake +++ b/modules/ECMQtDeclareLoggingCategory.cmake @@ -118,8 +118,9 @@ function(ecm_qt_declare_logging_category sources_var) get_filename_component(HEADER_NAME "${ARG_HEADER}" NAME) - string(REPLACE "::" "_" GUARD_NAME "${ARG_IDENTIFIER}_H") - string(TOUPPER "${GUARD_NAME}" GUARD_NAME) + string(REGEX REPLACE "[^a-zA-Z0-9]" "_" GUARD_NAME "${HEADER_NAME}") + string(REPLACE "::" "_" GUARD_PREFIX "ECM_QLOGGINGCATEGORY_${ARG_IDENTIFIER}") + string(TOUPPER "${GUARD_PREFIX}_${GUARD_NAME}" GUARD_NAME) if (NOT _ECM_QT_DECLARE_LOGGING_CATEGORY_TEMPLATE_CPP) message(FATAL_ERROR "You must include(ECMQtDeclareLoggingCategory) before using ecm_qt_declare_logging_category") -- cgit v1.2.1