Building 3rd party library before own project
-
One of the projects I'm working on, uses LibTIFF as an svn:external library (http://www.remotesensing.org/libtiff/). We want to build LibTIFF ourselves and integrate that in our project's build process. Thus, before we can build our own source code and link with the LibTIFF library, we first need to build LibTIFF. According to the build instructions for Windows on http://www.remotesensing.org/libtiff/build.html#PC, all we have to do is
cd %LIBTIFF_DIRECTORY% nmake /f makefile.vc clean nmake /f makefile.vc
Our project uses qmake to generate the Visual Studio project files, and then Msbuild to start the build. How can we make sure LibTIFF is built first? I assume we need to specify something in the qmake .pro file of our project? How is this typically handled?
-
Build order:
TEMPLATE = subdirs SUBDIRS = lib app CONFIG += ordered app.depends = lib
see this for adding custom commands to qmake
But be aware that the vcxproj conversion of qmake isn't actively developed anymore. So this may produce some faulty projects in some cases.
-
@raven-worx said:
TEMPLATE = subdirs SUBDIRS = lib app app.depends = lib
Isn't this a solution for when lib also has a .pro file? In my case (LibTIFF from http://www.remotesensing.org/libtiff/) does not have a qmake .pro file. Instead of starting to write my own .pro file for LibTIFF, I prefer to use the recommended nmake build instructions from their website (http://www.remotesensing.org/libtiff/build.html#PC):
nmake /f makefile.vc clean nmake /f makefile.vc
see this for adding custom commands to qmake
Perhaps I also should've mentioned that we're currently still stuck with Qt 4.8.7, but on http://doc.qt.io/qt-4.8/qmake-environment-reference.html#customizing I see that QMAKE_EXTRA_TARGETS is also supported in 4.8.7. So I guess QMAKE_EXTRA_TARGETS is the way to go here?
-
@Bart_Vandewoestyne said:
Isn't this a solution for when lib also has a .pro file? In my case (LibTIFF from http://www.remotesensing.org/libtiff/) does not have a qmake .pro file. Instead of starting to write my own .pro file for LibTIFF, I prefer to use the recommended nmake build instructions from their website (http://www.remotesensing.org/libtiff/build.html#PC):
thats why i posted the link which shows you how to add a custom build command to call your makefile
-
Hi! There is also a wiki article on this, see: https://wiki.qt.io/SUBDIRS_-_handling_dependencies. Getting this right (at least with Qt 4 and MSVC) seems to be a bit messy.
-
@raven-worx said:
@Bart_Vandewoestyne said:
Isn't this a solution for when lib also has a .pro file? In my case (LibTIFF from http://www.remotesensing.org/libtiff/) does not have a qmake .pro file. Instead of starting to write my own .pro file for LibTIFF, I prefer to use the recommended nmake build instructions from their website (http://www.remotesensing.org/libtiff/build.html#PC):
thats why i posted the link which shows you how to add a custom build command to call your makefile
Following the explanation on http://doc.qt.io/qt-4.8/qmake-environment-reference.html#customizing I am currently trying this in my .pro file:
buildLibTIFF.target = .buildLibTIFF buildLibTIFF.commands += cd /some/path/to/ThirdParty/LibTIFF buildLibTIFF.commands += nmake /f Makefile.vc QMAKE_EXTRA_TARGETS += buildLibTIFF PRE_TARGETDEPS += .buildLibTIFF
but LibTIFF doesn't get built. Note that we're using Qt 4.8.7 and msbuild 4.6.1055.0 (the one that comes with Visual Studio 2012).
I'm not sure if it has to do with this, but in the documentation for the PRE_TARGETDEPS variable in Qt 4.8 at http://doc.qt.io/qt-4.8/qmake-variable-reference.html#pre-targetdeps I find
Some backends do not support this, these include MSVC Dsp, and ProjectBuilder .pbproj files
but in the documentation for PRE_TARGETDEPS in Qt 5 at http://doc.qt.io/qt-5/qmake-variable-reference.html#pre-targetdeps Visual Studio is explicitly mentioned:
Some backends, such as the generators for Visual Studio and Xcode project files, do not support this variable.
I'm stuck at this point :-(
-
Hi,
A bit off topic but why not use the libtiff bundled with Qt ? That could avoid you the trouble having to build an external version of it. Unless you absolutely need that specific version.