Another approach to building software is generating make files. This is what qmake does. qmake is part of Qt, the portable widget library of TrollTech.
qmake takes Project files (extension .pro) and turns these into makefiles. The advantage here is that the syntax of .pro files is much simpler.
Suppose we have a minimalist test class, something like the following:
#include <iostream> #include <string> using std::cout; using std::endl; using std::string;
class Hi { private: string message; public: Hi(){ message = "Hi There!"; } void sayHi(){ cout << message << endl; } }; int main(){ Hi hi; hi.sayHi(); return 0; }
Save it in a file called Hi.cpp or similar.
Next, we let qmake generate the .pro file. This is not something we'll do regularly, but it's easy to start off with.
$ qmake -project
A new .pro file appears, looking something like this:
TEMPLATE = app TARGET = DEPENDPATH += . INCLUDEPATH += .
# Input SOURCES += Hi.cpp
I've removed the header that says 'autogenerated at date xxx' because that's just confusing for colleagues who might think they shouldn't touch this file. They should.
This new project file is where we'll work from. We can now generate a makefile:
$ qmake
And build the software with:
$ make
You immediately get other targets as well:
$ make clean $ make distclean