summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/global/qlibraryinfo.cpp51
-rw-r--r--src/corelib/global/qlibraryinfo.h2
-rw-r--r--tests/manual/qpainfo/main.cpp4
3 files changed, 54 insertions, 3 deletions
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index 6ad94b5067..ed1715ddb5 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -255,6 +255,57 @@ QLibraryInfo::buildDate()
}
#endif //QT_NO_DATESTRING
+#if defined(Q_CC_CLANG) // must be before GNU, because clang claims to be GNU too
+# ifdef __apple_build_version__ // Apple clang has other version numbers
+# define COMPILER_STRING __clang_version__ " (Apple)"
+# else
+# define COMPILER_STRING __clang_version__
+# endif
+#elif defined(Q_CC_GNU)
+# define COMPILER_STRING "GCC " __VERSION__
+#elif defined(Q_CC_MSVC)
+# if _MSC_VER < 1600
+# define COMPILER_STRING "MSVC 2008"
+# elif _MSC_VER < 1700
+# define COMPILER_STRING "MSVC 2010"
+# elif _MSC_VER < 1800
+# define COMPILER_STRING "MSVC 2012"
+# elif _MSC_VER < 1900
+# define COMPILER_STRING "MSVC 2013"
+# else
+# define COMPILER_STRING "MSVC <unknown version>"
+# endif
+#else
+# define COMPILER_STRING "<unknown compiler>"
+#endif
+
+/*!
+ Returns a string describing how this version of Qt was built.
+
+ \internal
+
+ \since 5.3
+*/
+
+const char *QLibraryInfo::build()
+{
+ static const char data[] = "Qt " QT_VERSION_STR " (" __DATE__ "), "
+ COMPILER_STRING ", "
+#if QT_POINTER_SIZE == 4
+ "32"
+#else
+ "64"
+#endif
+ " bit, "
+#ifdef QT_NO_DEBUG
+ "release"
+#else
+ "debug"
+#endif
+ " build)";
+ return data;
+}
+
/*!
\since 5.0
Returns \c true if this build of Qt was built with debugging enabled, or
diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h
index 54ef794d3e..2a8a3b84b9 100644
--- a/src/corelib/global/qlibraryinfo.h
+++ b/src/corelib/global/qlibraryinfo.h
@@ -59,6 +59,8 @@ public:
static QDate buildDate();
#endif //QT_NO_DATESTRING
+ static const char * build();
+
static bool isDebugBuild();
enum LibraryLocation
diff --git a/tests/manual/qpainfo/main.cpp b/tests/manual/qpainfo/main.cpp
index 257b340467..c51ca6323b 100644
--- a/tests/manual/qpainfo/main.cpp
+++ b/tests/manual/qpainfo/main.cpp
@@ -116,10 +116,8 @@ int main(int argc, char **argv)
QGuiApplication app(argc, argv);
const QPlatformIntegration *platformIntegration = QGuiApplicationPrivate::platformIntegration();
- std::cout << "Qt " << QT_VERSION_STR << " on \"" << QGuiApplication::platformName().toStdString() << "\" "
- << QSysInfo::WordSize << " bit/"
+ std::cout << QLibraryInfo::build() << " on \"" << QGuiApplication::platformName().toStdString() << "\" "
<< (QSysInfo::ByteOrder == QSysInfo::LittleEndian ? "little endian" : "big endian") << '/'
- << (QLibraryInfo::isDebugBuild() ? "debug" : "release")
<< '\n';
#if defined(Q_OS_WIN)