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. Creator / qmake: Set environment needed to evaluate project tree
Forum Updated to NodeBB v4.3 + New Features

Creator / qmake: Set environment needed to evaluate project tree

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

    I'm trying to integrate existing auto-generated project import files, which require a specific environment variable to point to a specific path, like so:

    SOURCES += \
        $$(MLS_DIR)/frei/mlscodepage.cpp
    

    I do not really want to set such environment variables globally. I would prefer a way that allows me to set these variables within Creator, however, I have not found a way to do so:

    • My .pro file is not a good choice, because other people use it, and they may need different path
    • I tried setting the MLS_DIR in the project setting's system environment section, but to no good result: It seems that qmake evaluates the project structure before these additions to the environment are made: When I output the environment variable through message, I get two passes: One where the variable is set correctly, one where it's empty. And the corresponding source files do not become part of the project tree.

    Any ideas how to solve this?

    Paul ColbyP 1 Reply Last reply
    0
    • A Asperamanca

      I'm trying to integrate existing auto-generated project import files, which require a specific environment variable to point to a specific path, like so:

      SOURCES += \
          $$(MLS_DIR)/frei/mlscodepage.cpp
      

      I do not really want to set such environment variables globally. I would prefer a way that allows me to set these variables within Creator, however, I have not found a way to do so:

      • My .pro file is not a good choice, because other people use it, and they may need different path
      • I tried setting the MLS_DIR in the project setting's system environment section, but to no good result: It seems that qmake evaluates the project structure before these additions to the environment are made: When I output the environment variable through message, I get two passes: One where the variable is set correctly, one where it's empty. And the corresponding source files do not become part of the project tree.

      Any ideas how to solve this?

      Paul ColbyP Offline
      Paul ColbyP Offline
      Paul Colby
      wrote on last edited by
      #2

      Hi @Asperamanca,

      It seems that qmake evaluates the project structure before these additions to the environment are made

      This is correct when you use the $$(...) syntax. In your case, you want to use $(...) instead.

      From qmake Lamguage - Variable Expansion:

      To obtain the contents of an environment value when qmake is run, use the $$(...) operator:
      ...
      To obtain the contents of an environment value at the time when the generated Makefile is processed, use the $(...) operator:

      Cheers.

      1 Reply Last reply
      2
      • A Offline
        A Offline
        Asperamanca
        wrote on last edited by Asperamanca
        #3

        I don't control these files, I have to live with what I get...
        They are currently used in a batch-style make process, where a script sets all the correct variables up front. However, I would like to set up my project within creator so I can actually work with it.

        EDIT: Wait: According to the description you quoted, $$(...) would be the correct use, because Creator would not use the generated makefiles to build the source tree...?

        Paul ColbyP 1 Reply Last reply
        0
        • A Asperamanca

          I don't control these files, I have to live with what I get...
          They are currently used in a batch-style make process, where a script sets all the correct variables up front. However, I would like to set up my project within creator so I can actually work with it.

          EDIT: Wait: According to the description you quoted, $$(...) would be the correct use, because Creator would not use the generated makefiles to build the source tree...?

          Paul ColbyP Offline
          Paul ColbyP Offline
          Paul Colby
          wrote on last edited by Paul Colby
          #4

          @Asperamanca

          The following seems to work fine...

          I added the following to a sample .pro file:

          message(A: $$(MLS_DIR))
          message(B: $(MLS_DIR))
          

          As expected, Qt Creator reloaded the project, with output:

          Project MESSAGE: A:
          Project MESSAGE: B:
          

          Then, in Qt Creator:

          1. clicked Projects
          2. selected the project under Active Project
          3. selected the Build item under Build & Run
          4. clicked the Details link to expand the Build Environment
          5. added a new MLS_DIR variable, setting it to my-new-value
          6. clicked Edit (to go back the code editor view)
          7. right-clicked the project's top-level entry in the Projects tree
          8. clicked "Run qmake"

          Qt Creator then ran qmake, and with the output:

          Project MESSAGE: A: my-new-value
          Project MESSAGE: B: my-new-value
          

          So it seems either will work, as long as you tell Qt Creator to re-run qmake after you've added the new environment variable to the build configuration? Give that a go (if you have't already).

          $$(...) would be the correct use, because Creator would not use the generated makefiles to build the source tree...?

          Qt Creator will use generated Makefiles (for qmake based projects), they're usually just in a folder where you don't notice them. For example, my Qt Creator is currently generating it under /home/paul/tmp/build/<project-name>-Desktop_Qt_5_10_0_GCC_64bit-Debug/.

          Cheers.

          A 1 Reply Last reply
          2
          • Paul ColbyP Paul Colby

            @Asperamanca

            The following seems to work fine...

            I added the following to a sample .pro file:

            message(A: $$(MLS_DIR))
            message(B: $(MLS_DIR))
            

            As expected, Qt Creator reloaded the project, with output:

            Project MESSAGE: A:
            Project MESSAGE: B:
            

            Then, in Qt Creator:

            1. clicked Projects
            2. selected the project under Active Project
            3. selected the Build item under Build & Run
            4. clicked the Details link to expand the Build Environment
            5. added a new MLS_DIR variable, setting it to my-new-value
            6. clicked Edit (to go back the code editor view)
            7. right-clicked the project's top-level entry in the Projects tree
            8. clicked "Run qmake"

            Qt Creator then ran qmake, and with the output:

            Project MESSAGE: A: my-new-value
            Project MESSAGE: B: my-new-value
            

            So it seems either will work, as long as you tell Qt Creator to re-run qmake after you've added the new environment variable to the build configuration? Give that a go (if you have't already).

            $$(...) would be the correct use, because Creator would not use the generated makefiles to build the source tree...?

            Qt Creator will use generated Makefiles (for qmake based projects), they're usually just in a folder where you don't notice them. For example, my Qt Creator is currently generating it under /home/paul/tmp/build/<project-name>-Desktop_Qt_5_10_0_GCC_64bit-Debug/.

            Cheers.

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

            @Paul-Colby
            Thanks for the elaborate answer. I think I'll set the environment variables on system level for now, and find a better solution together with the people who generate these files.

            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