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, slashes, and custom build steps

Qmake, slashes, and custom build steps

Scheduled Pinned Locked Moved Qt Creator and other tools
6 Posts 3 Posters 7.5k Views 1 Watching
  • 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.
  • B Offline
    B Offline
    barkan.alon
    wrote on last edited by
    #1

    Hi,

    I'm using Qt 4.7.3, VS 2008, Windows XP.

    I have a project file where the INCLUDEPATH variable includes a path that ends with a slash, e.g. like this: @ INCLUDEPATH += c:/mydir/@
    This causes a problem with the generated custom build step that runs moc, as described "here ":http://www.qtforum.org/article/33308/problems-with-qmake-and-visual-studio.html (I'm not the OP).

    I dug a little deeper and found that the problem is this:

    • When generating the VS project files, qmake replaces the forward-slash with a backslash. This results in a custom build step command-line that includes this switch:
      @-I"c:\mydir"@
    • When run, the Windows command interpreter interprets the backslash followed by double quotes as an escaped double quotes. This eventually ruins moc's command line - it's input-file parameter is now part of some other parameter that doesn't have closing quotes.
    • When run with no input filename, moc tries to read from stdin. Since there's nothing there, all moc sees is an empty input file, resulting in the "No relevant classes found" message and no output file. I verified this by running the custom build step command-line in a 'cmd.exe' window - moc just waits for stdin.

    My suggestion is to change qmake so it would detect include paths that end with a backslash, and add another backslash, e.g.: @-I"c:\mydir\"@ This way the quotes aren't escaped, and Windows is appeased :).
    Another option is to remove trailing slashes from paths altogether, unless the path is the root of a drive, in which case you still need two backslashes.

    Now sure you can also just put a double slash in the project file to achieve the solution, but this puts the burden on the user, and when a problem occurs it's tricky to find the root of the problem (took me some time).

    Thanks!
    Alon

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jim_kaiser
      wrote on last edited by
      #2

      Or... you could not put the "/" at the end of the path. Generally for a folder path, the trailing slash is not needed. That should solve your problem.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        barkan.alon
        wrote on last edited by
        #3

        bq. Generally for a folder path, the trailing slash is not needed.

        Not entirely true: The trailing slash is indeed not mandatory for most folder paths, but it is mandatory for the root of a drive - e.g. "c:" isn't a legal path, so -I"c:" doesn't work, but -I"c:\" does.

        1 Reply Last reply
        0
        • F Offline
          F Offline
          Franzk
          wrote on last edited by
          #4

          I have always wondered why anyone in his right mind would use an escape character as path separator.

          "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • B Offline
            B Offline
            barkan.alon
            wrote on last edited by
            #5

            Franzk: See "here":http://blogs.msdn.com/b/larryosterman/archive/2005/06/24/432386.aspx for some history.

            1 Reply Last reply
            0
            • F Offline
              F Offline
              Franzk
              wrote on last edited by
              #6

              Heh, at least the devs were somewhat sane :P

              "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0

              • Login

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