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. Precompiled header support in MOC
Forum Updated to NodeBB v4.3 + New Features

Precompiled header support in MOC

Scheduled Pinned Locked Moved Qt Creator and other tools
15 Posts 8 Posters 15.2k 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.
  • L Offline
    L Offline
    loladiro
    wrote on last edited by
    #4

    AFAIK, this is already implemented using:
    @
    -f[<file>] force #include, optional file name\n"
    @

    EDIT: never mind, looks like that remove the normal include files.

    1 Reply Last reply
    0
    • L Offline
      L Offline
      loladiro
      wrote on last edited by
      #5

      I've had a look at it and it's actually really easy to implement. I can open a merge request with the changes (won't get to it until Sunday though).

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        ZapB
        wrote on last edited by
        #6

        I've not looked in detail but does it not work if you just use the PRECOMPILED_HEADER variable in your .pro file as described "here":http://doc.qt.nokia.com/4.7-snapshot/qmake-precompiledheaders.html?

        Nokia Certified Qt Specialist
        Interested in hearing about Qt related work

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jds21
          wrote on last edited by
          #7

          Thanks for the replies. I created a bug report under the category "suggestion" : https://bugreports.qt.nokia.com/browse/QTBUG-20785 .

          I have found the /FI compile option for the c compiler which I think I can use instead. ( http://msdn.microsoft.com/en-us/library/8c5ztk84(v=VS.100).aspx ).

          I have been using cmake rather than qmake so far, so the PRECOMPILED_HEADER variable was not an option.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            steno
            wrote on last edited by
            #8

            If using vs2010, the pre compiled headers switch is pretty much obsolete imo. I find the /MP much more usefull in compiling huge projects, which is incompatible with the /Yu switch.

            1 Reply Last reply
            0
            • L Offline
              L Offline
              loladiro
              wrote on last edited by
              #9

              I have created a "merge request":https://qt.gitorious.org/qt/qtbase/merge_requests/41 for this feature

              1 Reply Last reply
              0
              • J Offline
                J Offline
                jds21
                wrote on last edited by
                #10

                steno : To me the pch is not obsolete. I think it depends greatly on the project type, and it is important to benchmark. I use /MP and /Yu together - I think it is only the pch generation (/Yc) that is not compatible with /MP. The combination gives faster compile times on my projects than either on its own, the pch giving 50% reduction in time and the MP another 20%.

                I prefer not to use /FI as it implicitly adds an include you cannot see in the source code, which can have unexpected consequences.

                loladiro : thanks for the merge request.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  steno
                  wrote on last edited by
                  #11

                  So what do you do, have another propject create the pre-compiled header and just use it with another project using the /MP switch?

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    jds21
                    wrote on last edited by
                    #12

                    I use /MP for the whole project, it seems that /Yc overrides it for the one file that generates the pch. I'm actually using a cmake macro, which also sets the dependency of the pch-users on the pch binary. VS may do this automatically if you manually setup the project, I'm not sure.

                    1 Reply Last reply
                    0
                    • _ Offline
                      _ Offline
                      _nob
                      wrote on last edited by
                      #13

                      I actually hacked the Cmake-Script to include StdAfx.h for me. First test seems to work.

                      @

                      PATCHED QT4_WRAP_CPP for use with StdAfx

                      Original source: Qt4Macros.cmake

                      MACRO (PCH_QT4_WRAP_CPP outfiles )

                      get include dirs

                      QT4_GET_MOC_FLAGS(moc_flags)
                      QT4_EXTRACT_OPTIONS(moc_files moc_options ${ARGN})

                      FOREACH (it ${moc_files})
                      GET_FILENAME_COMPONENT(it ${it} ABSOLUTE)
                      QT4_MAKE_OUTPUT_FILE(${it} moc_ cxx outfile)
                      set (moc_flags_append "-fStdAfx.h" "-f${it}") # StdAfx hack.

                      message (STATUS "Moc Flags append ${moc_flags_append}")

                      QT4_CREATE_MOC_COMMAND(${it} ${outfile} "${moc_flags};${moc_flags_append}" "${moc_options}")
                      SET(${outfiles} ${${outfiles}} ${outfile})
                      ENDFOREACH(it)
                      ENDMACRO (PCH_QT4_WRAP_CPP)
                      @

                      1 Reply Last reply
                      0
                      • L Offline
                        L Offline
                        loladiro
                        wrote on last edited by
                        #14

                        Starting with Qt5, the moc will now support the -b<file> option to add optional includes.

                        1 Reply Last reply
                        1
                        • J Offline
                          J Offline
                          joonhwan
                          wrote on last edited by
                          #15

                          great.

                          joonhwan at gmail dot com

                          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