[SOLVED] Qmake puts precompiled header build files in wrong directory
-
I'm using Qt 5.1.0 on Windows 7 with Qt Creator 2.8.0 and MSVC 2012.
Say I have the following folder structure:
@
bin/
debug/
release/
myproject/
myproject.pro
build/
debug/
release/
src/
main.cpp
pch.hpp@My goal is to have the compiled executable placed in bin/[debug|release]/ and build files (.obj, moc, etc.) into myproject/build/[debug|release]/.
I use the following in myproject.pro file:
@PROJECT_DIR = $$PRO_FILE_PWD
BUILD_DIR = $${PROJECT_DIR}/buildmyBuildMode() just returns debug|release, depending on the current build.
DESTDIR = $${PROJECT_DIR}/../bin/$$myBuildMode()
OBJECTS_DIR = $${BUILD_DIR}/$$myBuildMode()
MOC_DIR = $${BUILD_DIR}/$$myBuildMode()
RCC_DIR = $${BUILD_DIR}/$$myBuildMode()
UI_DIR = $${BUILD_DIR}/$$myBuildMode()@This works fine except when using a precompiled header. When I add a PCH to the project the PCH build files are placed into a new separate debug|release directory as a sibling of the buid/ and src/ directories. Here's what I end up with after a debug build:
@
bin/
debug/
myproject.exe
...debug database etc...
release/
myproject/
myproject.pro
build/
debug/
main.obj
release/
debug/
myproject_d_pch.obj
myproject_d_pch.pch
release/
src/
main.cpp
pch.hpp@The myproject/[debug|release]/ directories should not exist, the PCH build files should be in the same directory as main.obj.
Is this a qmake bug or is there an extra qmake variable I should be using that can fix this?
-
I found what seems to be an undocumented qmake variable called PRECOMPILED_DIR in the qmake source which sets the location of where the PCH build files will be placed. Assigning this in my .pro file fixed the problem.
So in addition to the above post:
@PRECOMPILED_DIR = $${BUILD_DIR}/$$myBuildMode()@