0

I'm trying to print a message with QMake but I have problems with extensions:

lib_name = $$1
message("test1: $$MYPATH/$$lib_name/src/$$lib_name.pri");
message("test2: $$MYPATH/$$lib_name/src/$$lib_name");

For some reason, test1 doesn't print the correct path. It just prints the path until src/. But, test2 is ok. It prints everything until the value in $$1.

Any workaround?

Azeem
  • 11,148
  • 4
  • 27
  • 40
veltres
  • 51
  • 5

1 Answers1

0

QMake supports variables (objects) with members that can be used using the dot . operator e.g. target.path for INSTALLS. So, in your case, $$lib_name.pri means that you're accessing the member pri of lib_name which doesn't exist so there's no output.

You need to enclose variables in curly braces for QMake to distinguish them from the surrounding text i.e. $${lib_name}.pri.

Example:

message("test1: $$MYPATH/$$lib_name/src/$${lib_name}.pri");
#                                       ~~~~~~~~~~~~

For more examples of objects, see Adding Custom Target and Adding Compilers sections of QMake's Advanced Usage page.

Here's another relevant SO thread: QMake - How to add and use a variable into the .pro file

Azeem
  • 11,148
  • 4
  • 27
  • 40