Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Having custom variables in Makefile
QtWS25 Last Chance

[SOLVED] Having custom variables in Makefile

Scheduled Pinned Locked Moved General and Desktop
qmakemakemakefile
16 Posts 3 Posters 7.3k 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.
  • S Offline
    S Offline
    SGaist
    Lifetime Qt Champion
    wrote on 24 Aug 2015, 19:42 last edited by
    #7

    Sorry, it seems that the code highlighter is not working exactly the same when you are editing the answer and once it's re-loaded.

    I've fixed it. Please take a look again, it's already working for environment variables.

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

    K 1 Reply Last reply 25 Aug 2015, 15:58
    0
    • S SGaist
      24 Aug 2015, 19:42

      Sorry, it seems that the code highlighter is not working exactly the same when you are editing the answer and once it's re-loaded.

      I've fixed it. Please take a look again, it's already working for environment variables.

      K Offline
      K Offline
      kumararajas
      wrote on 25 Aug 2015, 15:58 last edited by kumararajas
      #8

      Sam, I am bit confused.

      If I understand correctly,

      Having your code,

      TESTSTR = '\\"$\\"'
      DEFINES += TEST=\"$\"
      

      Should I need to add my environment variable here?
      Example:

      TSTR = '\\"$(BOOST_PATH)\\"'
      DEFINES += TEST=$${TSTR}
      

      Makefile looks like this:

      -DTEST=\"$(BOOST_PATH)\"
      

      Or I understood wrongly?

      Please clarify. Thank you very much for your kind help..

      --Kumara

      --Kumar

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 25 Aug 2015, 16:12 last edited by SGaist
        #9

        Sorry again about the code formatting…

        Trying again here:

        TESTSTR = '\\"$$(TEST)\\"'
        DEFINES += TEST=\"\$\$\{TESTSTR\}\"

        On that last line remove the backslashes before the dollar signs and curly braces...

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

        K 1 Reply Last reply 25 Aug 2015, 16:55
        0
        • S SGaist
          25 Aug 2015, 16:12

          Sorry again about the code formatting…

          Trying again here:

          TESTSTR = '\\"$$(TEST)\\"'
          DEFINES += TEST=\"\$\$\{TESTSTR\}\"

          On that last line remove the backslashes before the dollar signs and curly braces...

          K Offline
          K Offline
          kumararajas
          wrote on 25 Aug 2015, 16:55 last edited by kumararajas
          #10

          I did try the exact as you said..
          STRT = '\\"$(BOOST_PATH)\\"'
          DEFINES += BOOST_PATH=\"\$\$\{STRT\}\"
          And the output is,
          -DBOOST_PATH="$${STRT}"

          And I tried removing the back slashes on dollar sign and curly braces
          STRT = '\\"$(BOOST_PATH)\\"'
          DEFINES += BOOST_PATH=\"$${STRT}\"
          And the output is
          -DBOOST_PATH="\"$(BOOST_PATH)\""

          Still no success..

          --Kumara

          --Kumar

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 25 Aug 2015, 19:52 last edited by SGaist
            #11

            What do you get for the various variable if you show a message with their content:

            e.g.

            message($$(BOOST_PATH))
            message(\$\$\{STRT\})
            ?

            Again, remove the backslashes in the second line...

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

            K 1 Reply Last reply 25 Aug 2015, 20:30
            0
            • S SGaist
              25 Aug 2015, 19:52

              What do you get for the various variable if you show a message with their content:

              e.g.

              message($$(BOOST_PATH))
              message(\$\$\{STRT\})
              ?

              Again, remove the backslashes in the second line...

              K Offline
              K Offline
              kumararajas
              wrote on 25 Aug 2015, 20:30 last edited by kumararajas
              #12

              While printing a message, it looks good.

              message($(BOOST_PATH))

              Project MESSAGE: /path/to/boost
              

              message($${STRT})

              Project MESSAGE: \"/path/to/boost\"
              

              But why this has not been taken to Makefile? Mysteries..

              --Kumar

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 25 Aug 2015, 20:40 last edited by
                #13

                Then you are likely just missing some escaping for the last call...

                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
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 25 Aug 2015, 20:54 last edited by
                  #14

                  Finally found a way to write it:

                  BOOST = $ $ ( BOOST_PATH )
                  BOOST_STR = ' \ \ " $ $ { BOOST } \ \ " '
                  DEFINES += BOOST_PATH= \ " $ $ { BOOST_STR } \ "
                  

                  Extra spaces to be removed for the sample code

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

                  K 1 Reply Last reply 25 Aug 2015, 20:59
                  1
                  • S SGaist
                    25 Aug 2015, 20:54

                    Finally found a way to write it:

                    BOOST = $ $ ( BOOST_PATH )
                    BOOST_STR = ' \ \ " $ $ { BOOST } \ \ " '
                    DEFINES += BOOST_PATH= \ " $ $ { BOOST_STR } \ "
                    

                    Extra spaces to be removed for the sample code

                    K Offline
                    K Offline
                    kumararajas
                    wrote on 25 Aug 2015, 20:59 last edited by
                    #15

                    Thanks Sam, for helping me to fix the problem.

                    I do confirm that, it works.

                    (I do not want copy the instruction again here, which contains more spaces :P)

                    With the above code, I can see this in my Makefile

                    -DBOO_PATH="/path/to/boost"
                    

                    It has been a great help! Thanks a lot.

                    --Kumara

                    --Kumar

                    K 1 Reply Last reply 25 Aug 2015, 23:21
                    0
                    • K kumararajas
                      25 Aug 2015, 20:59

                      Thanks Sam, for helping me to fix the problem.

                      I do confirm that, it works.

                      (I do not want copy the instruction again here, which contains more spaces :P)

                      With the above code, I can see this in my Makefile

                      -DBOO_PATH="/path/to/boost"
                      

                      It has been a great help! Thanks a lot.

                      --Kumara

                      K Offline
                      K Offline
                      kumararajas
                      wrote on 25 Aug 2015, 23:21 last edited by kumararajas
                      #16

                      Later to that,

                      I have figured out a problem in having:

                      We need to have \" in the argument:
                      -DBOO_PATH="/path/to/boost"
                      Problem is that, the macro turned out to be
                      #define BOO_PATH /path/to/boost
                      which is actually useless. We need to have double quotes to cover them up.

                      BOOST =  $ $ ( BOOST_PATH )
                      BOOST_STR = ' \ \ " $ $ { BOOST } \ \ " '
                      DEFINES += BOOST_PATH=\ " $ $ { BOOST_STR } \"
                      

                      Again, eliminate the spaces :)

                      --Kumar

                      1 Reply Last reply
                      0

                      16/16

                      25 Aug 2015, 23:21

                      • Login

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