Results 1 to 4 of 4

Thread: compiling qt4 applications with cmake

  1. #1
    Join Date
    Jan 2006
    Posts
    369
    Thanks
    14
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default compiling qt4 applications with cmake

    Hi,

    I am toying with cmake. It looks interesting, and much more flexibly then QMake. I have read: http://wiki.qtcentre.org/index.php?t...pps_with_CMake and
    http://qtnode.net/wiki/Qt_with_cmake#cmake_for_Qt_4

    I have a basic CMakeLists.txt and it does not want to generate the UI files. The output I get is:
    elcuco@linux:~/src/svn/qtedit4/tools/qtsourceview/demos/demo1/build> cmake ../ && make
    -- Found Qt-Version 4.2.0-snapshot-20061002
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /home/elcuco/src/svn/qtedit4/tools/qtsourceview/demos/demo1/build
    [ 20%] Building CXX object CMakeFiles/demo1.dir/mainwindow1.o
    In file included from /home/elcuco/src/svn/qtedit4/tools/qtsourceview/demos/demo1/mainwindow1.cpp:12:
    /home/elcuco/src/svn/qtedit4/tools/qtsourceview/demos/demo1/mainwindow1.h:5:28: error: ui_mainwindow1.h: No such file or directory
    /home/elcuco/src/svn/qtedit4/tools/qtsourceview/demos/demo1/mainwindow1.h:11: error: ‘Ui’ has not been declared
    /home/elcuco/src/svn/qtedit4/tools/qtsourceview/demos/demo1/mainwindow1.h:11: error: invalid use of undefined type ‘class MainWindow1’
    /home/elcuco/src/svn/qtedit4/tools/qtsourceview/demos/demo1/mainwindow1.h:11: error: forward declaration of ‘class MainWindow1’
    /home/elcuco/src/svn/qtedit4/tools/qtsourceview/demos/demo1/mainwindow1.cpp: In constructor ‘MainWindow1::MainWindow1(QMainWindow*)’:
    /home/elcuco/src/svn/qtedit4/tools/qtsourceview/demos/demo1/mainwindow1.cpp:17: error: ‘setupUi’ was not declared in this scope
    /home/elcuco/src/svn/qtedit4/tools/qtsourceview/demos/demo1/mainwindow1.cpp:28: error: ‘textEdit’ was not declared in this scope
    /home/elcuco/src/svn/qtedit4/tools/qtsourceview/demos/demo1/mainwindow1.cpp:30: error: invalid use of undefined type ‘struct QStatusBar’
    /usr/local/Trolltech/qt4-rsync/include/QtGui/qmainwindow.h:38: error: forward declaration of ‘struct QStatusBar’
    /home/elcuco/src/svn/qtedit4/tools/qtsourceview/demos/demo1/mainwindow1.cpp: In member function ‘void MainWindow1::on_action_New_triggered()’:
    /home/elcuco/src/svn/qtedit4/tools/qtsourceview/demos/demo1/mainwindow1.cpp:35: error: ‘textEdit’ was not declared in this scope
    /home/elcuco/src/svn/qtedit4/tools/qtsourceview/demos/demo1/mainwindow1.cpp: In member function ‘void MainWindow1::on_action_Open_triggered()’:
    /home/elcuco/src/svn/qtedit4/tools/qtsourceview/demos/demo1/mainwindow1.cpp:57: error: ‘textEdit’ was not declared in this scope
    /home/elcuco/src/svn/qtedit4/tools/qtsourceview/demos/demo1/mainwindow1.cpp:60: error: invalid use of undefined type ‘struct QStatusBar’
    /usr/local/Trolltech/qt4-rsync/include/QtGui/qmainwindow.h:38: error: forward declaration of ‘struct QStatusBar’
    make[2]: *** [CMakeFiles/demo1.dir/mainwindow1.o] Error 1
    make[1]: *** [CMakeFiles/demo1.dir/all] Error 2
    make: *** [all] Error 2
    I am attaching here my CMakeLists.txt. Help will be appreciated.
    Attached Files Attached Files
    Last edited by jacek; 13th October 2006 at 23:37. Reason: changed [code] to [quote]

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: compiling qt4 applications with cmake

    Quote Originally Posted by elcuco View Post
    I guess you missed that part:
    # we need this to be able to include headers produced by uic in our code
    # (CMAKE_BINARY_DIR holds a path to the build directory, while INCLUDE_DIRECTORIES() works just like INCLUDEPATH from qmake)
    INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} )

  3. #3
    Join Date
    Jan 2006
    Posts
    369
    Thanks
    14
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: compiling qt4 applications with cmake

    I modified the include to this line (I am not building insource)
    Qt Code:
    1. INCLUDE_DIRECTORIES ( ${QT_INCLUDE_DIR} ${CMAKE_BINARY_DIR} ../../src )
    To copy to clipboard, switch view to plain text mode 

    Now the code compiles. Wow... This was not that trivial to understand, but thanks for pointing it out once again!

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: compiling qt4 applications with cmake

    Quote Originally Posted by elcuco View Post
    I am not building insource
    That's why you had to add ${CMAKE_BINARY_DIR} to INCLUDE_DIRECTORIES, since all generated files will are stored in that directory.

Similar Threads

  1. Qt with cmake on windows xp
    By Ashish in forum Newbie
    Replies: 1
    Last Post: 6th October 2006, 22:59
  2. CMake and pthreads
    By Matt Smith in forum General Discussion
    Replies: 5
    Last Post: 3rd September 2006, 20:42
  3. Compiling custom Qt3 Widgets Gives warning in VC++6 Compiler
    By sunil.thaha in forum Qt Programming
    Replies: 4
    Last Post: 9th June 2006, 12:44

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.