Possible bug in qt creator
In short sources don't appear in qt creator but project can build.
This is my qmake
Code:
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
Code:
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.
Re: Possible bug in qt creator
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:
Code:
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:
Code:
##top.pro
TEMPLATE = app
include(headers/headers.pri)
include(sources/sources.pri)
##headers/headers.pri
HEADERS += $${PWD}/*.h
##sources/sources.pri
SOURCES += $${PWD}/*.cpp