Results 1 to 4 of 4

Thread: Building documentation with qmake

  1. #1
    Join Date
    Sep 2007
    Posts
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Building documentation with qmake

    I'm having problems trying to use qmake to build my documentation. I have a directory where my documentation is as latex files. I want to use qmake (since I use it everywhere else in the project) to build pdfs out of the .tex files and also provide an install target to install them to a specified directory.

    I've tried doing it using a custom compiler:

    Qt Code:
    1. # Dummy, just to avoid qmake error because we're not compiling any application
    2. TEMPLATE = subdirs
    3.  
    4. TEX = help.tex
    5.  
    6. # Compiler for pdfs
    7. doc_builder.name = tex2pdf
    8. doc_builder.input = $$TEX
    9. doc_builder.output = ${QMAKE_FILE_IN_BASE}.pdf
    10. doc_builder.commands = pdflatex ${QMAKE_FILE_IN}
    11. doc_builder.variable_out = PDFS
    12. QMAKE_EXTRA_COMPILERS += doc_builder
    13.  
    14. # Install documentation
    15. docs.path = $$PREFIX/share/doc/MyApp
    16. docs.files = changelog.txt $$PDFS
    17.  
    18. INSTALLS += docs
    To copy to clipboard, switch view to plain text mode 

    This doesn't work, because the $$PDFS is expanded when qmake is run and it is naturally empty at the time because the custom compiler hasn't been run. How can I get around this? Is there any way of telling that the install target depends on something? Or is there another approach to achieve the same results I'm after?

  2. #2
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Building documentation with qmake

    I think the problem lies here :
    Qt Code:
    1. doc_builder.input = $$TEX
    To copy to clipboard, switch view to plain text mode 

    should be :
    Qt Code:
    1. doc_builder.input = TEX
    To copy to clipboard, switch view to plain text mode 
    Current Qt projects : QCodeEdit, RotiDeCode

  3. #3
    Join Date
    Sep 2007
    Posts
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Building documentation with qmake

    Ah, that was indeed one error. There was another reason as well. A feature of qmake seems to be that custom compilers are not executed if the template is set to 'subdirs'. After I set it to lib it works fine. I just get a dummy empty library in the process but oh well...

    Another annoying feature I discovered was that by default the files in installation sets are checked that they exists when qmake is run. This effectively prevents you from writing any installers for any generated files (like the .pdfs in my case). However after reading through the qmake source code, there is a nice undocumented option to disable that check.

    Anyway here's my project file for reference if someone else runs into these problems:

    Qt Code:
    1. # Dummy, just to get custom compilers to work in qmake
    2. TEMPLATE = lib
    3. TARGET = Dummy
    4.  
    5. # .tex files to build
    6. TEX += help.tex
    7.  
    8. # Compiler for pdfs
    9. doc_builder.name = tex2pdf
    10. doc_builder.input = TEX
    11. doc_builder.output = ${QMAKE_FILE_BASE}.pdf
    12. doc_builder.commands = pdflatex ${QMAKE_FILE_BASE}
    13.  
    14. # This makes the custom compiler run before anything else
    15. doc_builder.CONFIG += target_predeps
    16.  
    17. doc_builder.variable_out = documents.files
    18. doc_builder.clean = ${QMAKE_FILE_BASE}.pdf \
    19. ${QMAKE_FILE_BASE}.aux \
    20. ${QMAKE_FILE_BASE}.toc \
    21. ${QMAKE_FILE_BASE}.log
    22. QMAKE_EXTRA_COMPILERS += doc_builder
    23.  
    24. # Install documentation
    25. documents.path = $$PREFIX/share/doc/
    26. # If you don't specify this, all files must exist when you run qmake or else they will
    27. # just silently be ignored
    28. documents.CONFIG += no_check_exist
    29.  
    30. INSTALLS += documents
    To copy to clipboard, switch view to plain text mode 

    I still have to check if there's a way to get rid of the dummy library, but it will do for now.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Building documentation with qmake

    According to me you have two choices. One is to make the docs a separate "subdir" target. It doesn't even have to be in a separate directory, but it should reside as a separate .pro file in one of other directories and be pointed to as part of SUBDIRS variable of the main project file, i.e. SUBDIRS = sub1 sub2 docs.pro

    Another option is to make your docs a custom target in one of already existing project files - the one with subdirs template should be suitable as well. It should look more or less like this:

    QMAKE_EXTRA_TARGETS += docs
    docs.commands = pdflatex ${QMAKE_FILE_BASE}
    ... your other directives go here ...

    Then you can call "make docs" and they should be built. You can probably add "docs" as a post dependency for the project to have them built automatically, but that's just a guess.

Similar Threads

  1. Replies: 0
    Last Post: 29th May 2007, 06:28
  2. Compiling with Qmake/Make
    By VireX in forum Newbie
    Replies: 25
    Last Post: 22nd February 2007, 05:57
  3. Qt Cryptographic Architecture
    By vermarajeev in forum Qt Programming
    Replies: 6
    Last Post: 9th February 2007, 13:15
  4. Win32 qmake: building a static library
    By Amanda in forum Qt Programming
    Replies: 5
    Last Post: 8th November 2006, 19:32
  5. linking user space and kernel space programs with qmake
    By zielchri in forum Qt Programming
    Replies: 9
    Last Post: 8th March 2006, 23:11

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.