[Development] [Interest] guidelines for modifying Qt's own build system?

Kevin Kofler kevin.kofler at chello.at
Sat Mar 14 20:09:13 CET 2015


Thiago Macieira wrote:

> On Saturday 14 March 2015 18:34:08 Kevin Kofler wrote:
>> Thiago Macieira wrote:
>> > [moving to dev; interest in BCC]
>> > 
>> > On Saturday 14 March 2015 16:44:33 René J.V. Bertin wrote:
>> >> I am working on a patch for QStandardPaths and a switch (to toggle
>> >> between OS X "native" locations and XDG/Linuxy locations) that should
>> >> be applied when building a Qt application, or at the latest when such
>> >> applications start up. The main (or at least of the biggest) class of
>> >> applications that are to benefit from this patch are KF5 applications.
>> >> That's a pretty large lot, one of the reasons why I would prefer to
>> >> make this switch operate through the build system and not by a
>> >> modification to myriads of source files.
>> > 
>> > Understood, but wasn't there an argument that the same Qt could be used
>> > by applications made to understand the OS X intricacies, like VLC?
>> 
>> If I understood correctly, his idea is that from the point of view of Qt,
>> the flag would be a RUNTIME flag. It would be passed by some inline code
>> in the application that depends only on the compile-time flags for the
>> APPLICATION, not for the Qt library. So different applications can use
>> different settings with the SAME Qt binaries.
> 
> So you want to create a static library whose only .o has a global
> constructor function that sets this flag?

I think the plan would be more like an inline function:

QStandardPaths() {
  init(QT_USE_FHS_PATHS);
}

(possibly with something like __attribute__((always_inline)) to ensure the 
inline function will always be used, bypassing the C++ one definition rule), 
where QT_USE_FHS_PATHS would be defined at application compile time.


I guess a solution that would be both source&binary compatible and 
independent of compiler-specific C++ extensions would be to have:

qstandardpaths.h:

class QAbstractStandardPaths {
  …
};

namespace FHSPaths {
  class QStandardPaths : public QAbstractStandardPaths {
    …
  };
}

namespace NonFHSPaths {
  class QStandardPaths : public QAbstractStandardPaths {
    …
  };
}

#ifdef QT_USE_FHS_PATHS
#if QT_USE_FHS_PATHS
using FHSPaths::QStandardPaths;
#else
using NonFHSPaths::QStandardPaths;
#endif
#endif

qstandardpaths.cpp:

#undef QT_USE_FHS_PATHS
#include <qstandardpaths.h>

// not declared in the header, only for binary compatibility with previous
// versions of Qt
class QStandardPaths : public QAbstractStandardPaths {
  …
}

// and then all the definitions for FHSPaths::QStandardPaths and
// NonFHSPaths::QStandardPaths

        Kevin Kofler




More information about the Development mailing list