[SOLVED] How to create a global top-level source directory?
-
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!
-
Hi,
Maybe a silly question but are you by any chance using:
@message($$TOP_DIR)@
rather than
@message($$top_dir)@
?
-
Not a silly question, but no, I am only echoing it in all caps.
-
You must respect the casing of your variables, that's why you don't get anything printed
-
Its only the text literal portion that WAS printed that is caps. The actual variable is the correct case:
message(TOP_SRC: $$top_srcdir)
-
Sorry, misunderstood the echo part.
What OS are you running and what does the folder layout of your project look like ?
-
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
-
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 ?
-
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?
-
I can confirm on Qt-5.4 Linux 64bit that the solution in original article doesn't work.
-
@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
-
Tnx @DRoscoe . I saw your solution above. Just thought it's worth mentioning that the problem is still there ;)