diff options
Diffstat (limited to 'libodb-qt/odb/qt/details')
-rw-r--r-- | libodb-qt/odb/qt/details/config.hxx | 32 | ||||
-rw-r--r-- | libodb-qt/odb/qt/details/export.hxx | 46 |
2 files changed, 78 insertions, 0 deletions
diff --git a/libodb-qt/odb/qt/details/config.hxx b/libodb-qt/odb/qt/details/config.hxx new file mode 100644 index 0000000..01a4eb5 --- /dev/null +++ b/libodb-qt/odb/qt/details/config.hxx @@ -0,0 +1,32 @@ +// file : odb/qt/details/config.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_QT_DETAILS_CONFIG_HXX +#define ODB_QT_DETAILS_CONFIG_HXX + +// no pre + +// Qt5 may complain if we are building without -fPIC. Instead of asking the +// user to pass one of these options to the ODB compiler (which can, BTW, be +// done with -x -fPIC, for example, if one is not using the Qt profile), we +// are going to define __PIC__ ourselves just to silence Qt. We also want to +// try to minimize this to cases where it is actually necessary. To achieve +// this, we need to include the Qt config file without including <QtGlobal>, +// which is where the test for PIE is. While newer versions of Qt (from 4.7) +// have <QtConfig>, to support older versions we will include qconfig.h +// directly. This file appears to be present in all the versions starting with +// Qt 4.0. +// +#ifdef ODB_COMPILER +# if defined(__ELF__) && !defined(__PIC__) +# include <QtCore/qconfig.h> // QT_REDUCE_RELOCATIONS +# ifdef QT_REDUCE_RELOCATIONS +# define __PIC__ +# endif +# endif +# define LIBODB_QT_STATIC +#endif + +// no post + +#endif // ODB_QT_DETAILS_CONFIG_HXX diff --git a/libodb-qt/odb/qt/details/export.hxx b/libodb-qt/odb/qt/details/export.hxx new file mode 100644 index 0000000..f38d0ee --- /dev/null +++ b/libodb-qt/odb/qt/details/export.hxx @@ -0,0 +1,46 @@ +// file : odb/qt/details/export.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_QT_DETAILS_EXPORT_HXX +#define ODB_QT_DETAILS_EXPORT_HXX + +#include <odb/pre.hxx> + +#include <odb/qt/details/config.hxx> // LIBODB_QT_STATIC if ODB_COMPILER + +// Normally we don't export class templates (but do complete specializations), +// inline functions, and classes with only inline member functions. Exporting +// classes that inherit from non-exported/imported bases (e.g., std::string) +// will end up badly. The only known workarounds are to not inherit or to not +// export. Also, MinGW GCC doesn't like seeing non-exported function being +// used before their inline definition. The workaround is to reorder code. In +// the end it's all trial and error. + +#if defined(LIBODB_QT_STATIC) // Using static. +# define LIBODB_QT_EXPORT +#elif defined(LIBODB_QT_STATIC_BUILD) // Building static. +# define LIBODB_QT_EXPORT +#elif defined(LIBODB_QT_SHARED) // Using shared. +# ifdef _WIN32 +# define LIBODB_QT_EXPORT __declspec(dllimport) +# else +# define LIBODB_QT_EXPORT +# endif +#elif defined(LIBODB_QT_SHARED_BUILD) // Building shared. +# ifdef _WIN32 +# define LIBODB_QT_EXPORT __declspec(dllexport) +# else +# define LIBODB_QT_EXPORT +# endif +#else +// If none of the above macros are defined, then we assume we are being used +// by some third-party build system that cannot/doesn't signal the library +// type. Note that this fallback works for both static and shared but in case +// of shared will be sub-optimal compared to having dllimport. +// +# define LIBODB_QT_EXPORT // Using static or shared. +#endif + +#include <odb/post.hxx> + +#endif // ODB_QT_DETAILS_EXPORT_HXX |