17

Does Qt Creator set a qmake variable containing the build directory that can be referenced from the Qt project file?

The Qt Creator Default build directory:

../build-%{CurrentProject:Name}-%{CurrentKit:FileSystemName}-%{CurrentBuild:Name}

My goal is to copy the dll's import lib from the build output using QMAKE_POST_LINK to make it easier for my client project to link with. QMAKE_POST_LINK works if I hard code the path of the import lib.

For example:

QMAKE_POST_LINK = copy C:\projects\ICP\sw\icpts\sandbox\configurable-system-test-io\build-lib-configurable-system-test-io-Desktop_Qt_5_1_0_MSVC2012_32bit_eb09a8-Debug\debug\*.lib  ..\my-lib

Solution: Solution provided by fbucek to use $$OUT_DIR solved my problem. Thank You!

  • Under Windows, you must use $$shell_path($$OUT_PWD) in the QMAKE_POST_LINK to convert Unix '/' path characters to Windows '\' path characters.
  • To add multiple commands to QMAKE_POST_LINK, enclose in $$quote() with appended $$escape_expand(\n).

Example of Multiple QMAKE_POST_LINK commands:

QMAKE_POST_LINK += $$quote(copy /Y $$shell_path($$OUT_PWD)\debug\*.dll  ..\lib$$escape_expand(\\n))
QMAKE_POST_LINK += $$quote(copy /Y $$shell_path($$OUT_PWD)\debug\*.lib  ..\lib$$escape_expand(\\n))
QMAKE_POST_LINK += $$quote(copy /Y $$shell_path($$OUT_PWD)\debug\*.pdb  ..\lib$$escape_expand(\\n))

Thanks again for $$OUT_PWD !

-Ed

  • Qt Creator 2.7.2
  • Qt 5.1
  • Microsoft VS 2012
  • Windows 7
1
  • Though your question is not clear to me but I knew Creator provides under Projects->BuildSettings check shadow build option it allows to change build dir Commented Sep 18, 2013 at 4:11

1 Answer 1

14

Yes it does

Put this in pro file, run qmake and check if it shows what you want

message($$OUT_PWD)

Qmake Variable Reference OUT_PWD

Then you can use it like this: ( I hope - not tested )

QMAKE_POST_LINK = copy $$OUT_PWD\debug\*.lib  ..\my-lib
Sign up to request clarification or add additional context in comments.

4 Comments

Thank you for $$OUT_PWD ! I need to read the qmake variable reference line-by-line add a message statement for every one to understand what they do.
QMAKE_POST_LINK doe not seem to like variables. I tried: QMAKE_POST_LINK = copy /Y "$$OUT_PWD\\debug\*.lib" "..\\lib"
The problem is $$OUT_PWD uses forward slashes in the path '/' which makes the Windows copy command used by QMAKE_POST_LINK result in the error "The syntax of the command is incorrect.". Hmmm...
Use of $$shell_path($$OUT_PWD) solves the forward slash '/' path problem. Thanks again!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.