Results 1 to 5 of 5

Thread: It is possible to rename file with qmake

  1. #1
    Join Date
    Apr 2012
    Posts
    10
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default It is possible to rename file with qmake

    Hi
    I want to create "make install" for my project. I use INSTALLS variable and all works fine but i want installed file to be renamed. How i can achieve this
    I trying this
    Qt Code:
    1. Install.path = path/for/installation
    2.  
    3. install.file = file.something
    4.  
    5. install.name = newname.somthingelse
    6.  
    7. INSTALLS += install
    To copy to clipboard, switch view to plain text mode 
    but this don't work. I know about install.extra but don't know how to use this variable

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: It is possible to rename file with qmake

    You can do it this way (at the expense of a copy that does not get cleaned up):
    Qt Code:
    1. TEMPLATE = app
    2. TARGET =
    3. DEPENDPATH += .
    4. INCLUDEPATH += .
    5.  
    6. unix {
    7. target.path = /tmp/installpath
    8. INSTALLS += target
    9.  
    10. extra_install.path = /tmp/installpath
    11. extra_install.files = renamed.txt
    12. extra_install.extra = cp test.txt renamed.txt
    13. INSTALLS += extra_install
    14. }
    15.  
    16. # Input
    17. SOURCES += main.cpp
    18. OTHER_FILES += test.txt
    To copy to clipboard, switch view to plain text mode 
    The extra command can be a whole script.
    "We can't solve problems by using the same kind of thinking we used when we created them." -- Einstein
    If you are posting code then please use [code] [/code] tags around it - makes addressing the problem easier.

  3. The following user says thank you to ChrisW67 for this useful post:

    themean (29th June 2012)

  4. #3
    Join Date
    Dec 2012
    Posts
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: It is possible to rename file with qmake

    Hi @all,

    the mentioned approach will work fine using unix/linux. However, what if you want to make the same for Windows?
    Of course I could add a similar section for win32. But then the pathes need backslashes \ rather than forwar slashes / (because of "copy") and if I want to use path-variables, I will have to declare them for unix and win32 separately

    It would be nice, if there would be a possibility to install a (extra) target under a different name, which is not platform dependent ...

    Best,

    Thorsten



    Qt Code:
    1. TEMPLATE = app
    2. TARGET =
    3. DEPENDPATH += .
    4. INCLUDEPATH += .
    5.  
    6. target.path = ../tmp/installpath # will not work for win32
    7. win32: target.path = ..\tmp\installpath # is necessary only due to "copy"
    8.  
    9. extra_install.path =$$target.path
    10. extra_install.files = renamed.txt
    11.  
    12. unix {
    13. extra_install.extra = cp test.txt renamed.txt
    14. }
    15. win32 {
    16. extra_install.extra = copy test.txt renamed.txt
    17. }
    18.  
    19. INSTALLS += target
    20. INSTALLS += extra_install
    21. # Input
    22. SOURCES += main.cpp
    23. OTHER_FILES += test.txt
    To copy to clipboard, switch view to plain text mode 

  5. #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: It is possible to rename file with qmake

    You can convert slashes to backslashes using a regular expression in qmake directive if that's the problem.
    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.


  6. #5
    Join Date
    Dec 2012
    Posts
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: It is possible to rename file with qmake

    Well - that's it exactly ...

    [CODE]
    $replace(install_gspf.path,'/','\\')\\GSPFKrnl.exe
    [CODE]

    did the job ... Thx

Similar Threads

  1. Rename File
    By lsropia in forum General Programming
    Replies: 3
    Last Post: 22nd October 2011, 11:47
  2. qmake: does no generate .h file from .ui file
    By miodas007 in forum Newbie
    Replies: 7
    Last Post: 18th April 2011, 22:57
  3. rename file name
    By weixj2003ld in forum Qt Programming
    Replies: 11
    Last Post: 8th April 2010, 10:27
  4. File rename detection
    By bunjee in forum Qt Programming
    Replies: 6
    Last Post: 23rd July 2009, 15:22
  5. How to rename a file after opening ?
    By npc in forum Newbie
    Replies: 2
    Last Post: 1st June 2006, 13:36

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.