PDA

View Full Version : Possible bug in qt creator



themean
17th October 2012, 12:44
In short sources don't appear in qt creator but project can build.
This is my qmake


QT += core gui

TARGET = Disigner
TEMPLATE = app

!include( ../Common.pri)::warning(Fail to include Common.pri)

sourcesPath = #Sources
headersPath = #Sources
tempSources += main.cpp
tempSources += Designer.cpp

tempHeaders += Designer.h

compliteSources += $$ApendPath(sourcesPath,tempSources)
compliteHeaders += $$ApendPath(headersPath,tempHeaders)

finalSources += $$compliteSources
finalHeaders += $$compliteHeaders

message($$finalSources)
message($$finalHeaders)
SOURCES += $$finalSources
HEADERS += $$finalHeaders


This is my Common.pri


defineReplace(ApendPath){
Path = $$eval($$1)
FileNames = $$eval($$2)
FullNames =

if(Path){
for(FileName,FileNames){
FullName = $${Path}/$${FileName}
FullNames += $$FullName
}

} else {

for(FileName,FileNames){
FullName = $${FileName}
FullNames += $$FullName
}

}

return ($$FullNames)
}


If i comment "SOURCES += $$finalSources" and add "SOURCES += main.cpp Designer.cpp" sources appear again in qt creator again.

ChrisW67
18th October 2012, 05:48
Qt Creator extracts the source file names from the SOURCES and HEADERS in pro and pri files by parsing the files. It understands explicitly named files, globs, and some variable expansions. If there are no files listed there, as is the case here, then there are no files in the project. With your attempt at a completely dynamic setup the only way that Qt Creator could possibly know which files qmake would ultimately include in SOURCES/HEADERS with your dynamic setup would be to 'run' the PRO file internally and intercept the end result.


The globbing and expansion functionality may help you here. This, for example, works:


TEMPLATE = app
someothersources = ../other.cpp
SOURCES += *.cpp $${someothersources}
HEADERS += *.h

picking up all the CPP and H files in the directory but it will not notice new files created outside until you force it to reparse the pro file.

If I understand what you are trying to achieve:

##top.pro
TEMPLATE = app

include(headers/headers.pri)
include(sources/sources.pri)

##headers/headers.pri
HEADERS += $${PWD}/*.h

##sources/sources.pri
SOURCES += $${PWD}/*.cpp