質問

(Apologies, I can't think of a better way of explaining except through including the following detail)

Pre-build structure:

F:\
└ Project\
  └ Project.pro
  └ ProjectSettings.pri
  └ Source\
    └ Source.pro
    └ My_Library\
      └ My_Library.pro
      └ library.cpp
      └ ...

Contents of "Project.pro":

TEMPLATE = subdirs
SUBDIRS = Source

Contents of "Source.pro":

TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS +=  My_Library

Contents of "My_Library.pro":

include(../../ProjectSettings.pri)

TEMPLATE = lib
SOURCES += library.cpp

Contents of "ProjectSettings.pri"

TARGET = $$basename(_PRO_FILE_PWD_)

Debug:buildDir = "Debug"
Release:buildDir = "Release"

DESTDIR =     $$PWD/$$buildDir/bin
OBJECTS_DIR = $$PWD/$$buildDir/$$basename(_PRO_FILE_PWD_)/obj
MOC_DIR =     $$PWD/$$buildDir/$$basename(_PRO_FILE_PWD_)/moc
RCC_DIR =     $$PWD/$$buildDir/$$basename(_PRO_FILE_PWD_)/rcc
UI_DIR =      $$PWD/$$buildDir/$$basename(_PRO_FILE_PWD_)/gui

Post-build structure:

F:\
└ Project\
  └ Project.pro
  └ ProjectSettings.pri
  └ Source\
    └ Source.pro
    └ My_Library\
      └ My_Library.pro
      └ library.cpp
  └ Debug\
    └ bin\
      └ libMy_Library.a
    └ My_Library\
      └ moc\
      └ obj\
        └ library.o
  └ My_Library\   <------ WTF
    └ moc\
  └ Release\
    └ bin\
      └ libMy_Library.a
    └ My_Library\
      └ moc\
      └ obj\
        └ library.o

Problem

The idea is

  • run qmake -recursive in the Project folder
  • which builds all the specified sub-projects
  • spits out a bunch of well organised intermediate files
  • and places all the binaries for the sub-projects into one folder
  • all of which are segregated based on Debug or Release scope

It seems to work brilliantly, except for an extra folder per 'sub-project' in the Project folder each of which contains a moc folder which I've highlighted "WTF"* above.

Questions

  1. Which (combination of) instruction(s) in the .pro files generates the "WTF" folders?
  2. What would the "WTF" folder be used for? (bearing in mind the Debug and Release scopes specify their own moc)
  3. Is there a way to prevent the "WTF" folders being created?

I don't have any source files that would cause the MOC to output moc files yet so all moc folders are empty at the moment.

* "WTF" = "What The Folder"

役に立ちましたか?

解決

1. The folders are created before the Debug and Release scopes are run. qmake produces one primary make file (Makefile) and if there is source to build: two child make files (Makefile.Debug and Makefile.Release). The scopes are set for the children, but not for the parent therefore qmake decides it must create the folders which don't exist.

2. It's not used for anything so far as I can tell.

3. By adding a buildDir definition that already exists (in this case Source) qmake doesn't bother to make any extra interim folders. Furthermore, the scope test should be modified (see here and here for an explanation of why). This boils down to the following ProjectSettings.pri:

PROJECT_NAME = $$basename(PWD)
TARGET = $$basename(_PRO_FILE_PWD_)

buildDir = Source
CONFIG( debug, debug|release ) {
    buildDir = "Debug"
} else {
    buildDir = "Release"
}

DESTDIR =     $$PWD/$$buildDir/bin
OBJECTS_DIR = $$PWD/$$buildDir/$$basename(_PRO_FILE_PWD_)/obj
MOC_DIR =     $$PWD/$$buildDir/$$basename(_PRO_FILE_PWD_)/moc
RCC_DIR =     $$PWD/$$buildDir/$$basename(_PRO_FILE_PWD_)/rcc
UI_DIR =      $$PWD/$$buildDir/$$basename(_PRO_FILE_PWD_)/gui

Not really sure why this works, but it seems to solve the problem.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top