Custom Designer Plugin with CMake ... builds but fails to load
-
I'm trying to build the example custom plugin using cmake. It builds just fine but Designer fails to load it with the following error:
@
"Cannot load library /usr/lib/qt/plugins/designer/libcustomwidgetplugin.so: (/usr/lib/qt/plugins/designer/libcustomwidgetplugin.so: undefined symbol: _ZTV17AnalogClockPlugin)"
@I have made no changes to any source files, and I confirmed that the plugin works when built with QtCreator. Can someone help me figure out what I'm missing to make it work with cmake?
Here's my CMakeLists.txt. It's got several redundant definitions in there right now from trying to copy what I saw in the Creator generated Makefile.
@
Standard setup cmake_minimum_required (VERSION 2.6)
cmake_minimum_required (VERSION 2.6)
project (customwidgetplugin CXX C)
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR})FIND_PACKAGE(Qt4 REQUIRED)
set (QT_USE_QTDESIGNER TRUE)
set (QT_USE_QTGUI TRUE)
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})
ADD_DEFINITIONS(-DQT_PLUGIN)
ADD_DEFINITIONS(-DQT_NO_DEBUG)
ADD_DEFINITIONS(-DQT_SHARED)
ADD_DEFINITIONS(-DQDESIGNER_EXPORT_WIDGETS)
ADD_DEFINITIONS(-DQT_SCRIPT_LIB)
ADD_DEFINITIONS(-DQT_XML_LIB)
ADD_DEFINITIONS(-DQT_GUI_LIB)
ADD_DEFINITIONS(-DQT_CORE_LIB)Includes
set (includeDirs ${includeDirs}
${customwidgetplugin_SOURCE_DIR/src}
)
include_directories (${customwidgetplugin_SOURCE_DIR} ${includeDirs})Source files
set (SRC ${SRC}
src/analogclock.cpp
src/customwidgetplugin.cpp
)Headers
set (H ${H}
src/analogclock.h
src/customwidgetplugin.cpp
)set (FORMS ${FORMS}
)set (LIBS ${LIBS}
${QT_LIBRARIES}
-L/usr/lib -lQtScript -lQtXml -lQtGui -lQtCore -lQtDesigner -lpthread
)set (RES ${RES})
Create QT intermediates
QT4_WRAP_CPP(H_MOC ${H})
QT4_WRAP_UI(FORM_HEADERS ${FORMS})QT4_ADD_RESOURCES(RES_RCC ${RES})
Executable
add_library (customwidgetplugin SHARED ${SRC} ${H} ${H_MOC} ${FORM_HEADERS} ${RES_RCC})
target_link_libraries (customwidgetplugin ${LIBS} ${QT_QTCORE_LIBRARIES} ${QT_QTGUI_LIBRARIES})
install (TARGETS customwidgetplugin DESTINATION ${customwidgetplugin_BINARY_DIR} )
@[EDIT: code formatting, please wrap in @-tags, not code; Volker]