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. [SOLVED] How to create a global top-level source directory?
Qt 6.11 is out! See what's new in the release blog

[SOLVED] How to create a global top-level source directory?

Scheduled Pinned Locked Moved General and Desktop
12 Posts 3 Posters 5.6k 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.
  • D Offline
    D Offline
    DRoscoe
    wrote on last edited by
    #1

    I want to be able to define a fixed top-level source directory for all of my projects in a SUBDIRS project. I found this wiki entry:

    http://qt-project.org/wiki/QMake-top-level-srcdir-and-builddir

    I am using Qt 5.4 so I followed the Qt 5 instruction which simply says to create a .qmake.conf file with the following lines:

    top_srcdir=$$PWD
    top_builddir=$$shadowed($$PWD)

    However, this does not work. When I query the variable in my main .PRO file, I get an empty variable:

    Project MESSAGE: TOP_SRC:

    Is there any way to do this that actually works?

    Thanks!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Maybe a silly question but are you by any chance using:

      @message($$TOP_DIR)@

      rather than

      @message($$top_dir)@

      ?

      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
      • D Offline
        D Offline
        DRoscoe
        wrote on last edited by
        #3

        Not a silly question, but no, I am only echoing it in all caps.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You must respect the casing of your variables, that's why you don't get anything printed

          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
          • D Offline
            D Offline
            DRoscoe
            wrote on last edited by
            #5

            Its only the text literal portion that WAS printed that is caps. The actual variable is the correct case:

            message(TOP_SRC: $$top_srcdir)

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Sorry, misunderstood the echo part.

              What OS are you running and what does the folder layout of your project look like ?

              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
              • D Offline
                D Offline
                DRoscoe
                wrote on last edited by
                #7

                I am running OSX 10.10.2 and the project layout is as follows:

                @
                CONFIG += c++11 ordered
                TEMPLATE = subdirs

                #DAR@20150203 The subdirs MUST be in the following order for a successful build.

                Qt has some strange dependency handling

                SUBDIRS +=
                aop_logger
                aop_xml
                aop_serial
                aop_util
                aop_measure
                MathUtilities
                DataCollection
                DebugLogger
                AvionicsBus
                AircraftDataModel
                WindModel
                TableLookups
                aop_data
                tap_data
                configuration
                AtosUtils
                dna
                tap_messaging
                tap_new_display_app
                @

                Each subdir is a static lib subproject, except for the main app itself which resides in tap_new_display_app. What I wanted to do was to define a global variable that is set to the top-level path of the main .PRO file. This way I have a common reference point for all relative paths to include files, depend paths, etc, regardless of any nesting of the subprojects

                I added a message output from the .qmake.conf file itself and I never saw ANY output, suggesting that the .qmake.conf file is not being loaded.

                I just tried another approach that appears to work. Here is my solution: I created a top_srcdir.pri file at the same level as my main tap_new_display_app.pro file containing the following:

                @top_srcdir=$$PWD@

                Then I included it in the main .pro file and immediately echoed it:

                @include(top_srcdir.pri)
                message(TOP_SRCDIR: $$top_srcdir)@

                This works:

                @Project MESSAGE: TOP_SRCDIR: /Users/droscoe/Documents/workspace/dar_tap_display_20150209_view/aop/external/tap_new_display@

                If I include the top_srcdir.pri file in another project, it appears to work as well:

                @
                Project MESSAGE: MAIN - TOP_SRCDIR: /Users/droscoe/Documents/workspace/dar_tap_display_20150209_view/aop/external/tap_new_display
                Project MESSAGE: AOP_DATA - TOP_SRCDIR: /Users/droscoe/Documents/workspace/dar_tap_display_20150209_view/aop/external/tap_new_display
                @

                I guess the $$PWD is being expanded to the path in which it resides, not from the directory its being included from, so as long as its at the top-level of my source tree, I have a workable solution. The method in the WIKI does not work and should be removed

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  I just retested it and it's working with the .qmake.conf file in the root directory. Again a silly question but did put the point before qmake.conf ?

                  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
                  • D Offline
                    D Offline
                    DRoscoe
                    wrote on last edited by
                    #9

                    Yes, I did. I've recreated the experiment 3 times with the same result. I get no indication .qmake.conf is being read. I've confirmed this on Mac an Windows. Is there something I should be doing other than creating the .qmake.conf file?

                    1 Reply Last reply
                    0
                    • V Offline
                      V Offline
                      Vyacheslav
                      wrote on last edited by
                      #10

                      I can confirm on Qt-5.4 Linux 64bit that the solution in original article doesn't work.

                      D 1 Reply Last reply
                      0
                      • V Vyacheslav

                        I can confirm on Qt-5.4 Linux 64bit that the solution in original article doesn't work.

                        D Offline
                        D Offline
                        DRoscoe
                        wrote on last edited by DRoscoe
                        #11

                        @Vyacheslav I was able to get around this problem by defining a file at the root level of my project. I named it "top_srcdir.pri" and it contains the following lines:

                        #-------------------------------------------
                        # Filename   : top_srcdir.pri
                        # Description: Describes the top-level source path and common library include paths
                        #-------------------------------------------
                        
                        aop_srcdir=$$PWD/../../../aop
                        cto4_srcdir=$$PWD/../../../CTO4Shared
                        

                        Then I simply include that file everywhere I need to reference a fixed location for my top-level source tree. Works like a charm

                        -Dave

                        1 Reply Last reply
                        0
                        • V Offline
                          V Offline
                          Vyacheslav
                          wrote on last edited by
                          #12

                          Tnx @DRoscoe . I saw your solution above. Just thought it's worth mentioning that the problem is still there ;)

                          1 Reply Last reply
                          1

                          • Login

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