What .prf files are automatically loaded by qmake?

You may wonder why the qmake CONFIG variable has values that you never set. Sometimes, you even need to remove some values from CONFIG in your .pro file using:

CONFIG -= qt

What is the default value of CONFIG? In my system, the initial value of CONFIG is

file_copies qmake_use qt warn_on release link_prl dummy_platform dummy_compiler copy_dir_files

Where do those values come? Well, qmake will load extra .prf files besides processing your project file. Specifically, qmake will call loadSpec() to load qmake super cache(_QMAKE_SUPER_CACHE_, find this file .qmake.super in current working directory, its parent directory, its grand-parent directory till root directory), c:\Qt5.12.1\5.12.1\Src\qtbase\mkspecs\features\spec_pre.prf, c:\Qt5.12.1\5.12.1\Src\qtbase\mkspecs\dummy\qmake.conf, c:\Qt5.12.1\5.12.1\Src\qtbase\mkspecs\features\spec_post.prf, .qmake.conf(find this file in .pro directory, its parent directory, its grand-parent directory, till root directory), qmake cache(_QMAKE_CACHE_) file .qmake.cache(find it in working directory, its parent directory, its grand-parent directory till root directory), .qmake.stash (find it in working directory, its parent directory, its grand-parent directory till root directory), and load c:\Qt5.12.1\5.12.1\Src\qtbase\mkspecs\features\default_pre.prf, before loading your .pro file, and load c:\Qt5.12.1\5.12.1\Src\qtbase\mkspecs\features\default_post.prf after loading your .pro file. The handling logic is in the QMakeEvaluator::visitProFile function of c:\Qt5.12.1\5.12.1\Src\qtbase\qmake\library\qmakeevaluator.cpp. The values of CONFIG is prefilled by those project feature files.

You may already know qmake will load features specified by CONFIG. For example, if CONFIG=…qt…, qmake will load qt.prf. But the load of such feature files is not done as soon as you add the config to CONFIG, but delayed towards the end of QMakeEvaluator::visitProFile after the load of default_post.prf, by the evaluateConfigFeatures function. Of course, qmake will only load the configure features if the xxx.prf file exists, and ignore those that do not exist.

If you like my content, please consider buying me a coffee. Buy me a coffeeBuy me a coffee Thank you for your support!
Posted in

Leave a Reply