Announcement

Collapse
No announcement yet.

Using CMake with Qt Projects

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Using CMake with Qt Projects

    http://developer.qt.nokia.com/quarte...ld_qt_projects

    Qt comes with the QMake tool for handling cross platform building issues. However, there are other build systems available such as autotools, SCons and CMake. These tools meet different criterias, for example external dependencies.

    When the KDE project shifted from Qt 3 to Qt 4 the project changed build tool from autotools to CMake. This has given CMake a special position in the Qt world &emdash; both from the number of users point and from a feature support and quality point. Seen from a workflow point of view, Qt Creator supports CMake since version 1.1 (1.3 if you want to use a Microsoft toolchain).
    .....
    The article goes on to explain how to use CMake to build Qt projects.
    "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
    – John F. Kennedy, February 26, 1962.

    #2
    Re: Using CMake with Qt Projects

    thanks GG, great read. im not sure that my project would really benifet from Cmake for building. Maybe my next project will, so thanks again!
    Mark Your Solved Issues [SOLVED]
    (top of thread: thread tools)

    Comment


      #3
      Re: Using CMake with Qt Projects

      I bookmarked that one. I have been experimenting with cmake on really small qt-less project and my first impression is very good. I just noticed I already had a bookmark for the same subject different site. This might be useful also.
      http://www.qtcentre.org/wiki/index.p...pps_with_CMake
      FKA: tanderson

      Comment


        #4
        Re: Using CMake with Qt Projects

        QtCentre was my favorite site before I retired from programming. For the previous 5 years I had been using Qt to create inhouse apps, and second to the Troll direct (paid) email support it was the best site on the web.
        "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
        – John F. Kennedy, February 26, 1962.

        Comment


          #5
          Re: Using CMake with Qt Projects

          IDK, I see it like a more complicated thing. Maybe it's just a matter of time to get used to cmake.

          I wonder if sithlord's app is opensource code or not...
          Multibooting: Kubuntu Noble 24.04
          Before: Jammy 22.04, Focal 20.04, Precise 12.04 Xenial 16.04 and Bionic 18.04
          Win XP, 7 & 10 sadly
          Using Linux since June, 2008

          Comment


            #6
            Re: Using CMake with Qt Projects

            Originally posted by kyonides
            I see it like a more complicated thing.
            more complicated than what?
            FKA: tanderson

            Comment


              #7
              Re: Using CMake with Qt Projects

              Originally posted by kyonides
              I wonder if sithlord's app is opensource code or not...
              Of course it is. GPLv3... maybe one day i will learn to make deb files and host a ppa for it for ubuntu/debian (then again its only a save game editor for FF7).. the projects has svn and it is hosted on sourceforge.there is a link lower left for svn.i know i need to improve the web page.
              Mark Your Solved Issues [SOLVED]
              (top of thread: thread tools)

              Comment


                #8
                Re: Using CMake with Qt Projects

                Originally posted by kyonides
                IDK, I see it like a more complicated thing. Maybe it's just a matter of time to get used to cmake.
                ....
                I used qmake for my work but I have no doubt that both tools can get equally complicated. As I used to tell my Physics students: "Everything is easy once you know how!"

                "man cmake" will show you over 13,000 lines of documentation about cmake.
                Qmake for Qt 4.6 has a manual here.

                For a small project, where *.h, *.cpp and *.ui files are all in the same directory qmake will generate a file that looks like this:
                ###############################################
                # Automatically generated by qmake (2.00a) Tue Nov 1 08:49:22 2005
                ###############################################
                TEMPLATE = app
                DEPENDPATH += .
                INCLUDEPATH += .
                CONFIG += qt release debug
                # Input
                HEADERS += homestead.h
                FORMS += homestead.ui
                SOURCES += main.cpp homestead.cpp
                That file was generated after I had created main.cpp, homestead.h, homestead.cpp and homestead.ui in skeletal form. After those four files were created I entered the directory in a Konsole and issued
                qmake -project
                which created "hap2008.pro", as shown above. Initially it was hap2005.pro but each year required creating a new directory for the new year and copying everything over to it. The name of the initial directory was "hap2005", which is where qmake gets the prefix to the *.pro name. The fourth year, hap2008, was created by copying the contents of hap2007 into a new directory titled hap2008. Because the State legislature could and did change the homestead laws each year, each year's development remained independent of previous or subsequent years.)

                As I continued to add features and complete the project design the hapxxxx.pro file eventually became:
                ###############################################
                # Automatically generated by qmake (2.00a) Tue Nov 1 08:49:22 2005
                ###############################################
                TEMPLATE = app
                DEPENDPATH += .
                INCLUDEPATH += .
                CONFIG += qt release debug
                QT += sql
                # Input
                HEADERS += dlglogin.h homestead.h wholenamedlg.h historydialog.h batchrptdlg.h
                FORMS += homestead.ui dlglogin.ui wholenamedlg.ui historydialog.ui batchrptdlg.ui
                SOURCES += main.cpp homestead.cpp wholenamedlg.cpp historydialog.cpp batchrptdlg.cpp

                After "qmake -project" was run, to create "hap2008.pro" it was run again as
                qmake hap2008.pro
                in order to create the Makefile file. Then, running "make" in the hap2008 sub-directory compiled the project and created the binary executable. Since I had the "release" and "debug" settings in the pro file "Makefile.release" and "Makefile.debug" were also created, and when "make" was run it would create both a debug binary and a release binary.

                As I added to the project I would have to either manually edit hapNNNN.pro and add the additional header, source and gui files, or delete hapNNNN.pro and re-run "qmake -project" followed by "qmake hapNNNN.pro" in order to generate a new Makefiles. Obviously, I edited the pro file.

                In more complicated projects headers, source and gui files can be kept in separate sub-directories. Or, if the project has quasi independent sub-projects they can be kept in different sub-directories. Qmake traverses the directory tree to search for all the kinds of files it knows about.

                With QtCreator all this action is available as menu options. You can set build options, run qmake, etc...


                When cmake is run inside a project directory for the first time it creates a CMakeList.txt file which contains templates which the programmer files in with information relevant to his project. Programmers skilled with using cmake just directly write the CMakeList.txt files themselves.

                Both tools have extensive collections of variable and function references, and environmental variables and configuration settings.

                They are both tools, each with advantages and disadvantages. I use qmake merely because when I first started using Qt3 that was the tool recommended to create the pro and Makefiles. Having learned how to use it I stuck with it. IF I had begun homestead development in KDevelop3 I would probably have used cmake. In that regard, it was fortunate that Qt4 came out when it did because it converted to classic C++ development by reducing Qt-Designer from the be-all, do-all dev tool for Qt3 to just a gui designer in Qt4. That change made development with Qt MUCH easier and quicker.




                "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
                – John F. Kennedy, February 26, 1962.

                Comment

                Working...
                X