Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to quell qmake's "WARNING: Failure to find:"?

Tags:

qmake

I'm using PRE_TARGETDEPS to generate source files, and I'm adding the generated source files to SOURCES for compilation.

The output of my generator obviously doesn't exist at the time qmake is run, so qmake outputs WARNING: Failure to find: for each of the to-be-created source files.

How can I quell this warning, since I know my PRE_TARGETDEPS is going to produce those files?

Or, is there a better way to generate intermediate files using qmake?

Example

Here's a complete test.pro file that exhibits the problem:

TEMPLATE = lib

preprocess.commands += cat test.cc.in | sed 's/a/0/g' > test.0.cc ;
preprocess.commands += cat test.cc.in | sed 's/a/1/g' > test.1.cc ;
preprocess.depends = test.cc.in
QMAKE_EXTRA_TARGETS += preprocess
PRE_TARGETDEPS += preprocess

SOURCES = test.0.cc test.1.cc

Place this in an empty folder, and also create an empty test.cc.in file. Run qmake, and you'll see these warnings:

WARNING: Failure to find: test.0.cc
WARNING: Failure to find: test.1.cc
like image 202
smokris Avatar asked Dec 31 '12 20:12

smokris


1 Answers

How can I quell this warning

From my reading of the qmake code, it looks like you can:

  • either have qmake ignore any filenames that don't exist - in which case they won't get built by your later steps
  • or have it write these warnings

I don't think either of these would be satisfactory for you.


Here's my reasoning.... I had a hunt for the text Failure to find in a Qt distribution I had to hand: qt4.8.1.

It appeared 3 times in in qmake/generators/makefile.cpp. The two blocks of code look like this:

QStringList
MakefileGenerator::findFilesInVPATH(QStringList l, uchar flags, const QString &vpath_var)
{
....
                    debug_msg(1, "%s:%d Failure to find %s in vpath (%s)",
                              __FILE__, __LINE__,
                              val.toLatin1().constData(), vpath.join("::").toLatin1().constData());
                    if(flags & VPATH_RemoveMissingFiles)
                        remove_file = true;
                    else if(flags & VPATH_WarnMissingFiles)
                        warn_msg(WarnLogic, "Failure to find: %s", val.toLatin1().constData());
....
                else if(flags & VPATH_WarnMissingFiles)
                    warn_msg(WarnLogic, "Failure to find: %s", val.toLatin1().constData());

and this is called with:

        l = findFilesInVPATH(l, (comp.flags & Compiler::CompilerRemoveNoExist) ?
                             VPATH_RemoveMissingFiles : VPATH_WarnMissingFiles, "VPATH_" + comp.variable_in);

So the flags parameter passed in to the first block will be either RemoveMissingFiles or WarnMissingFiles, depending on comp.flags & Compiler::CompilerRemoveNoExist.


Or, is there a better way to generate intermediate files using qmake?

I'm not sure that it's better - i.e. it's certainly complex - but this is what is done where I work...

In the .pro file, a system call is done, that:

  1. generates the required files,
  2. and then writes out their names to stdout.

Here's an example from the .pro, to show how it would be called:

SOURCES    += $$system( python my_script_name.py )

You can of course pass arguments in to the python script, if you like

Things to note/limitations:

  • This means that the python script gets run whenever you run qmake, but not during individual make invocations
  • Each invocation of python really slows down our qmake steps - taking roughly twice as long as running qmake without launching python - but you could always use a different scripting language

This would fix your problem, in that by the time qmake processes the SOURCES value, the files have been created by the script.

like image 173
Clare Macrae Avatar answered Oct 16 '22 07:10

Clare Macrae