aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-02-07 08:27:09 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-02-07 08:27:09 +0200
commit0c5c65f4377db0d6e303dec900e5561f6afdf7d3 (patch)
tree7f7ad0372617a860774490e669d1d7859987b66f
parent31ab17b60b7781a94b4d12681112f510a6a825bc (diff)
Take care of QT_REDUCE_RELOCATIONS-related error for ODB compiler
-rw-r--r--odb/qt/details/config.hxx17
-rw-r--r--odb/qt/version.options5
2 files changed, 22 insertions, 0 deletions
diff --git a/odb/qt/details/config.hxx b/odb/qt/details/config.hxx
index 0e968a2..d4c2bab 100644
--- a/odb/qt/details/config.hxx
+++ b/odb/qt/details/config.hxx
@@ -9,6 +9,23 @@
#ifdef _MSC_VER
#elif defined(ODB_COMPILER)
+// Qt5 may complain if we are building without -fPIC or -fPIE. Instead of
+// asking the user to pass one of these options to the ODB compiler (which
+// can, BTW, be done with -x -fPIE, for example, if one is not using the
+// Qt profile), we are going to define __PIE__ 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 <QtGlobals>, which is where the test for PIC/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.
+//
+# if defined(__ELF__) && !defined(__PIC__) && !defined(__PIE__)
+# include <QtCore/qconfig.h> // QT_REDUCE_RELOCATIONS
+# ifdef QT_REDUCE_RELOCATIONS
+# define __PIE__
+# endif
+# endif
# define LIBODB_QT_STATIC_LIB
#else
# include <odb/qt/details/config.h>
diff --git a/odb/qt/version.options b/odb/qt/version.options
index 262f339..43c3d39 100644
--- a/odb/qt/version.options
+++ b/odb/qt/version.options
@@ -2,6 +2,11 @@
# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC
# license : GNU GPL v2; see accompanying LICENSE file
+# Include the config file first so that it can do its thing before we
+# include any Qt headers.
+#
+--odb-prologue '#include <odb/qt/details/config.hxx>'
+
# Make sure the options files as seen by the ODB compiler and header
# files as seen by the C++ compiler have the same Qt interface version.
#