Results 1 to 8 of 8

Thread: What Does $$qtLibraryTarget() Do?

  1. #1
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default 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

    Qt Code:
    1. TARGET = $$qtLibraryTarget(example)
    To copy to clipboard, switch view to plain text mode 

    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

    Qt Code:
    1. TARGET = example
    To copy to clipboard, switch view to plain text mode 

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: What Does $$qtLibraryTarget() Do?

    So why do you use it at all?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: What Does $$qtLibraryTarget() Do?

    Quote Originally Posted by wysota View Post
    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.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: What Does $$qtLibraryTarget() Do?

    Let's make one thing straight - the clean target shouldn't remove the target binary. The distclean one should.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default 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.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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?

    qmake Code:
    1. TARGET=mylibname
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: What Does $$qtLibraryTarget() Do?

    Quote Originally Posted by wysota View Post
    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?

    qmake Code:
    1. TARGET=mylibname
    To copy to clipboard, switch view to plain text mode 
    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.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: What Does $$qtLibraryTarget() Do?

    Quote Originally Posted by SixDegrees View Post
    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:

    qmake Code:
    1. defineReplace(qtLibraryTarget) {
    2. unset(LIBRARY_NAME)
    3. LIBRARY_NAME = $$1
    4. mac:!static:contains(QT_CONFIG, qt_framework) {
    5. QMAKE_FRAMEWORK_BUNDLE_NAME = $$LIBRARY_NAME
    6. export(QMAKE_FRAMEWORK_BUNDLE_NAME)
    7. }
    8. contains(TEMPLATE, .*lib):CONFIG(debug, debug|release) {
    9. !debug_and_release|build_pass {
    10. mac:RET = $$member(LIBRARY_NAME, 0)_debug
    11. else:win32:RET = $$member(LIBRARY_NAME, 0)d
    12. }
    13. }
    14. isEmpty(RET):RET = $$LIBRARY_NAME
    15. return($$RET)
    16. }
    To copy to clipboard, switch view to plain text mode 

    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).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. [SOLVED] Q_EXPORT_PLUGIN2 vs. $$qtLibraryTarget()
    By zaphod.b in forum Qt Programming
    Replies: 2
    Last Post: 24th July 2009, 14:40

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.