diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2012-05-30 12:09:00 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-28 06:21:48 +0200 |
commit | 96166fa56abb52157387c4911efbd4e5e6beee93 (patch) | |
tree | 4c7b1620d3f9964b41110b2a9c450ef85cc9ff0f /src | |
parent | 50eed2d068138e30d508f8b230cfaaeb116e659c (diff) |
Update the macros for shared/DLL and static builds
Up until now, we had a mess of different macros used for building
DLLs, for building shared libraries on Unix systems and for building
static libraries. Some of the macros were contradictory and did not
work. From now on, there shall be only:
- QT_STATIC: indicates that it's a static Qt build and the export
macros should expand to empty
- QT_SHARED: indicates that it's a shared / dynamic Qt build and the
export macros should expand to Q_DECL_EXPORT or Q_DECL_IMPORT,
depending on whether the macro corresponds to the current module
being built (the QT_BUILD_XXXX_LIB macro comes from the module's
.pro file)
QT_BOOTSTRAPPED implies QT_STATIC since the bootstrapped tools link
statically to some source code.
QT_STATIC is recorded in qconfig.h by configure when Qt is configured
for static builds. Nothing is recorded for a shared / dynamic build,
so QT_SHARED is implied if nothing is defined. This allows for the
existence of a static_and_shared build: with nothing recorded,
defining QT_STATIC before qglobal.h causes the export macros to be
that of the static form. Linking to the static libraries is out of the
scope of this change (something for the buildsystem and linker to
figure out).
From this commit on, the proper way of declaring the export macros for
a module called QtFoo is:
#ifndef QT_STATIC
# ifdef QT_BUILD_FOO_LIB
# define Q_FOO_EXPORT Q_DECL_EXPORT
# else
# define Q_FOO_EXPORT Q_DECL_IMPORT
# endif
#else
# define Q_FOO_EXPORT
#endif
The type of the Qt build is recorded in QT_CONFIG (in qconfig.pri) so
all Qt modules build by default the same type of library. The keywords
are "static" and "shared", used in both QT_CONFIG and CONFIG. The
previous keyword of "staticlib" is deprecated and should not be used.
Discussed-on: http://lists.qt-project.org/pipermail/development/2012-April/003172.html
Change-Id: I127896607794795b681c98d08467efd8af49bcf3
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/concurrent/qtconcurrent_global.h | 20 | ||||
-rw-r--r-- | src/corelib/global/qglobal.h | 122 | ||||
-rw-r--r-- | src/testlib/qtest_global.h | 2 |
3 files changed, 48 insertions, 96 deletions
diff --git a/src/concurrent/qtconcurrent_global.h b/src/concurrent/qtconcurrent_global.h index 422bca0258..7bcd6942c5 100644 --- a/src/concurrent/qtconcurrent_global.h +++ b/src/concurrent/qtconcurrent_global.h @@ -48,24 +48,14 @@ # define QT_NO_QFUTURE #endif -#if defined(Q_OS_WIN) && !defined(QT_NODLL) -# if defined(QT_MAKEDLL) -# if defined(QT_BUILD_CONCURRENT_LIB) -# define Q_CONCURRENT_EXPORT Q_DECL_EXPORT -# else -# define Q_CONCURRENT_EXPORT Q_DECL_IMPORT -# endif -# elif defined(QT_DLL) -# define Q_CONCURRENT_EXPORT Q_DECL_IMPORT -# endif -#endif - -#if !defined(Q_CONCURRENT_EXPORT) -# if defined(QT_SHARED) +#ifndef QT_STATIC +# if defined(QT_BUILD_CONCURRENT_LIB) # define Q_CONCURRENT_EXPORT Q_DECL_EXPORT # else -# define Q_CONCURRENT_EXPORT +# define Q_CONCURRENT_EXPORT Q_DECL_IMPORT # endif +#else +# define Q_CONCURRENT_EXPORT #endif #endif // include guard diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 93bdd3c03a..1710e7bb3e 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -460,16 +460,29 @@ class QDataStream; #define QT_SUPPORTS(FEATURE) (!defined(QT_NO_##FEATURE)) /* - Create Qt DLL if QT_DLL is defined (Windows only) + The Qt modules' export macros. + The options are: + - defined(QT_STATIC): Qt was built or is being built in static mode + - defined(QT_SHARED): Qt was built or is being built in shared/dynamic mode + If neither was defined, then QT_SHARED is implied. If Qt was compiled in static + mode, QT_STATIC is defined in qconfig.h. In shared mode, QT_STATIC is implied + for the bootstrapped tools. */ -#if defined(Q_OS_WIN) -# if defined(QT_NODLL) -# undef QT_MAKEDLL -# undef QT_DLL -# elif defined(QT_MAKEDLL) /* create a Qt DLL library */ -# if defined(QT_DLL) -# undef QT_DLL +#ifdef QT_BOOTSTRAPPED +# ifdef QT_SHARED +# error "QT_SHARED and QT_BOOTSTRAPPED together don't make sense. Please fix the build" +# elif !defined(QT_STATIC) +# define QT_STATIC +# endif +#endif + +#if defined(QT_SHARED) || !defined(QT_STATIC) +# ifdef QT_STATIC +# error "Both QT_SHARED and QT_STATIC defined, please make up your mind" +# else +# ifndef QT_SHARED +# define QT_SHARED # endif # if defined(QT_BUILD_CORE_LIB) # define Q_CORE_EXPORT Q_DECL_EXPORT @@ -561,76 +574,27 @@ class QDataStream; # else # define Q_DBUS_EXPORT Q_DECL_IMPORT # endif -# define Q_TEMPLATEDLL -# elif defined(QT_DLL) /* use a Qt DLL library */ -# define Q_CORE_EXPORT Q_DECL_IMPORT -# define Q_GUI_EXPORT Q_DECL_IMPORT -# define Q_WIDGETS_EXPORT Q_DECL_IMPORT -# define Q_PLATFORMSUPPORT_EXPORT Q_DECL_IMPORT -# define Q_PRINTSUPPORT_EXPORT Q_DECL_IMPORT -# define Q_SQL_EXPORT Q_DECL_IMPORT -# define Q_NETWORK_EXPORT Q_DECL_IMPORT -# define Q_SVG_EXPORT Q_DECL_IMPORT -# define Q_CANVAS_EXPORT Q_DECL_IMPORT -# define Q_OPENGL_EXPORT Q_DECL_IMPORT -# define Q_MULTIMEDIA_EXPORT Q_DECL_IMPORT -# define Q_OPENVG_EXPORT Q_DECL_IMPORT -# define Q_XML_EXPORT Q_DECL_IMPORT -# define Q_XMLPATTERNS_EXPORT Q_DECL_IMPORT -# define Q_SCRIPT_EXPORT Q_DECL_IMPORT -# define Q_SCRIPTTOOLS_EXPORT Q_DECL_IMPORT -# define Q_COMPAT_EXPORT Q_DECL_IMPORT -# define Q_DBUS_EXPORT Q_DECL_IMPORT -# define Q_TEMPLATEDLL # endif -# define Q_NO_DECLARED_NOT_DEFINED #else -# if defined(Q_OS_LINUX) && defined(Q_CC_BOR) -# define Q_TEMPLATEDLL -# define Q_NO_DECLARED_NOT_DEFINED -# endif -# undef QT_MAKEDLL /* ignore these for other platforms */ -# undef QT_DLL -#endif - -#if !defined(Q_CORE_EXPORT) -# if defined(QT_SHARED) -# define Q_CORE_EXPORT Q_DECL_EXPORT -# define Q_GUI_EXPORT Q_DECL_EXPORT -# define Q_WIDGETS_EXPORT Q_DECL_EXPORT -# define Q_PLATFORMSUPPORT_EXPORT Q_DECL_EXPORT -# define Q_PRINTSUPPORT_EXPORT Q_DECL_EXPORT -# define Q_SQL_EXPORT Q_DECL_EXPORT -# define Q_NETWORK_EXPORT Q_DECL_EXPORT -# define Q_SVG_EXPORT Q_DECL_EXPORT -# define Q_OPENGL_EXPORT Q_DECL_EXPORT -# define Q_MULTIMEDIA_EXPORT Q_DECL_EXPORT -# define Q_OPENVG_EXPORT Q_DECL_EXPORT -# define Q_XML_EXPORT Q_DECL_EXPORT -# define Q_XMLPATTERNS_EXPORT Q_DECL_EXPORT -# define Q_SCRIPT_EXPORT Q_DECL_EXPORT -# define Q_SCRIPTTOOLS_EXPORT Q_DECL_EXPORT -# define Q_COMPAT_EXPORT Q_DECL_EXPORT -# define Q_DBUS_EXPORT Q_DECL_EXPORT -# else -# define Q_CORE_EXPORT -# define Q_GUI_EXPORT -# define Q_WIDGETS_EXPORT -# define Q_PLATFORMSUPPORT_EXPORT -# define Q_PRINTSUPPORT_EXPORT -# define Q_SQL_EXPORT -# define Q_NETWORK_EXPORT -# define Q_SVG_EXPORT -# define Q_OPENGL_EXPORT -# define Q_MULTIMEDIA_EXPORT -# define Q_OPENVG_EXPORT -# define Q_XML_EXPORT -# define Q_XMLPATTERNS_EXPORT -# define Q_SCRIPT_EXPORT -# define Q_SCRIPTTOOLS_EXPORT -# define Q_COMPAT_EXPORT -# define Q_DBUS_EXPORT -# endif +# define Q_CORE_EXPORT +# define Q_GUI_EXPORT +# define Q_WIDGETS_EXPORT +# define Q_PLATFORMSUPPORT_EXPORT +# define Q_PRINTSUPPORT_EXPORT +# define Q_SQL_EXPORT +# define Q_NETWORK_EXPORT +# define Q_SVG_EXPORT +# define Q_QUICK1_EXPORT +# define Q_DECLARATIVE_EXPORT +# define Q_OPENGL_EXPORT +# define Q_MULTIMEDIA_EXPORT +# define Q_OPENVG_EXPORT +# define Q_XML_EXPORT +# define Q_SCRIPT_EXPORT +# define Q_SCRIPTTOOLS_EXPORT +# define Q_CANVAS_EXPORT +# define Q_COMPAT_EXPORT +# define Q_DBUS_EXPORT #endif /* @@ -638,12 +602,10 @@ class QDataStream; for Qt's internal unit tests. If you want slower loading times and more symbols that can vanish from version to version, feel free to define QT_BUILD_INTERNAL. */ -#if defined(QT_BUILD_INTERNAL) && defined(Q_OS_WIN) && defined(QT_MAKEDLL) +#if defined(QT_BUILD_INTERNAL) && defined(QT_BUILDING_QT) && defined(QT_SHARED) # define Q_AUTOTEST_EXPORT Q_DECL_EXPORT -#elif defined(QT_BUILD_INTERNAL) && defined(Q_OS_WIN) && defined(QT_DLL) +#elif defined(QT_BUILD_INTERNAL) && defined(QT_SHARED) # define Q_AUTOTEST_EXPORT Q_DECL_IMPORT -#elif defined(QT_BUILD_INTERNAL) && !defined(Q_OS_WIN) && defined(QT_SHARED) -# define Q_AUTOTEST_EXPORT Q_DECL_EXPORT #else # define Q_AUTOTEST_EXPORT #endif diff --git a/src/testlib/qtest_global.h b/src/testlib/qtest_global.h index 18d09ba162..13a813ce41 100644 --- a/src/testlib/qtest_global.h +++ b/src/testlib/qtest_global.h @@ -49,7 +49,7 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -#if !defined(QT_SHARED) && !defined(QT_DLL) +#if defined(QT_STATIC) # define Q_TESTLIB_EXPORT #else # ifdef QT_BUILD_TESTLIB_LIB |