Results 1 to 2 of 2

Thread: cmake and include "xxx.moc"

  1. #1
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Thanks
    24
    Thanked 17 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default cmake and include "xxx.moc"

    Hi,

    I have a program where I created an database driver (embdriver) based on the QMYSQLDriver provided by QT. The file has the following include

    Qt Code:
    1. #include "embdriver.moc"
    To copy to clipboard, switch view to plain text mode 

    Building my application with qmake does not generate a problem but using cmake I get the error:

    fatal error: embdriver.moc: No such file or directory

    In the CMakeList.txt I have: qt4_automoc(${GOBLET_createdb_SOURCES}) and cmake creates embdriver.moc but I don't know the why I get the error!

    This is the full CMakeList.txt
    Qt Code:
    1. SET(GOBLET_createdb_SOURCES main.cpp ../common/embdriver.cpp ../common/mydbconn.cpp)
    2. SET(GOBLET_createdb_HEADERS ../common/embdriver.h ../common/mydbconn.h)
    3. QT4_WRAP_CPP(GOBLET_createdb_HEADERS_MOC ${GOBLET_createdb_HEADERS})
    4. SET(GOBLET_createdb_RESOURCES mysqlFiles.qrc)
    5.  
    6. qt4_automoc(${GOBLET_createdb_SOURCES})
    7.  
    8. QT4_ADD_RESOURCES(GOBLET_createdb_RESOURCES_RCC ${GOBLET_createdb_RESOURCES})
    9.  
    10. ADD_EXECUTABLE(goblet-createdb ${GOBLET_createdb_SOURCES} ${GOBLET_createdb_HEADERS} ${GOBLET_createdb_HEADERS_MOC} ${GOBLET_createdb_RESOURCES_RCC})
    11.  
    12. INCLUDE_DIRECTORIES(../common . ..)
    13.  
    14. IF(NOT WIN32)
    15. TARGET_LINK_LIBRARIES(goblet-createdb ${QT_LIBRARIES} ${MYSQL_LIBRARY} ${AIO_LIBRARY} ${CRYPT_LIBRARY})
    16. ELSE (NOT WIN32)
    17. TARGET_LINK_LIBRARIES(goblet-createdb ${QT_LIBRARIES} ${MYSQL_LIBRARY})
    18. ENDIF (NOT WIN32)
    19.  
    20. INSTALL_PROGRAMS(/bin FILES goblet-createdb)
    To copy to clipboard, switch view to plain text mode 

    I created a build directory for my application:

    my_application/build

    then I run
    Qt Code:
    1. cd build
    2. cmake ..
    3. make
    To copy to clipboard, switch view to plain text mode 

    and I see that embdriver.moc was created in my_application/build/ my_application

    So why it cannot find it?

    Many thanks for your help

    Carlos.

  2. #2
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Thanks
    24
    Thanked 17 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: cmake and include "xxx.moc"

    So, instead of fighting with cmake and that .moc include..... I just modified the file to remove the include... Now all works fine just with QT4_WRAP_CPP().

    Carlos.

Similar Threads

  1. Replies: 1
    Last Post: 28th April 2012, 03:53
  2. Replies: 0
    Last Post: 20th November 2011, 12:41
  3. Replies: 1
    Last Post: 5th February 2011, 21:14
  4. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05
  5. Best way to "include" the images of an application
    By SkripT in forum Qt Programming
    Replies: 4
    Last Post: 18th April 2006, 18:32

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.