summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-10-30 13:29:55 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-10-30 21:59:20 +0000
commit53b11882c829ddb46c46ede2c010f6b49e86ae2b (patch)
tree9f93651a1aafc39badf8bc4329aade0e4873d3e7
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 <joerg.bornemann@qt.io>
-rw-r--r--cmake/QtModuleHelpers.cmake17
-rw-r--r--cmake/QtPluginHelpers.cmake1
-rw-r--r--src/testlib/CMakeLists.txt1
3 files changed, 11 insertions, 8 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}")
endif()
+ # 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_USE_QSTRINGBUILDER
QT_DEPRECATED_WARNINGS
QT_BUILDING_QT
- 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
${deprecation_define}
)
endif()
@@ -344,7 +349,6 @@ function(qt_internal_add_module target)
${public_includes}
PUBLIC_DEFINES
${arg_PUBLIC_DEFINES}
- QT_${module_define}_LIB
DEFINES
${arg_DEFINES}
${defines_for_extend_target}
@@ -367,6 +371,11 @@ function(qt_internal_add_module target)
NO_PCH_SOURCES ${arg_NO_PCH_SOURCES}
)
+ # 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)
+
if(NOT ${arg_EXCEPTIONS} AND NOT ${arg_HEADER_MODULE})
qt_internal_set_no_exceptions_flags("${target}")
endif()
@@ -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)
endfunction()
# Generate a module description file based on the template in ModuleDescription.json.in
diff --git a/cmake/QtPluginHelpers.cmake b/cmake/QtPluginHelpers.cmake
index 07952bde48..3ded19f3e6 100644
--- a/cmake/QtPluginHelpers.cmake
+++ b/cmake/QtPluginHelpers.cmake
@@ -190,7 +190,6 @@ function(qt_internal_add_plugin target)
"${static_plugin_define}"
QT_PLUGIN
PUBLIC_DEFINES
- QT_${module_define}_LIB
${arg_PUBLIC_DEFINES}
FEATURE_DEPENDENCIES ${arg_FEATURE_DEPENDENCIES}
DBUS_ADAPTOR_SOURCES "${arg_DBUS_ADAPTOR_SOURCES}"
diff --git a/src/testlib/CMakeLists.txt b/src/testlib/CMakeLists.txt
index 733f86b2c7..718c792dcc 100644
--- a/src/testlib/CMakeLists.txt
+++ b/src/testlib/CMakeLists.txt
@@ -60,7 +60,6 @@ qt_internal_add_module(Test
QT_NO_CAST_TO_ASCII
QT_NO_DATASTREAM
QT_NO_FOREACH
- QT_BUILD_TESTLIB_LIB # special case
LIBRARIES
Qt::CorePrivate
PUBLIC_LIBRARIES