Results 1 to 8 of 8

Thread: Preventing UI_HEADERS_DIR from being added to include path

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Preventing UI_HEADERS_DIR from being added to include path

    Sorry for asking stupid questions, but I don't understand your problem.
    Are you trying to build separate targets? Why do you want to copy headers?

    Edit: well, I do understand what your problem is, but not why.

  2. #2
    Join Date
    Aug 2010
    Posts
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Preventing UI_HEADERS_DIR from being added to include path

    As i said, i have two types of libraries, core and gui. Let's say core library (libtbs) has a signal class resides in "signal.h" and "signal.cpp" both are in "source/libtbs" directory. To use signal class from within signal.cpp or any other file within core library i'm including it like #include "signal.h"

    That's ok. But when i need to use signal class from one of the unit tests or from a gui library, #include "signal.h" will not work. Since they are not in the same directory. Adding "source/libtbs" to include path (-I../libtbs) will not work either as "signal.h" from libtbs and "signal.h" of POSIX will be included in place of each other... So, the headers of libtbs must be copied to "builddir/include/tbs" and "builddir/include" must be added to include path then users of core library can include and use "signal.h" as #include <tbs/signal.h>

    Setting UI_HEADERS_DIR to builddir/include/tbs also enables -I builddir/include/tbs causing "signal.h" of core library to be included in place of POSIX one.

  3. #3
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Preventing UI_HEADERS_DIR from being added to include path

    Wouldn't it be easier to just rename your signal.h to tbs_signal.h ? Then you have no collisions to worry about and can just use the paths as normal without copying header files around.

  4. #4
    Join Date
    Aug 2010
    Posts
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Preventing UI_HEADERS_DIR from being added to include path

    It is. However this will move signal.h from it's own _namespace_ to global one. ( #include <tbs/signal.h> | #include <tbs_signal.h> ) breaking source consistency with previous versions etc... Isn't it correct way to shape the build system for project instead of shaping the project for build system?

  5. #5
    Join Date
    Aug 2010
    Posts
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Preventing UI_HEADERS_DIR from being added to include path

    I've managed to solve the problem by overriding uic.

    The key point is disabling the uic by adding "CONFIG -= uic" then using a custom compiler. I'm posting both full configuration file and another that uses it.

    pri file.

    Qt Code:
    1. # Public domain.
    2. # Turns off warnings about strict aliasing
    3. QMAKE_CXXFLAGS += -Wstrict-aliasing=0 -Wno-unused-parameter
    4. CONFIG += no_include_pwd silent
    5. CONFIG -= uic
    6.  
    7. # ----------------------------------------------------------------------------
    8. # Header copier
    9. header_copy.input = HEADERS
    10. header_copy.CONFIG += no_link target_predeps
    11. header_copy.variable_out = GENERATED_FILES
    12.  
    13. # ----------------------------------------------------------------------------
    14. # UI compiler
    15. tbsuic.input = FORMS
    16. tbsuic.variable_out = GENERATED_FILES
    17. tbsuic.CONFIG += no_link target_predeps
    18.  
    19. # ----------------------------------------------------------------------------
    20. defineTest(configuration) {
    21. target_name = $$1
    22. target_type = $$2
    23. output_directory = $$3
    24.  
    25. TARGET = $$target_name
    26. INCLUDEPATH = $$output_directory/include
    27. LIBS += -L$$output_directory/lib
    28. UI_DIR = $$output_directory/obj/ui
    29. UI_HEADERS_DIR = $$output_directory/include/tbs
    30. QMAKE_EXTRA_COMPILERS += tbsuic header_copy
    31.  
    32. # Relative part of header _compiler_
    33. header_copy.output = $$output_directory/include/tbs/${QMAKE_FILE_BASE}.h
    34. header_copy.commands = @$$QMAKE_COPY ${QMAKE_FILE_NAME} ${QMAKE_FILE_OUT}
    35.  
    36. # Relative part of ui compiler
    37. tbsuic.output = $$output_directory/include/tbs/ui_${QMAKE_FILE_BASE}.h
    38. tbsuic.commands = @$$QMAKE_UIC ${QMAKE_FILE_NAME} -o $$output_directory/include/tbs/ui_${QMAKE_FILE_BASE}.h
    39.  
    40. contains(target_type, lib) {
    41. TEMPLATE = lib
    42. CONFIG += staticlib
    43. DESTDIR = $$output_directory/lib
    44. }
    45. else:contains(target_type, exe) {
    46. DESTDIR = $$output_directory/bin
    47. TEMPLATE = app
    48. debug {
    49. CONFIG += console
    50. }
    51. }
    52.  
    53. export(TARGET)
    54. export(TEMPLATE)
    55. export(CONFIG)
    56. export(DESTDIR)
    57. export(UI_DIR)
    58. export(UI_HEADERS_DIR)
    59. export(INCLUDEPATH)
    60. export(LIBS)
    61. export(HEADERS)
    62. export(header_copy.output)
    63. export(header_copy.commands)
    64. export(tbsuic.output)
    65. export(tbsuic.commands)
    66. export(QMAKE_EXTRA_COMPILERS)
    67. }
    To copy to clipboard, switch view to plain text mode 


    Pro file that uses configuration file
    Qt Code:
    1. include (../tbs_desktop.pri) #Inclusion
    2.  
    3. #First parameter is target's name, second is it's type, and third is source root relative
    4. #to project
    5. configuration(tbs_forms, lib, ..)
    6.  
    7. SOURCES += \
    8. point_list_model.cpp \
    9. tabular_data_editor.cpp \
    10. route_editor.cpp \
    11. .....
    12.  
    13. HEADERS += \
    14. vertex.h \
    15. tabular_data_editor.h \
    16. route_editor.h \
    17. point_list_model.h \
    18. ...
    19.  
    20. FORMS += \
    21. route_editor.ui \
    22. line_property_editor.ui \
    23. .....
    To copy to clipboard, switch view to plain text mode 


    "CONFIG -= uic" is suggested at irc.freenode.net#qt by someone which his/her nick name is
    eluding my memory at the moment.

Similar Threads

  1. Replies: 8
    Last Post: 17th October 2009, 08:10
  2. Include path question
    By MarkoSan in forum Qt Programming
    Replies: 3
    Last Post: 28th September 2009, 13:21
  3. Include path confusion in Qt with Eclipse
    By PUK_999 in forum Installation and Deployment
    Replies: 0
    Last Post: 20th August 2009, 20:56
  4. g++ include path
    By LMZ in forum Newbie
    Replies: 2
    Last Post: 8th May 2007, 13:45
  5. Set include file path in KDevelop
    By zlatko in forum KDE Forum
    Replies: 2
    Last Post: 16th January 2006, 11:12

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
  •  
Qt is a trademark of The Qt Company.