summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2023-04-24 10:09:46 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2023-04-24 14:55:32 +0000
commitf86d8c72103e45e68a681c8e5f0bd91fef758141 (patch)
treeac3a89a8ce17de66f3577f35bfa6ba8650b627b7
parent254e13ee98bb551ac3882596d71b3a9c081cd11f (diff)
downloadqbs-f86d8c72103e45e68a681c8e5f0bd91fef758141.tar.gz
Fix build for configuration that enables tests, but disables unit tests
It's probably not worth adding an extra export macro for that, so just enable QBS_AUTOTEST_EXPORT if any tests are enabled. Amends b3509323a4552eb1c4a43218cb715904400d0d62. Change-Id: I3573ae59de98f192d6ae3630b973857f911b3eaa Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
-rw-r--r--cmake/QbsBuildConfig.cmake3
-rw-r--r--src/lib/corelib/corelib.qbs21
-rw-r--r--src/lib/corelib/tools/qbs_export.h4
3 files changed, 18 insertions, 10 deletions
diff --git a/cmake/QbsBuildConfig.cmake b/cmake/QbsBuildConfig.cmake
index 4e49cf4b3..e0a7d76d7 100644
--- a/cmake/QbsBuildConfig.cmake
+++ b/cmake/QbsBuildConfig.cmake
@@ -85,6 +85,9 @@ set(DEFAULT_DEFINES "")
if(WIN32)
list(APPEND DEFAULT_DEFINES UNICODE _UNICODE _SCL_SECURE_NO_WARNINGS)
endif()
+if(WITH_TESTS)
+ list(APPEND DEFAULT_DEFINES QBS_WITH_TESTS)
+endif()
# CMake 3.10 doesn't have list(TRANSFORM)
function(list_transform_prepend var prefix)
diff --git a/src/lib/corelib/corelib.qbs b/src/lib/corelib/corelib.qbs
index f33c483da..358e6e353 100644
--- a/src/lib/corelib/corelib.qbs
+++ b/src/lib/corelib/corelib.qbs
@@ -14,14 +14,19 @@ QbsLibrary {
".",
"../.." // for the plugin headers
])
- property stringList enableUnitTestsDefines:
- qbsbuildconfig.enableUnitTests ? ["QBS_ENABLE_UNIT_TESTS"] : []
- property stringList systemSettingsDirDefines: qbsbuildconfig.systemSettingsDir
- ? ['QBS_SYSTEM_SETTINGS_DIR="' + qbsbuildconfig.systemSettingsDir + '"'] : []
- cpp.defines: base.concat([
- "QBS_RELATIVE_LIBEXEC_PATH=" + Utilities.cStringQuote(qbsbuildconfig.relativeLibexecPath),
- "QBS_VERSION=" + Utilities.cStringQuote(version),
- ]).concat(enableUnitTestsDefines).concat(systemSettingsDirDefines)
+ cpp.defines: {
+ var defines = base.concat([
+ "QBS_RELATIVE_LIBEXEC_PATH=" + Utilities.cStringQuote(qbsbuildconfig.relativeLibexecPath),
+ "QBS_VERSION=" + Utilities.cStringQuote(version),
+ ]);
+ if (project.withTests)
+ defines.push("QBS_WITH_TESTS");
+ if (qbsbuildconfig.enableUnitTests)
+ defines.push("QBS_ENABLE_UNIT_TESTS");
+ if (qbsbuildconfig.systemSettingsDir)
+ defines.push('QBS_SYSTEM_SETTINGS_DIR="' + qbsbuildconfig.systemSettingsDir + '"');
+ return defines;
+ }
Properties {
condition: qbs.targetOS.contains("windows")
diff --git a/src/lib/corelib/tools/qbs_export.h b/src/lib/corelib/tools/qbs_export.h
index 164aa4184..2cfe1cd82 100644
--- a/src/lib/corelib/tools/qbs_export.h
+++ b/src/lib/corelib/tools/qbs_export.h
@@ -53,14 +53,14 @@
#else
# ifdef QBS_LIBRARY
# define QBS_EXPORT QBS_DECL_EXPORT
-# ifdef QBS_ENABLE_UNIT_TESTS
+# ifdef QBS_WITH_TESTS
# define QBS_AUTOTEST_EXPORT QBS_DECL_EXPORT
# else
# define QBS_AUTOTEST_EXPORT
# endif
# else
# define QBS_EXPORT QBS_DECL_IMPORT
-# ifdef QBS_ENABLE_UNIT_TESTS
+# ifdef QBS_WITH_TESTS
# define QBS_AUTOTEST_EXPORT QBS_DECL_IMPORT
# else
# define QBS_AUTOTEST_EXPORT