Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Using qmake to config project for gui or console
Forum Updated to NodeBB v4.3 + New Features

Using qmake to config project for gui or console

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 936 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T3STYT Offline
    T3STYT Offline
    T3STY
    wrote on last edited by
    #1

    I'm trying to use the same project for both a console application and gui application. When processing qmake it should define the correct CONFIG and QT defines so it'll prepare the project for one of them.
    I thought I could create a variable of my own where I define the value as either console or gui, and then I'd use the eval() function. In my .pro file I added these lines:
    @APP_MODE = con_app
    eval(APP_MODE= con_app) {
    message("building for console");
    }

    eval(APP_MODE = gui_app) {
    message("building for gui");
    }@
    Obviously, other than the messages there would be the proper CONFIG and QT defines for each. Unfortunately though, this seems not to be working. When running qmake in QtCreator, the general tab outputs both messages:
    @Project MESSAGE: console app
    Project MESSAGE: gui app
    Project MESSAGE: console app
    Project MESSAGE: gui app@
    Messages are also outputted twice, but I guess this is because qmake processes the .pro file twice or more times, not a big deal if it would properly evaluate APP_MODE as either con_app or gui_app.

    I then tried to use the contains() function instead of eval(), and this time it works, it correctly recognizes that APP_MODE contains either con_app or gui_app.

    What I'd like to know is if I am doing something wrong, and if it is a good approach for a "hybrid" .pro file.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved