Hi,

I have a Qt4 program that I'm working on and ran into an issue yesterday
with the automoc cpp files.  I had added a new slot and connected a
comboxbox currentIndexChanged signal to it but when I ran the program I
could see messages on stdout complaining that my slot didn't exist.  I
tracked the problem down to the fact that the moc_ctrlBasic.cpp file was
not being regenerated.  If I look in my cmake build directory I currently
have 8 moc cpp files:

./moc_ctrlBasic.cpp
./moc_ctrlmenu.cpp
./moc_infoWin.cpp
./moc_qglDisplay.cpp
./moc_qglMultiWindow.cpp
./moc_qglWindow.cpp
./moc_videoGeneric.cpp
./yuv_player_automoc.cpp

I am using CMake 2.8.10.1 with Visual Studio 11 and when I do a clean
solution these 8 moc cpp files are not deleted.  In order to get my new
slot recognised I had to manually delete these moc files and then after a
rebuild everything worked as expected.  None of my cpp files #include
"moc_xxx.cpp" but that isn't necessary from my reading of the AUTOMOC
property (i.e. ctrlBasic.cpp only does a #include "ctrlBasic.h").  What am
I doing wrong in my CMakeLists.txt file which looks like this:

cmake_minimum_required(VERSION 2.8.9 FATAL_ERROR)

project(yuv_player)

find_package(OpenGL REQUIRED)

find_package(Qt4 REQUIRED)
set(QT_USE_QTMAIN true)
set(QT_USE_QTOPENGL true)
include(${QT_USE_FILE})

set(CMAKE_AUTOMOC true)

if (MSVC)
    add_definitions(/MP)        # build in parallel
    # disable the security warnings for fopen, scanf etc.
    add_definitions(/D"_CRT_SECURE_NO_WARNINGS" /D"_SCL_SECURE_NO_WARNINGS")
endif()

set(sources
    main.cpp
    yuv_tools.cpp
    ctrlMenu/ctrlBasic.cpp
    ctrlMenu/ctrlmenu.cpp
    multiWindow/qglMultiWindow.cpp
    multiWindow/qglDisplay.cpp
    multiWindow/qglWindow.cpp
    utils/readYuv.cpp
    utils/readOut2.cpp
    video_tools.cpp
    ctrlMenu/infoWin.cpp
    videoGeneric.cpp
)

set(headers
    yuv_tools.h
    ctrlMenu/ctrlBasic.h
    ctrlMenu/ctrlmenu.h
    ctrlMenu/infoWin.h
    multiWindow/qglDisplay.h
    multiWindow/qglMultiWindow.h
    multiWindow/qglWindow.h
    utils/readYuv.h
    utils/readOut2.h
    video_tools.h
    ctrlMenu/infoWin.h
    videoGeneric.h
    defs.h
)

include_directories(
    .
    multiWindow
    ctrlMenu
)

add_executable(yuv_player WIN32 ${sources} ${headers})

target_link_libraries(yuv_player ${QT_LIBRARIES} ${OPENGL_LIBRARIES})

--
Glenn
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to