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: How to set a variable that must contain spaces?
Forum Update on Monday, May 27th 2025

qmake: How to set a variable that must contain spaces?

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
7 Posts 3 Posters 2.8k 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.
  • A Offline
    A Offline
    Asperamanca
    wrote on last edited by
    #1

    I need to set QMAKE_CXXFLAGS to a value that contains spaces, specifically

    QMAKE_CXXFLAGS += /AI"$$(PROGRAMFILES)/Reference Assemblies/Microsoft/Framework/.NETFramework/v4.0"
    

    The PROGRAMFILES environment variable will (usually) resolve to a path with spaces. How can I handle that?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You can try shell_path or maybe shell_quote.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      A 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        You can try shell_path or maybe shell_quote.

        Hope it helps

        A Offline
        A Offline
        Asperamanca
        wrote on last edited by
        #3

        @SGaist
        Forgot to mention I'm still sitting on 4.8...

        aha_1980A 1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          In that case, did you try with just quote ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • A Asperamanca

            @SGaist
            Forgot to mention I'm still sitting on 4.8...

            aha_1980A Offline
            aha_1980A Offline
            aha_1980
            Lifetime Qt Champion
            wrote on last edited by aha_1980
            #5

            @Asperamanca

            Without the possibility to test, I think you have to escape the quotes with enough escape chars ('') so the quotes actually get to the shell. You may need two or three pairs of '' to get it work - just test until it works :)

            QMAKE_CXXFLAGS += /AI"\\"$$(PROGRAMFILES)/Reference Assemblies/Microsoft/Framework/.NETFramework/v4.0\\""
            

            Edit: seems my escape chars were lost, I meant backslashes '\'

            Qt has to stay free or it will die.

            A 1 Reply Last reply
            3
            • aha_1980A aha_1980

              @Asperamanca

              Without the possibility to test, I think you have to escape the quotes with enough escape chars ('') so the quotes actually get to the shell. You may need two or three pairs of '' to get it work - just test until it works :)

              QMAKE_CXXFLAGS += /AI"\\"$$(PROGRAMFILES)/Reference Assemblies/Microsoft/Framework/.NETFramework/v4.0\\""
              

              Edit: seems my escape chars were lost, I meant backslashes '\'

              A Offline
              A Offline
              Asperamanca
              wrote on last edited by
              #6

              @aha_1980
              That put me on the right track. The solution is:

              QMAKE_CXXFLAGS += /AI\"$$(PROGRAMFILES)/Reference Assemblies/Microsoft/Framework/.NETFramework/v4.0\"
              

              Thanks!

              aha_1980A 1 Reply Last reply
              1
              • A Asperamanca

                @aha_1980
                That put me on the right track. The solution is:

                QMAKE_CXXFLAGS += /AI\"$$(PROGRAMFILES)/Reference Assemblies/Microsoft/Framework/.NETFramework/v4.0\"
                

                Thanks!

                aha_1980A Offline
                aha_1980A Offline
                aha_1980
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @Asperamanca Cool! Thanks for reporting back.

                Please mark this thread as solved now.

                Qt has to stay free or it will die.

                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