Search code examples
makefileqt-creatorqmake

How to avoid qmake Build Step if using QT Creator


I have a Qt project file (.pro) and a Makefile (self-written).
The project file is simply used for editing the source files in the IDE:

/home/project/

             ./src/fooApp.pro
                              TEMPLATE=app
                              CONFIG-=qt
                              TARGET=fooApp

                              SOURCES+=...
                              HEADERS+=...

             ./src/main.c
             ./src/foo.c
             ./src/foo.h

             ./build/Makefile

I would like to build the project via IDE QT Creator 3.5.1
Therefore I would like to invoke make on the Makefile.

During the build process I always get the error that no Makefile can be found hence no build was triggered.

The solution is to always invoke qmake first, then make (even if a Makefile is still present and custom setting make -C ../build in /home/project/)

Could someone please explain, why it is not possible ignore qmake and directly invoke make on the already existing Makefile?

(No Qt library is used for the project)

Regards


Solution

  • This is quite easy, I use makefile only project alot because I like qt-creator as an IDE. In the IDE goto the projects tab on the left.

    Select the "build" tab near the top of that page, looks like: (build | run).

    In the build steps:

    • remove the qmake build step by press hovering the mouse over that step and clicking the X that appears.
    • Edit the build directory so that it is the same directory as your makefile.

      Note: you will have to click the shadow build check box next to it to enable it.

    • remove any other steps you don't want (infact just remove them all for now).
    • Add a new step make step. It will try to use the default make, but you can override that if you want. Also add any arguments like debug or -j4 etc...

    Then you are done :)

    Next time you hit build it will simply invoke that make command.

    Note: You will need to do the same for any other configurations you have (like release, debug, etc...). You can also just add loads more configurations for doing other make options (if you have them) for instance make doxygen or such...

    Just remembered you can also either:

    • I am not sure why, but when I tested it (as OP did) you can't seem to just setup a make step with parameters -C ../, it seems to want to look in the "build directory" first.

    I tend to use the build location since its a nice feature of the IDE.

    Note an issue with newer versions of Qtcreator as a makefile IDE is that you cant share your build settings with other people (i.e. can't configure control them) because they are locked to your PC profile... long story... but its very sad and I no longer use qt creator for that one reason.