Results 1 to 5 of 5

Thread: Who to force qmake to use absolute paths in generated Makefiles

  1. #1
    Join Date
    Jun 2011
    Posts
    4
    Qt products
    Qt3
    Platforms
    MacOS X

    Default Who to force qmake to use absolute paths in generated Makefiles

    I have a QT project with some sub projects like this:
    Qt Code:
    1. main/
    2. main.pro
    3. sub1/
    4. include/
    5. src/
    6. s1.cpp
    7. sub1.pro
    8. sub2/
    9. sub2.pro
    To copy to clipboard, switch view to plain text mode 
    I generate the makefiles with qmake -r from the top. qmake is then generating Makefiles for main.pro, sub1.pro and sub2.pro. Because qmake uses relative paths the paths within the Makefiles of sub1 and sub2 are relatively to the pro files. This causes clang to print relative paths when referring to source code files within error messages:
    Qt Code:
    1. src/s1.cpp:22:13: error: expected '('
    To copy to clipboard, switch view to plain text mode 
    And seen from the project directory src/s1.cpp doesn't exist. At least the path should be sub1/src/s1.cpp.
    Another solution would be to force qmake to generate absolute paths in the Makefile but I can't find a way to do that.
    Any idea?

  2. #2
    Join Date
    Jun 2011
    Posts
    4
    Qt products
    Qt3
    Platforms
    MacOS X

    Default Re: Who to force qmake to use absolute paths in generated Makefiles

    no one with an idea?

  3. #3
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: Who to force qmake to use absolute paths in generated Makefiles

    Not sure I fully understand your problem, or which project / makefile is being processed when you get this error. If you're building the sub1.pro subproject, src/s1.cpp is a correct reference, no?

    How about providing the contents of the profiles and the actual build output to start?
    I write the best type of code possible, code that I want to write, not code that someone tells me to write!

  4. #4
    Join Date
    Jun 2011
    Posts
    4
    Qt products
    Qt3
    Platforms
    MacOS X

    Default Re: Who to force qmake to use absolute paths in generated Makefiles

    qmake generates a Makefile that includes some directory changes. When it's about to compile a sub project it switches to that directory and then runs all the clang/cc commands to compile. But because this is not happening in the top project's directory, the output relates to the sub projects directory. My IDE/Editor who wants to interpret the error messages cannot find the source file because it overlooks the directory changes. So my solution would be to force qmake to use absolute path within the makefiles it generates. I thought this would be a very common problem :/

  5. #5
    Join Date
    Jul 2016
    Posts
    1

    Default Re: Who to force qmake to use absolute paths in generated Makefiles

    Im not sure if this is what you are asking for. But if you want qmake to only create absolute path you should put following line into your .pro file
    Qt Code:
    1. QMAKE_PROJECT_DEPTH = 0 # undocumented qmake flag to force absolute paths in make files
    To copy to clipboard, switch view to plain text mode 
    It basically tells qmake that the accepted depth for a relative path is zero. So there will never be any relative paths.

    You can find information about this and other undocumented features on QTs wiki page.
    https://wiki.qt.io/Undocumented_QMake

Similar Threads

  1. Qt Creator Qt Creator and big auto generated makefiles
    By yurai in forum Qt Tools
    Replies: 5
    Last Post: 12th June 2015, 11:14
  2. qt.conf - cannot use absolute paths?
    By vennsm in forum Qt Programming
    Replies: 0
    Last Post: 21st March 2012, 15:54
  3. Qt Assistant Absolute Paths in QAssistant
    By mac_loo in forum Qt Tools
    Replies: 1
    Last Post: 4th April 2011, 09:56
  4. default target in generated makefiles
    By iefremov in forum Installation and Deployment
    Replies: 1
    Last Post: 24th December 2010, 11:57
  5. Generated Makefiles clean-up
    By tora in forum Qt Programming
    Replies: 3
    Last Post: 4th June 2009, 12:45

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.