Using QMAKE_EXTRA_COMPILERS
-
I've been trying to get qmake to build python wrapper files for c++ using SWIG. The .pri file has this:
swig for ui.i
#GENERATED_SOURCES += \
ui_wrap.cxx
#SWIG_FILES += \
ui.i
#swig.input = SWIG_FILES
#swig.variable_out = GENERATED_SOURCES
#swig.commands = /usr/local/bin/swig -w454 -c++ -python ${QMAKE_FILE_NAME};
#swig.output = ${QMAKE_FILE_BASE}_wrap.cxx
#QMAKE_EXTRA_COMPILERS += swigThis works fine if qmake / make is run from the command line (this is on OSX, similar for Linux). But if I try and build the app using Qt Creator in shadow build mode, it doesn't work. And the reason it doesn't work is that under Qt Creator, make is expecting to find the ui_wrap.cxx file in the build/glade shadow directory, whereas it only exists in the source tree.
More precisely, the makefile qmake generates has all c++ files as ../../projdir/*.cpp i.e. relative paths from the shadow build dir to the source tree, but ui_wrap.cxx has no relative path.
Am I missing something obvious? Resource files generated by rcc are placed in the shadow build tree, so they get compiled correct But QMAKE_EXTRA_COMPILERS is not doing the same...
-
I've been trying to get qmake to build python wrapper files for c++ using SWIG. The .pri file has this:
swig for ui.i
#GENERATED_SOURCES += \
ui_wrap.cxx
#SWIG_FILES += \
ui.i
#swig.input = SWIG_FILES
#swig.variable_out = GENERATED_SOURCES
#swig.commands = /usr/local/bin/swig -w454 -c++ -python ${QMAKE_FILE_NAME};
#swig.output = ${QMAKE_FILE_BASE}_wrap.cxx
#QMAKE_EXTRA_COMPILERS += swigThis works fine if qmake / make is run from the command line (this is on OSX, similar for Linux). But if I try and build the app using Qt Creator in shadow build mode, it doesn't work. And the reason it doesn't work is that under Qt Creator, make is expecting to find the ui_wrap.cxx file in the build/glade shadow directory, whereas it only exists in the source tree.
More precisely, the makefile qmake generates has all c++ files as ../../projdir/*.cpp i.e. relative paths from the shadow build dir to the source tree, but ui_wrap.cxx has no relative path.
Am I missing something obvious? Resource files generated by rcc are placed in the shadow build tree, so they get compiled correct But QMAKE_EXTRA_COMPILERS is not doing the same...
You need to tell swig to generate the file in the build directory, where qmake (and therefore also make) expects it. E.g.
swig.commands = /usr/local/bin/swig -w454 -c++ -python ${QMAKE_FILE_NAME} -o {QMAKE_FILE_OUT}
-
Thats' a good idea, I'll give it a try.
A slightly more complicated workaround was to specify:
swig.output = ../../project/${QMAKE_FILE_BASE}_wrap.cxx
GENERATED_SOURCES += ../../project/ui_wrap.cxxwhich keeps the wrapper file location but adds a relative path to it which is valid for both the source tree and shadow build tree.
But that is not as neat as your idea.