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. How to make DEFINES += SOMETHING to be visible only if current .pro file is being build
Forum Update on Monday, May 27th 2025

How to make DEFINES += SOMETHING to be visible only if current .pro file is being build

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 1.2k 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.
  • K Offline
    K Offline
    Kofr
    wrote on last edited by
    #1

    Hi, I have qmake template subdirs.
    One subdir for project sources and one for unit tests.

    • main.pro
      • src.pro
      • tests.pro

    I want that when building tests.pro which depends on .h and .cpp files of src.pro the TESTING_ENABLED macro be defined.
    But if I simply put line in tests.pro DEFINES += TESTING_ENABLED this define is seen over the project. How to mae it defined only if I compile tests.pro?

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

      Hi,

      How exactly are you setting up you tests ?

      I usually have each unit tests in its own project and if I need something I put in a .pri file that I include from the unit tests .pro file.

      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
      0
      • SGaistS SGaist

        Hi,

        How exactly are you setting up you tests ?

        I usually have each unit tests in its own project and if I need something I put in a .pri file that I include from the unit tests .pro file.

        K Offline
        K Offline
        Kofr
        wrote on last edited by Kofr
        #3

        @SGaist i use
        scr
        However question is why qmake DEFINES written in test (isvalueok.pro) are available in src.pro when I build src.pro and how to make it separate.

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

          Can you share a minimal compilable example that reproduce this behaviour ?

          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
          0
          • SGaistS SGaist

            Can you share a minimal compilable example that reproduce this behaviour ?

            K Offline
            K Offline
            Kofr
            wrote on last edited by Kofr
            #5

            @SGaist I could not reproduce it (
            simplified working one code
            In my large project I still have this problem. May be it is a bug of 5.8 as in 5.7 all worked correctly.

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

              That's a possibility yes. The only way I currently see is to try to disable everything in your project and rebuild until you see the behaviour happening.

              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
              • ArtmeticA Offline
                ArtmeticA Offline
                Artmetic
                wrote on last edited by
                #7

                in pro file use

                include(subfolderName/tests.pri)

                change .pro files that are subprojets to .pri

                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