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: automatic addition of source files
Forum Updated to NodeBB v4.3 + New Features

qmake: automatic addition of source files

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

    Is there any possibility to tell qmake and Qt Creator to automatically load all .cpp and .h from a directory including all its subdirectories? Is there a magic rule for .pro file which solves it?

    I am working on GUI which is connected to another (non-Qt) C++ application. People working on that app add new files or change existing ones. When I download these changes via git to my local repository, I have to check it and add all new files manually to .pro file. That is really annoying. Thus, I am looking for a better way. The best option would be to tell the .pro file about one directory where all sources and headers are located and it will load them dynamically including all subdirectories.

    Thanks,

    thompsonx

    J.HilkJ 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      well there are way to do something like that
      https://stackoverflow.com/questions/3806833/qmake-automatically-compiling-all-files-in-a-directory

      1 Reply Last reply
      0
      • thompsonxT thompsonx

        Is there any possibility to tell qmake and Qt Creator to automatically load all .cpp and .h from a directory including all its subdirectories? Is there a magic rule for .pro file which solves it?

        I am working on GUI which is connected to another (non-Qt) C++ application. People working on that app add new files or change existing ones. When I download these changes via git to my local repository, I have to check it and add all new files manually to .pro file. That is really annoying. Thus, I am looking for a better way. The best option would be to tell the .pro file about one directory where all sources and headers are located and it will load them dynamically including all subdirectories.

        Thanks,

        thompsonx

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        @thompsonx
        well you could write a small programm to do that for you.

        Read your *.pro file and save the content in a String/Bytearray ignore everything SOURCES +=, HEADERS += and FORMS +=.
        Recursively go through all sub dirs add *h, *p *.ui files to seperate lists.

        Add those lists to your Pro file

        Save the new file.

        :-)


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        1 Reply Last reply
        0
        • thompsonxT Offline
          thompsonxT Offline
          thompsonx
          wrote on last edited by
          #4

          @mrjj said in qmake: automatic addition of source files:

          Hi
          well there are way to do something like that
          https://stackoverflow.com/questions/3806833/qmake-automatically-compiling-all-files-in-a-directory

          thx for reply, @mrjj . The proposed solution has a disadvantage. In my .pro file apart from SOURCES and HEADERS I also specify some qmake flags, include some libs and add includepaths which are necessary for the application that I am connecting the GUI to. With your solution I have to store the flags and all that stuff somewhere and copy it to a new .pro everytime. Am I right?

          @J-Hilk
          thx. Of course, this is a solution :-D But I would prefer a solution via .pro file if exists.

          1 Reply Last reply
          0
          • mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @thompsonx said in qmake: automatic addition of source files:

            With your solution I have to store the flags and all that stuff somewhere and copy it to a new .pro everytime. Am I right?

            yes it just discovers files. it cant possible know any compile options from the files alone.
            But it makes a .pri file so in theory some options can survive a rescan if you can maybe include
            another pri file in the pri file etc.
            Normally you do not want it to find random .cpp and include in the project so its
            not something i tried a lot of times :)

            1 Reply Last reply
            0
            • thompsonxT Offline
              thompsonxT Offline
              thompsonx
              wrote on last edited by
              #6

              Ok, I understand. So, possibly I can keep somewhere a .pri file with compiler flags etc. and include it to the final .pro file created by qmake. True?

              mrjjM 1 Reply Last reply
              0
              • thompsonxT thompsonx

                Ok, I understand. So, possibly I can keep somewhere a .pri file with compiler flags etc. and include it to the final .pro file created by qmake. True?

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @thompsonx
                Yes i imagine its possible to have a pri file to setup options and the
                actual files comes from other autogenerated .pri file.

                1 Reply Last reply
                2

                • Login

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