2

I'm trying to use a flag, set from command line, such that when it is typed in, a pri file sets the variable to be used in another pri file. The pri that sets the variable is working fine, however when I try to access the variable from another pri where it actually needs to be used, I'm not getting any results.

So for instance in cmd

 qmake (parameters) --variable_name

In parent.pri

 contains(options, --variable_name) {
      variable_name = true
      message("variable_name = " $$variable_name)
 }

output = variable_name = true

In child.pri

 message("variable_name = " $$variable_name)
 if(variable_name = true) {
    // do stuff
 }
 else {
     return(true)
 }

output = variable_name =

I believe this is the right syntax, however in the child.pri when I try to echo the value set for variable_name nothing is displayed.

I could use contains(options, variable_name) { }

but I would like to only have to use this once in the parent.pri

madhead
  • 31,729
  • 16
  • 153
  • 201
fisherml
  • 65
  • 1
  • 5
  • 16

1 Answers1

0

Only .pro files are executed by qmake. .pri files are a bit like headers in C and C++ in the sense that they are replaced by their contents in the pro files. So for one pri file to "know" the directives of another pri files, you need to include parent.pri either in child.pri or before child.pri everywhere it is included.

Community
  • 1
  • 1
UmNyobe
  • 22,539
  • 9
  • 61
  • 90
  • I've tried include(parent.pri) in the child.pri, however when running qmake, it says reading C:\blah\blah\something.pro, and then brings back the prompt – fisherml Aug 15 '13 at 18:56
  • is C:\blah\blah\something.pro including child.pri?? Did you made sure paths are correct, if you include a pri file which is not found it will be silently ignored – UmNyobe Aug 16 '13 at 08:52