Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Build subdirs template project
Forum Updated to NodeBB v4.3 + New Features

Build subdirs template project

Scheduled Pinned Locked Moved Solved Installation and Deployment
2 Posts 2 Posters 636 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.
  • F Offline
    F Offline
    FloatFlower.Huang
    wrote on last edited by FloatFlower.Huang
    #1

    I am writing a multiple projects managed by SUBDIRS template, my source code tree:

    / SubdirProject
    ├─ SubdirProject.pro
    ├─ /BarLib
    ├─── BarLib.pro
    ├─── barlib.h
    ├─── barlib_global.h
    ├─── barlib.cpp
    ├─ /FooApp
    └─── main.cpp
    

    I want to build this project to this build tree:

    /build
    ├─ FooApp.exe
    ├─ /lib
    └─── Barlib.dll
    

    however, my actually build tree like this:

    /build
    ├─BarLib
    │  ├─build
    │  │  ├─debug
    │  │  │  ├─ .moc
    │  │  │  ├─ .obj
    │  │  │  └─ Barlib.dll
    │  │  └─release
    │  │  │  ├─ .moc
    │  │  │  ├─ .obj
    │  │  │  └─ Barlib.dll
    │  ├─debug
    │  └─release
    └─FooApp
        ├─build
        │  ├─debug
        │  │  ├─ .moc
        │  │  ├─ .obj
        │  │  └─ FooApp.exe
        │  └─release
        │      ├─.moc
        │      ├─ .obj
        │      └─ FooApp.exe    
        ├─debug
        └─release
    

    Here are my .pro files:
    SubdirProject.pro file

    TEMPLATE = subdirs
    
    SUBDIRS += \
        BarLib \
        FooApp
    
    CONFIG += ordered
    

    Barlib.pro file

    // .. whatever
    
    release: DESTDIR = build/release
    debug:   DESTDIR = build/debug
    
    OBJECTS_DIR = $$DESTDIR/.obj
    MOC_DIR = $$DESTDIR/.moc
    RCC_DIR = $$DESTDIR/.qrc
    UI_DIR = $$DESTDIR/.ui
    

    FooApp.pro file

    // .. whatever
    
    release: DESTDIR = build/release
    debug:   DESTDIR = build/debug
    
    OBJECTS_DIR = $$DESTDIR/.obj
    MOC_DIR = $$DESTDIR/.moc
    RCC_DIR = $$DESTDIR/.qrc
    UI_DIR = $$DESTDIR/.ui
    

    How do I modify my project file that I can make my project be built to the build tree below? Futhermore, I have specify the OBJECT_DIR variable, why there are empty directory created, such as Barlib/release, Barlin/debug, etc ?

    Here is complete code: https://gist.github.com/floatflower/400f9150429a56590f280a0c49ae243f

    aha_1980A 1 Reply Last reply
    0
    • F FloatFlower.Huang

      I am writing a multiple projects managed by SUBDIRS template, my source code tree:

      / SubdirProject
      ├─ SubdirProject.pro
      ├─ /BarLib
      ├─── BarLib.pro
      ├─── barlib.h
      ├─── barlib_global.h
      ├─── barlib.cpp
      ├─ /FooApp
      └─── main.cpp
      

      I want to build this project to this build tree:

      /build
      ├─ FooApp.exe
      ├─ /lib
      └─── Barlib.dll
      

      however, my actually build tree like this:

      /build
      ├─BarLib
      │  ├─build
      │  │  ├─debug
      │  │  │  ├─ .moc
      │  │  │  ├─ .obj
      │  │  │  └─ Barlib.dll
      │  │  └─release
      │  │  │  ├─ .moc
      │  │  │  ├─ .obj
      │  │  │  └─ Barlib.dll
      │  ├─debug
      │  └─release
      └─FooApp
          ├─build
          │  ├─debug
          │  │  ├─ .moc
          │  │  ├─ .obj
          │  │  └─ FooApp.exe
          │  └─release
          │      ├─.moc
          │      ├─ .obj
          │      └─ FooApp.exe    
          ├─debug
          └─release
      

      Here are my .pro files:
      SubdirProject.pro file

      TEMPLATE = subdirs
      
      SUBDIRS += \
          BarLib \
          FooApp
      
      CONFIG += ordered
      

      Barlib.pro file

      // .. whatever
      
      release: DESTDIR = build/release
      debug:   DESTDIR = build/debug
      
      OBJECTS_DIR = $$DESTDIR/.obj
      MOC_DIR = $$DESTDIR/.moc
      RCC_DIR = $$DESTDIR/.qrc
      UI_DIR = $$DESTDIR/.ui
      

      FooApp.pro file

      // .. whatever
      
      release: DESTDIR = build/release
      debug:   DESTDIR = build/debug
      
      OBJECTS_DIR = $$DESTDIR/.obj
      MOC_DIR = $$DESTDIR/.moc
      RCC_DIR = $$DESTDIR/.qrc
      UI_DIR = $$DESTDIR/.ui
      

      How do I modify my project file that I can make my project be built to the build tree below? Futhermore, I have specify the OBJECT_DIR variable, why there are empty directory created, such as Barlib/release, Barlin/debug, etc ?

      Here is complete code: https://gist.github.com/floatflower/400f9150429a56590f280a0c49ae243f

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi @FloatFlower.Huang

      The additional debug and release folders are created on Windows because on Windows you cannot mix debug and release objects in one executable. Please see https://bugreports.qt.io/browse/QTBUG-52347 for more clarification.

      If you use shadow-building and never mix objects, than you can set CONFIG-=debug_and_release in your pro files and then you get the same behavior on Windows as on Linux or macOS.

      Addional mark: I saw CONFIG += ordered in your top pro file. Don't use it! There are better ways: https://blog.rburchell.com/2013/10/every-time-you-configordered-kitten-dies.html

      Qt has to stay free or it will die.

      1 Reply Last reply
      3

      • Login

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