aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedrich W. H. Kossebau <kossebau@kde.org>2017-05-15 16:27:16 +0200
committerFriedrich W. H. Kossebau <kossebau@kde.org>2017-05-23 23:01:51 +0200
commita959e34971f917a6141b826a5c08e3a96be78336 (patch)
tree058ff78074eaaef619101b88f0058d5628180ca4
parent97ba63aafa510e64c78a529cb5e88eebd2e97967 (diff)
downloadextra-cmake-modules-a959e34971f917a6141b826a5c08e3a96be78336.tar.gz
extra-cmake-modules-a959e34971f917a6141b826a5c08e3a96be78336.tar.bz2
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
-rw-r--r--modules/ECMQtDeclareLoggingCategory.cmake5
1 files changed, 3 insertions, 2 deletions
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")