0

In my project I have made configure.ac and Makefile.am files correctly so my components compile and dynamically link to the appropriate libraries. One of these components links to a library that uses QT, so the appropriate Makefile must be generated out of the .pro file prior compilation on the target system.

For this I think that I need to find a way to tell my make scripts, through Makefile.am perhaps, that this library must be compiled on its own by first running qmake and the generated Makefile in that directory.

Is this even possible? If so, how do I do it?

2 Answers2

0

Researching on my own I have found an apparently abandoned project called “AutoTroll” which is supposed to automatically alter files of autotools in order to add compatibility with Qt4. I have tried to make it work with no luck. It lacks a proper documentation also.

Without this tool, compiling Qt4 modules with autotools requires a lot of hacking and interventions, making it really hard and even more for a cross-platform application.

I have switched to CMake. CMake’s setup is far easier than autotools’ and it supports Qt4 modules out of the box.

0

We do this, its not that difficult. In configure.ac:

QT_QMAKE
[
echo $QMAKE -o Makefile.myapp $(realpath $(dirname $0))/myapp.pro
$QMAKE -o Makefile.myapp $(realpath $(dirname $0))/myapp.pro
]

Then (Assuming your macros are located in the standard m4 directory), make a file called qt_qmake.m4 there.

AC_DEFUN([OTT_QT_QMAKE],[
   if test -z "$QMAKE"; then
      QMAKE=$(which qmake)
      $QMAKE -v > /dev/null 2>&1
      if test $? -ne 0; then
         AC_MSG_ERROR([qmake executable not found!])
      fi
   fi
   AC_SUBST(QMAKE)
])

Then in Makefile.am:

ACLOCAL_AMFLAGS=-Im4

all-am:
        make -f Makefile.myapp all

install-am:
        make -f Makefile.myapp install

qmake_all:
        make -f Makefile.myapp qmake_all

clean-am:
        make -f Makefile.myapp clean

That should align with the targets that QTCreator uses, and allows you to "bootstrap" qmake using autotools to make a config.h for instance, or global qmake include file to make shadow builds easier. Theres a lot I'm leaving out if you want to have version checking,etc... but it should get you started. If you built qt yourself, or have it not in your path, ie redhat (/usr/lib{64}/qt5/bin/qmake), you can just use the QMAKE variable to point to it. QT is smart enough with that to take it from there usually. I know its not the most elegant solution, but its worked for us cross-linux for almost a decade.

CRB
  • 111
  • 1
  • 6