path: root/cmake/QtModuleHelpers.cmake
diff options
authorAlexandru Croitor <>2020-10-30 13:29:55 +0100
committerAlexandru Croitor <>2020-10-30 21:59:20 +0000
commit53b11882c829ddb46c46ede2c010f6b49e86ae2b (patch)
tree9f93651a1aafc39badf8bc4329aade0e4873d3e7 /cmake/QtModuleHelpers.cmake
parent0c3def85c61cea1f51d712c43c2c25fd788e6573 (diff)
CMake: Cleanup module and plugin define situation
The QT.<module>.DEFINES assignment in pri files needs to take into account the module name when computing the define name. This is the MODULE value that qmake specifies. In CMake that would be the value of CONFIG_MODULE_NAME. Previously the value of the define was computed in qt_internal_module_info() without taking into account the module name. While qt_internal_module_info() ended being used also for plugins and other target types, the defines computed by it were meant to be used only for Qt modules. Thus remove the <result>_define assignment from qt_internal_module_info and move its computation directly into qt_internal_add_module, taking into account the value of CONFIG_MODULE_NAME. The only other use of module_define was in qt_internal_add_plugin but that was merely a long overdue copy-paste error, qmake doesn't propagate QT_FOO_LIB defines for plugins. As result, a define special case in testlib is not needed anymore, because the define is now computed properly. Finally, QT_FOO_LIB should not be used while building the Qt module itself, so instead of using PUBLIC_DEFINES option of qt_internal_extend_target, use target_compile_definitions(INTERFACE) directly. Change-Id: I4d44f7461bac2f0c09aec3e995d02dfe36e00883 Reviewed-by: Joerg Bornemann <>
Diffstat (limited to 'cmake/QtModuleHelpers.cmake')
1 files changed, 11 insertions, 6 deletions
diff --git a/cmake/QtModuleHelpers.cmake b/cmake/QtModuleHelpers.cmake
index 6431bba589..b75b67f441 100644
--- a/cmake/QtModuleHelpers.cmake
+++ b/cmake/QtModuleHelpers.cmake
@@ -23,6 +23,11 @@ function(qt_internal_add_module target)
set(arg_CONFIG_MODULE_NAME "${module_lower}")
+ # Module define needs to take into account the config module name.
+ string(TOUPPER "${arg_CONFIG_MODULE_NAME}" module_define_infix)
+ string(REPLACE "-" "_" module_define_infix "${module_define_infix}")
+ string(REPLACE "." "_" module_define_infix "${module_define_infix}")
### Define Targets:
set(is_interface_lib 0)
set(is_shared_lib 0)
@@ -330,7 +335,7 @@ function(qt_internal_add_module target)
- QT_BUILD_${module_define}_LIB ### FIXME: use QT_BUILD_ADDON for Add-ons or remove if we don't have add-ons anymore
+ QT_BUILD_${module_define_infix}_LIB ### FIXME: use QT_BUILD_ADDON for Add-ons or remove if we don't have add-ons anymore
@@ -344,7 +349,6 @@ function(qt_internal_add_module target)
- QT_${module_define}_LIB
@@ -367,6 +371,11 @@ function(qt_internal_add_module target)
+ # The public module define is not meant to be used when building the module itself,
+ # it's only meant to be used for consumers of the module,
+ # thus we can't use qt_internal_extend_target()'s PUBLIC_DEFINES option.
+ target_compile_definitions(${target} INTERFACE QT_${module_define_infix}_LIB)
@@ -637,20 +646,16 @@ endfunction()
# * foo_include_dir with the module's include directory
# e.g for QtQuick it would be qtdeclarative_build_dir/include/QtQuick for a prefix build or
# qtbase_build_dir/include/QtQuick for a non-prefix build
-# * foo_define same as foo_uper but with - replaced as _
function(qt_internal_module_info result target)
set(module "Qt${target}")
set("${result}" "${module}" PARENT_SCOPE)
set("${result}_versioned" "Qt${PROJECT_VERSION_MAJOR}${target}" PARENT_SCOPE)
string(TOUPPER "${target}" upper)
string(TOLOWER "${target}" lower)# * foo_upper with the value "CORE"
- string(REPLACE "-" "_" define "${upper}")
- string(REPLACE "." "_" define "${define}")
set("${result}_upper" "${upper}" PARENT_SCOPE)
set("${result}_lower" "${lower}" PARENT_SCOPE)
set("${result}_repo_include_dir" "${QT_BUILD_DIR}/include" PARENT_SCOPE)
set("${result}_include_dir" "${QT_BUILD_DIR}/include/${module}" PARENT_SCOPE)
- set("${result}_define" "${define}" PARENT_SCOPE)
# Generate a module description file based on the template in