Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. qmake creates build artifacts in source directory even when building in out-of-source build directory

qmake creates build artifacts in source directory even when building in out-of-source build directory

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
8 Posts 3 Posters 1.1k Views
  • 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.
  • M Offline
    M Offline
    Mrts
    wrote on 26 Sept 2019, 18:39 last edited by
    #1

    Hi!

    Can someone explain why qmake creates build artifacts in source directory even when building in out-of-source build directory?

    Given the following directory tree:

    .
    ├── build
    ├── src
    │   ├── app
    │   ├── controller
    │   └── ui
    ├── tests
    │   ├── mock-ui
    │   └── tests
    └── tests-build
        ├── mock-ui
        └── tests
    

    where build is the directory for building source files in src and tests-build is the directory for building sources in tests, and the following tests.pro project file in tests:

    TEMPLATE = subdirs
    CONFIG += ordered
    
    SUBDIRS = \
        mock-ui \
        ../src/controller \
        tests
    
    tests.depends = controller mock-ui
    

    when I run

    cd tests-build
    qmake ../tests
    make check
    

    then controller project build artifacts appear in src/controller instead of tests-build where they should appear.

    Is this because the controller project is outside of the test subdirs project root? How can I fix this?

    Thanks in advance for any tips!

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 26 Sept 2019, 18:46 last edited by
      #2

      Hi and welcome to devnet,

      Why is contoller outside of the subdir project ?

      Note that qmake is not cmake, you usually do out of source builds, not "in a folder inside the sources". IIRC, there was an issue with how the paths were generated when inside a subfolder but I'm not 100% sure.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 1 Reply Last reply 26 Sept 2019, 18:56
      1
      • S SGaist
        26 Sept 2019, 18:46

        Hi and welcome to devnet,

        Why is contoller outside of the subdir project ?

        Note that qmake is not cmake, you usually do out of source builds, not "in a folder inside the sources". IIRC, there was an issue with how the paths were generated when inside a subfolder but I'm not 100% sure.

        M Offline
        M Offline
        Mrts
        wrote on 26 Sept 2019, 18:56 last edited by Mrts
        #3

        @SGaist thanks for the welcome!

        Note that both build directories are outside the sources, so they are already out of source builds:

        .
        ├── build <-- build directory for sources in src
        ├── src
        ├── tests
        └── tests-build <-- build directory for sources in tests
        

        The tests subdirs project is a QTest project for testing controller . controller is a separate static library module that should be unaware of tests, hence it lies outside of tests in src.

        Note that mock-ui and tests build artifacts end up in tests-build as expected, only controller misbehaves.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 26 Sept 2019, 19:06 last edited by
          #4

          Can you show the complete structure of your project ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          M 1 Reply Last reply 26 Sept 2019, 19:15
          0
          • S SGaist
            26 Sept 2019, 19:06

            Can you show the complete structure of your project ?

            M Offline
            M Offline
            Mrts
            wrote on 26 Sept 2019, 19:15 last edited by Mrts
            #5

            @SGaist sure, here it goes:

            .
            ├── build
            ├── src
            │   ├── app
            │   │   ├── app.pro
            │   │   ├── main.cpp
            │   │   └── parseargs.hpp
            │   ├── common.pri
            │   ├── controller
            │   │   ├── controller.cpp
            │   │   ├── controller.hpp
            │   │   ├── controller.pro
            │   │   └── monitorthread.hpp
            │   ├── ui
            │   │   ├── ui.cpp
            │   │   ├── ui.hpp
            │   │   └── ui.pro
            │   └── foo.pro
            ├── tests
            │   ├── mock-ui
            │   │   ├── mock-ui.cpp
            │   │   ├── mock-ui.hpp
            │   │   └── mock-ui.pro
            │   ├── tests
            │   │   ├── main.cpp
            │   │   └── tests.pro
            │   └── foo-tests.pro
            └── tests-build
            

            Thanks for looking into this!

            A 1 Reply Last reply 28 Sept 2019, 10:46
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 28 Sept 2019, 06:26 last edited by
              #6

              Are they all separated projects ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • M Mrts
                26 Sept 2019, 19:15

                @SGaist sure, here it goes:

                .
                ├── build
                ├── src
                │   ├── app
                │   │   ├── app.pro
                │   │   ├── main.cpp
                │   │   └── parseargs.hpp
                │   ├── common.pri
                │   ├── controller
                │   │   ├── controller.cpp
                │   │   ├── controller.hpp
                │   │   ├── controller.pro
                │   │   └── monitorthread.hpp
                │   ├── ui
                │   │   ├── ui.cpp
                │   │   ├── ui.hpp
                │   │   └── ui.pro
                │   └── foo.pro
                ├── tests
                │   ├── mock-ui
                │   │   ├── mock-ui.cpp
                │   │   ├── mock-ui.hpp
                │   │   └── mock-ui.pro
                │   ├── tests
                │   │   ├── main.cpp
                │   │   └── tests.pro
                │   └── foo-tests.pro
                └── tests-build
                

                Thanks for looking into this!

                A Offline
                A Offline
                aha_1980
                Lifetime Qt Champion
                wrote on 28 Sept 2019, 10:46 last edited by aha_1980
                #7

                Hi @Mrts,

                usually the SUBDIRS pro file is top-level, i.e. all referenced pro files are below it.

                That gives you one build directory with the same hierarchy as your source folders.

                And please: Don't use CONFIG+=ORDERED!

                Regards

                https://blog.rburchell.com/2013/10/every-time-you-configordered-kitten-dies.html

                Qt has to stay free or it will die.

                M 1 Reply Last reply 3 Oct 2019, 07:19
                1
                • A aha_1980
                  28 Sept 2019, 10:46

                  Hi @Mrts,

                  usually the SUBDIRS pro file is top-level, i.e. all referenced pro files are below it.

                  That gives you one build directory with the same hierarchy as your source folders.

                  And please: Don't use CONFIG+=ORDERED!

                  Regards

                  https://blog.rburchell.com/2013/10/every-time-you-configordered-kitten-dies.html

                  M Offline
                  M Offline
                  Mrts
                  wrote on 3 Oct 2019, 07:19 last edited by
                  #8

                  @aha_1980, thanks, I removed CONFIG += ORDERED.

                  I prefer to keep tests separate from source, so I guess I have to live with this limitation.

                  1 Reply Last reply
                  0

                  1/8

                  26 Sept 2019, 18:39

                  • Login

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