What Does $$qtLibraryTarget() Do?
I've been using $$qtLibraryTarget() as a wrapper around library target names in my project, but I'm not sure what it does; there doesn't seem to be much documentation on it. One thing it definitely does is screw up qmake's Makefile 'clean' targets - the libraries generated with $$qtLibraryTarget() are never removed by 'make clean' or 'make distclean'. If the function call is removed and the library basename simply assigned to TARGET, 'clean' is able to get rid of the generated library, as expected.
And the function itself doesn't seem to do anything qmake doesn't already do. If I use it like
Code:
TARGET = $$qtLibraryTarget(example)
the Makefile produces (on Linux) a file named libexample.so for plugin projects, or the same plus symbolic links with version information if I'm building a plain library. However, if I simply say
the Makefile produces...exactly the same thing.
In the interest of making my 'clean' targets work correctly, I'm thinking I'll yank $$qtLibraryTarget() throughout my project, which generates several libraries and plugins. But if the function actually does something useful, I'd like to hear about it before taking this step.
Re: What Does $$qtLibraryTarget() Do?
So why do you use it at all?
Re: What Does $$qtLibraryTarget() Do?
Quote:
Originally Posted by
wysota
So why do you use it at all?
By example. Several project files within Qt and their published examples use it - though not all. I can't find an explanation of whether or why it should be used. Although not using it always seems to do the "right thing" in my case, it would be nice to know with certainty whether qmake will always be so prescient, or if someday, on another system or when another set of circumstances prevail, it will suddenly all go wrong.
Re: What Does $$qtLibraryTarget() Do?
Let's make one thing straight - the clean target shouldn't remove the target binary. The distclean one should.
Re: What Does $$qtLibraryTarget() Do?
Maybe so. However, neither target removes the libraries when they're specified with $$qtLibraryTarget(), while they are removed - perhaps only by distclean - when $$qtLibraryTarget() isn't used.
Since this "feature" doesn't seem to be documented anywhere, I'm beginning to think it's an internal qmake function that has "escaped" into the wild, and probably shouldn't be used in production code. My guess is that it simply generates the system-specific library name, and is probably used when the library or plugin template is specified, but really doesn't belong in the project file itself.
I'll give it a couple more days to see if anyone really knows what it does or what it's for. Then, I guess I'll yank it.
Re: What Does $$qtLibraryTarget() Do?
How do you use this function? All it does is return the name of the library. What happens if you write this instead of using the function?
Re: What Does $$qtLibraryTarget() Do?
Quote:
Originally Posted by
wysota
How do you use this function? All it does is return the name of the library. What happens if you write this instead of using the function?
See my original post; I already know what the function's outputs are, or seem to be, and I already have a mixture of project files, some that use it, others that don't.
My question is simple: what, exactly, is the function supposed to do? Since no one seems to know the answer to that question, I'm left to assume that it's simply an internal function that, as already noted, returns the system-specific name of the library being built, that it is used internally by qmake for this purpose, and the multitude of examples both in the Qt tutorials and examples code and scattered, albeit inconsistently, throughout Qt's source tree itself are, in fact, pointless escapees from the development environment.
At least, that's the assumption I'm going to adopt unless someone can put forward some actual documentation.
Re: What Does $$qtLibraryTarget() Do?
Quote:
Originally Posted by
SixDegrees
My question is simple: what, exactly, is the function supposed to do? Since no one seems to know the answer to that question, I'm left to assume that it's simply an internal function that, as already noted, returns the system-specific name of the library being built, that it is used internally by qmake for this purpose, and the multitude of examples both in the Qt tutorials and examples code and scattered, albeit inconsistently, throughout Qt's source tree itself are, in fact, pointless escapees from the development environment.
At least, that's the assumption I'm going to adopt unless someone can put forward some actual documentation.
Qt is open-source, just look into the function code:
Code:
defineReplace(qtLibraryTarget) {
unset(LIBRARY_NAME)
LIBRARY_NAME = $$1
mac:!static:contains(QT_CONFIG, qt_framework) {
QMAKE_FRAMEWORK_BUNDLE_NAME = $$LIBRARY_NAME
export(QMAKE_FRAMEWORK_BUNDLE_NAME)
}
contains(TEMPLATE, .*lib):CONFIG(debug, debug|release) {
!debug_and_release|build_pass {
mac:RET = $$member(LIBRARY_NAME, 0)_debug
else:win32:RET = $$member(LIBRARY_NAME, 0)d
}
}
isEmpty(RET):RET = $$LIBRARY_NAME
return($$RET)
}
Like I already said, it returns the name of the library (with "d" or "_debug" appended for windows and mac respectively when running in debug mode). It's a direct equivalent of "TARGET=xyz" (apart from assigning the value of course).