Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qmake quote function not actually putting quote

Qmake quote function not actually putting quote

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
5 Posts 2 Posters 5.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mwoua
    wrote on last edited by
    #1

    Hello,
    I am using this function (found on StaockOverflow) to copy files at the end of my build process

        defineTest(copyToDestDir) {
            files = $$1
    
            for(FILE, files) {
                DDIR = $$DESTDIR
    
                # Replace slashes in paths with backslashes for Windows
                win32:FILE ~= s,/,\\,g
                win32:DDIR ~= s,/,\\,g
    
                QMAKE_POST_LINK += $$QMAKE_COPY $$quote($$FILE) $$quote($$DDIR) $$escape_expand(\\n\\t)
            }
            export(QMAKE_POST_LINK)
        }
    

    The problem I have, is that the quote function does not put quote. In my compile output window I have :
    copy /y C:\Users\user101\Documents\WS\Qt\main\Host..\Libs\FTDI\x64* ..\Output\Debugx86_64

    => There is no quote

    And on another machine, the build path has a space in it, so it doesnt work at all.

    I have found this bug report : https://bugreports.qt.io/browse/QTBUG-44083 but it has been closed almost instantly because there is no bug.

    So what is the intended behavior of quote()?
    And How can qmake actually put quote so my copy works with space in it?

    K 1 Reply Last reply
    1
    • M Mwoua

      Hello,
      I am using this function (found on StaockOverflow) to copy files at the end of my build process

          defineTest(copyToDestDir) {
              files = $$1
      
              for(FILE, files) {
                  DDIR = $$DESTDIR
      
                  # Replace slashes in paths with backslashes for Windows
                  win32:FILE ~= s,/,\\,g
                  win32:DDIR ~= s,/,\\,g
      
                  QMAKE_POST_LINK += $$QMAKE_COPY $$quote($$FILE) $$quote($$DDIR) $$escape_expand(\\n\\t)
              }
              export(QMAKE_POST_LINK)
          }
      

      The problem I have, is that the quote function does not put quote. In my compile output window I have :
      copy /y C:\Users\user101\Documents\WS\Qt\main\Host..\Libs\FTDI\x64* ..\Output\Debugx86_64

      => There is no quote

      And on another machine, the build path has a space in it, so it doesnt work at all.

      I have found this bug report : https://bugreports.qt.io/browse/QTBUG-44083 but it has been closed almost instantly because there is no bug.

      So what is the intended behavior of quote()?
      And How can qmake actually put quote so my copy works with space in it?

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      @Mwoua said in Qmake quote function not actually putting quote:

      defineTest(copyToDestDir) {
          files = $$1
      
          for(FILE, files) {
              DDIR = $$DESTDIR
      
              # Replace slashes in paths with backslashes for Windows
              win32:FILE ~= s,/,\\,g
              win32:DDIR ~= s,/,\\,g
      
              QMAKE_POST_LINK += $$QMAKE_COPY $$quote($$FILE) $$quote($$DDIR) $$escape_expand(\\n\\t)
          }
          export(QMAKE_POST_LINK)
      }
      

      change to

      defineTest(copyToDestDir) {
             files = $$1
      
             for(FILE, files) {
                 DDIR = $$DESTDIR
      
                 # Replace slashes in paths with backslashes for Windows
                 win32:FILE ~= s,/,\\,g
                 win32:DDIR ~= s,/,\\,g
      
                 QMAKE_POST_LINK += $$QMAKE_COPY $$shell_quote($$FILE) $$shell_quote($$DDIR) $$escape_expand(\\n\\t)
             }
             export(QMAKE_POST_LINK)
         }
      

      basically you should use shell_quote instead of quote.

      That is what the comment in the bug report says.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      2
      • M Offline
        M Offline
        Mwoua
        wrote on last edited by
        #3

        Thats what I was trying, and it works, thanks.

        But what does quote function does?

        K 1 Reply Last reply
        0
        • M Mwoua

          Thats what I was trying, and it works, thanks.

          But what does quote function does?

          K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          @Mwoua

          The only thing I can offer are the comments in JIRA. It is not clear to me either.

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          0
          • K Offline
            K Offline
            koahnig
            wrote on last edited by
            #5

            Just playing a bit around brings this output

            FOOS = this is a string
            message("FOOS " $$FOOS)
            contains(FOOS, this is a string) {
            message("Does first contains ")
            }
            contains(FOOS, is) {
            message("Does second contains ")
            }
            message(" ")
            FOOS = "this is a string"
            message("FOOS " $$FOOS)
            contains(FOOS, this is a string) {
            message("Does first contains ")
            }
            contains(FOOS, is) {
            message("Does second contains ")
            }
            message(" ")
            
            FOOS = $$quote(this is a string)
            message("FOOS " $$FOOS)
            contains(FOOS, this is a string) {
            message("Does first contains ")
            }
            contains(FOOS, is) {
            message("Does second contains ")
            }
            message(" ")
            
            FOO = $$shell_quote(this is a string)
            message("FOO " $$FOO)
            FOO2 = $$system_quote(this is a string)
            message("FOO2 " $$FOO2)
            

            and the output is:

            Project MESSAGE: FOOS  this is a string
            Project MESSAGE: Does second contains 
            Project MESSAGE:  
            Project MESSAGE: FOOS  this is a string
            Project MESSAGE: Does first contains 
            Project MESSAGE:  
            Project MESSAGE: FOOS  this is a string
            Project MESSAGE: Does first contains 
            Project MESSAGE:  
            Project MESSAGE: FOO  "this is a string"
            Project MESSAGE: FOO2  "this is a string"
            

            Therefore, using the quote function is simply the same as putting a string into quotes. Assigning a string to a variable without quotes results into a string list. Only quotes or the quote function assigns a single string.

            In case also quotes have to be added to the variable one may use functions shell_quote or system_quote.

            Vote the answer(s) that helped you to solve your issue(s)

            1 Reply Last reply
            2

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved