I have the following *.pro files :
the one which heads the solution
# head - pro file :
TEMPLATE = subdirs
CONFIG = qt thread ordered
# save root directory
PROJECT_ROOT_DIRECTORY = $$_PRO_FILE_PWD_
message("Master pro file path : ["$${PROJECT_ROOT_DIRECTORY}"]") // output : "Master pro file path : [/Path/To/Directory]"
# project subdirs
SUBDIRS += PROJECT1
and
# PROJECT1 - pro file :
TEMPLATE = app
# etc.
# output 'PROJECT_ROOT_DIRECTORY ' contents
message("Master pro file path : "$${PROJECT_ROOT_DIRECTORY}) // output : "Master pro file path : []"
How do I pass variables between the 2 pro files (here the variable is PROJECT_ROOT_DIRECTORY
) ?
Edit :
This is the same question as this this one, but I don't see how the "another option is to" answer can help me.
You could put the variable definitions in a .pri
file, which you then include in all .pro
files you want. Note that you need to tell the .pro
files in your subdirectories the path where to find the .pri
file.
head.pro:
# head - pro file :
TEMPLATE = subdirs
CONFIG = qt thread ordered
# configuration
include(config.pri)
message("Master pro file path : ["$${PROJECT_ROOT_DIRECTORY}"]") # output : "Master pro file path : [/Path/To/Directory]"
# project subdirs
SUBDIRS += PROJECT1
config.pri:
# save root directory
PROJECT_ROOT_DIRECTORY = $$PWD // not $$_PRO_FILE_PWD_!
project1/project1.pro:
# PROJECT1 - pro file :
TEMPLATE = app
# configuration
include(../config.pri) # note that you need to put "../" before the .pri path
message("Master pro file path : ["$${PROJECT_ROOT_DIRECTORY}"]") # should now output : "Master pro file path : [/Path/To/Directory]"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With