Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. [SOLVED] Qmake puts precompiled header build files in wrong directory

[SOLVED] Qmake puts precompiled header build files in wrong directory

Scheduled Pinned Locked Moved Qt Creator and other tools
2 Posts 1 Posters 3.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ecko
    wrote on last edited by
    #1

    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}/build

    myBuildMode() 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?

    1 Reply Last reply
    0
    • E Offline
      E Offline
      ecko
      wrote on last edited by
      #2

      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()@

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved