[SOLVED] How can I add extra configs to a subproject at run time?
I have a project that depends on an external lib, structured like this:
The lib is itself a working qmake project, producing a dynamic-linked library, but instead of installing it to the target machine I want to statically linked to it instead.
I know that I can add CONFIG += staticlib to the lib's .pro file to make it produce a static lib, but I would prefer not to modify the project itself, so that I can include the project as a git submodule directly. But is it possible? How? Adding CONFIG += staticlib in neither project.pro nor 3rdparty.pro works.
Have you tried to add CONFIG+=staticlib to qmake command line?
If you use QtCreator then you can add this option to a build step in a Projects page.
Yes it works—thanks for pointing it out.
Wonders if there's a solution that works if I ever want this not to be global and want this to be applied only to selected subdirs. But this works for my use case.
I just came up with an another solution with ".qmake.cache and QMAKE_SUBSTITUTES":http://qt-project.org/wiki/QMake-top-level-srcdir-and-builddir . I put file .qmake.cache.in containing CONFIG+=staticlib in my 3rdparty directory, and added an extra rule QMAKE_SUBSTITUTES+=.qmake.cache in 3rdparty.pro. Seems like a a better solution for me since I don't need to remember typing qmake CONFIG+=staticlib anymore.
And this can probably solve the selected subdir problem I mentioned in the previous comment. You can make a new job that generates qmake.cache.in files at runtime in selected paths, and make 3rdparty.pro depend on it. Haven't try it, but seems like it would work.