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] Using wildcards for SOURCES when build dir is different from source dir

[SOLVED] Using wildcards for SOURCES when build dir is different from source dir

Scheduled Pinned Locked Moved General and Desktop
9 Posts 4 Posters 16.1k 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.
  • L Offline
    L Offline
    lyuts
    wrote on last edited by
    #1

    Hi guys,

    I'm stuck with one problem when building my project and still can't find the reason for such behaviour. Consider the following project layout.

    @Project
    |_Project.pro
    |_Module1
    |_Module1.pro
    |_Part1
    | |_f.cpp
    | |_f.h
    |_Part2
    |_g.cpp
    |_g.h@

    Here is my Project.pro:
    @TEMPLATE = subdirs

    SUBDIRS = Module1@

    Here is my Module1.pro:
    @TEMPLATE = lib

    HEADERS = $$PWD/Part1/.h
    $$PWD/Part2/
    .h

    SOURCES = $$PWD/Part1/.cpp
    $$PWD/Part2/
    .cpp@

    Now i create build directory, because I want it to be separate from source directory, and run qmake:

    $ cd <Project/Path>
    $ mkdir build
    $ cd build
    $ qmake ../Project.pro
    $ make

    And here I get the following error:

    @make[1]: *** No rule to make target ../../../Module1/Part1/f.cpp', needed by f.o'. Stop.@

    I suppose this is because I have used wildcards for setting SOURCES and HEADERS variable. I think so, because If I don't use them and type the whole concrete paths when setting SOURCE/HEADERS my build goes ok.

    Is this how it is supposed to behave when using wildcards, or it is a bug? If that is how it should be does anybody knows the way to fix that (of course I want to use wildcards because it save time and space:) )?

    Thanks

    I'm a rebel in the S.D.G.

    1 Reply Last reply
    0
    • ? This user is from outside of this forum
      ? This user is from outside of this forum
      Guest
      wrote on last edited by
      #2

      In Module1.pro, you don't need the "$$PWD/", you can write a relative path.

      Also, qmake doesn't like to have a build directory under src, try this instead:

      @
      $ cd
      $ cd ..
      $ mkdir build
      $ cd build
      $ qmake ../src/Project.pro
      $ make
      @

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tobias.hunger
        wrote on last edited by
        #3

        I think you are having some other issue: Qmake is very picky with where it wants its build directory. Try putting the build directory parallel to the source directory, not into it.

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lyuts
          wrote on last edited by
          #4

          [quote author="Nicolas" date="1286191411"]In Module1.pro, you don't need the "$$PWD/", you can write a relative path.

          Also, qmake doesn't like to have a build directory under src, try this instead:

          @
          $ cd
          $ cd ..
          $ mkdir build
          $ cd build
          $ qmake ../src/Project.pro
          $ make
          @[/quote]

          I do have to write $$PWD. PWD is the directory where the .pro file is located (this is from qmake variable reference). The location of sources is relative to $$PWD.

          bq. Try putting the build directory parallel to the source directory, not into it.

          I tried the same with build directory outside source directory. But the result was the same. I haven't tried to use build directory that is on the same level as my source directory is. Having them on the same exact level - isn't that a wrong limitation?

          Thanks.

          UPD: I can build Qt Creator with build directory that is several levels upper than the source tree.

          I'm a rebel in the S.D.G.

          1 Reply Last reply
          0
          • ? This user is from outside of this forum
            ? This user is from outside of this forum
            Guest
            wrote on last edited by
            #5

            [quote author="lyuts" date="1286192482"] [quote author="Nicolas" date="1286191411"]In Module1.pro, you don&#39;t need the "$$PWD/", you can write a relative path.
            [/quote]

            I do have to write $$PWD. PWD is the directory where the .pro file is located (this is from qmake variable reference). The location of sources is relative to $$PWD.
            [/quote]
            I can assure you you don't need the $$PWD. Maybe you can give it a try without it.

            No other idea, sorry.

            1 Reply Last reply
            0
            • L Offline
              L Offline
              lyuts
              wrote on last edited by
              #6

              [quote author="Nicolas" date="1286192967"]
              I can assure you you don't need the $$PWD. Maybe you can give it a try without it.
              [/quote]

              This is maybe true when no wildcards are used. I put wildcards there and the no files could be located without $$PWD. When I put $$PWD the files list contains my files but the path prefixed is not correct, i.e. lead to a wrong location.

              I'm a rebel in the S.D.G.

              1 Reply Last reply
              0
              • B Offline
                B Offline
                baysmith
                wrote on last edited by
                #7

                The undocumented qmake function files(glob) might do what you want. Try this for Module1.pro:

                @
                TEMPLATE = lib

                HEADERS = $$files(Part1/.h)
                $$files(Part2/
                .h)

                SOURCES = $$files(Part1/.cpp)
                $$files(Part2/
                .cpp)
                @

                Nokia Certified Qt Specialist.

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  lyuts
                  wrote on last edited by
                  #8

                  Bradley, that's exactly what I was looking for :) Thank you so much, this solved my problem.

                  I'm a rebel in the S.D.G.

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    dfaure
                    wrote on last edited by
                    #9

                    Bradley: any plans on getting that documented? :-)

                    David Faure (david.faure@kdab.com)
                    KDE/Qt Senior Software Engineer
                    KDAB - Qt Experts - Platform-independent software solutions

                    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