I was always wondering why doing something like this never worked

SOURCES += *.cpp
SOURCES -= excluded.cpp

excluded.cpp always stayed in SOURCES. The thing is that when you add a new value to the list, it's just a string. Thus using wildcard in files names is nothing more but an asteriks character. And therefore using -= operator will only remove exact strings. But today I found another undocumented function I've been looking for years!

$$files(glob) — Returns a list of files which match the specified glob pattern.

So now I can do

SOURCES += $$files(*.cpp)
SOURCES -= excluded.cpp

and it actually works.