I’ll take things that should be really easy but are in fact impossible for $1000, Mr Trebek.
I have a Qt desktop app that uses qmake. I have tests. I have test data that I need to copy to my build directory. Not only that, but I want to copy a whole directory recursively. In Linux and Windows. You must be thinking to yourself, ‘There’s no way that’s possible, leave me out of your crazy plans!’ Well to that I say nay. Nay indeed.
I originally copied my test data using the
INSTALLS variable. My data folder is just a directory sitting in the test source called “TestData.” This solution is fantastic because it works cross-platform.
1 2 3 4
However, this means that if I ever have a clean directory, I have to run
make install to install my test data. What a pain! Why bother! Why even write tests when life is this unjust!
BUT WAIT! After combing the depths of the internets for much of the evening, I was able to find many halfway solutions to my original problem. The concept is to add commands to the
For Linux, I use
For Windows, I use
1 2 3 4 5
I also want that directory to be deleted when I run
make clean. Cleaning up just means adding some commands to the
QMAKE_CLEAN directive. I also want to run the appropriate commands whether I’m on Unix or Windows without having to modify my
.pro file. Wrapping the previous commands in what I call an “OS-space” will cause those commands to only run in the specified operating system.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Data copied, tests working again. Take that, Nokia; no matter how difficult you make your build-processing tool, I’ll figure out how to contort it to my whims.