Standard for determining Qt presence at compile time?

Sysprogs forums Forums VisualGDB Standard for determining Qt presence at compile time?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #9989
    hfrmobile
    Participant

    Exists there a “standard way” to determine at compile time if  it is a Qt project or not?

    Of course I can add an own QT preprocessor macro in the qmake project settings/Project/Preproecessor macros and in code doing this:

    #if QT
      ...
    else
      ...
    endif // QT

    Did the same for “DEBUG” since the project template when Qt is checked doesn’t had it but the but the project template (shell/console) when not using Qt has a DEBUG in make file setting …

     

    • This topic was modified 7 years, 10 months ago by hfrmobile.
    #10001
    support
    Keymaster

    Hi,

    You could try checking for QT_CORE_LIB, but if you want a 100% accurate answer, we would recommend asking on the Qt forums.

    #10015
    hfrmobile
    Participant

    Thanks for your reply.

    Can’t ask the Qt forums since my question is related to VisualGDB because:

    In the Linux project wizard I can choose “Application (executable file)”:

    • Use MSBuild
    • Use GNU Make
    • Use CMake
    • Use Qt

    I have chosen “Qt” for one project and “GNU Make” for the other.

    <span style=”text-decoration: underline;”>Background:</span> I share some sources between the two VisualGDB projects (one with Qt, the other without).

    For the moment I’ve added a preprocessor macro QT_PRESENCE to the VisualGDB settings and in the shared header/source files I do something like this:

    #ifdef QT_PRESENCE
        #include "Something that is using Qt"
    #endif

    To put my question in other words: How can I determine the “application type”?

     

    #10029
    support
    Keymaster

    Hi,

    Unfortunately this is not possible directly. Selecting one of the build subsystems simply tells VisualGDB how to build the project, but it does not automatically add any special preprocessor macros to the project settings. So the only way to detect Qt out-of-the-box would be to check for macros that QMake itself defines.

    Defining a macro like QT_PRESENCE via VisualGDB Project Settings is also a good workaround.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.