Hello,
I am switching my .pro project to CMake.
It's a Qt 4 custom plugin.
For now it doesn't build, it complains here: "undefined interface" where I do Q_INTERFACES...
#include <QObject>
#include "XAppletPlugin.h"
#include "XApplet.h"
namespace tutorial1 {
/**
* @brief AppletTutorial1 plugin class
*/
class APPLETTUTORIAL1SHARED_EXPORT AppletTutorial1
: public QObject,
public XAppletPlugin
{
// Q_OBJECT macro should appear in any class derived from QObject
Q_OBJECT
// Q_INTERFACES should appear in any class derived from a given interface
Q_INTERFACES(XAppletPlugin)
#include <QObject>
#include "XAppletPlugin.h"
#include "XApplet.h"
namespace tutorial1 {
/**
* @brief AppletTutorial1 plugin class
*/
class APPLETTUTORIAL1SHARED_EXPORT AppletTutorial1 : public QObject, public XAppletPlugin
{
// Q_OBJECT macro should appear in any class derived from QObject
Q_OBJECT
// Q_INTERFACES should appear in any class derived from a given interface
Q_INTERFACES(XAppletPlugin)
To copy to clipboard, switch view to plain text mode
"XAppletPlugin.h" is correctly found and include isn't in error, only "Q_INTERFACES" line If I hover with the mouse on include lines at top I see the full path of file as tooltip and it's OK: "C:\myExternalLib\relWithDebInfo\include\conta iner-data\XAppletPlugin.h"
So here is my CMakeLists:
cmake_minimum_required(VERSION 2.8.8)
project(applettutorial1)
FIND_PACKAGE(Qt4 REQUIRED)
# application headers files
SET(applettutorial1_HEADERS
"include/applettutorial1.h"
"include/applet-tutorial1_global.h"
"include/applettutorial1imp.h"
)
# application files: source and headers again
# so that they show up in project files tree
SET(applettutorial1_SOURCES
${applettutorial1_HEADERS}
src/applettutorial1.cpp
src/applettutorial1imp.cpp
tutorial1.xml
)
MESSAGE(STATUS "Source files: " ${applettutorial1_SOURCES} )
# Required
QT4_WRAP_CPP(applettutorial1_HEADERS_MOC ${applettutorial1_HEADERS})
# SET(applettutorial1_RESOURCES images.qrc)
#QT4_ADD_RESOURCES(applettutorial1_RESOURCES_RCC ${applettutorial1_RESOURCES})
if (QT4_FOUND)
# SET(QT_USE_QTDESIGNER ON)
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})
else()
message(FATAL_ERROR "No Qt4 found")
endif()
IF(CMAKE_BUILD_TYPE MATCHES DEBUG)
SET(EXTERNALLIB_BASE "$ENV{EXTERNALLIB}/debug")
ELSE()
SET(EXTERNALLIB_BASE "$ENV{EXTERNALLIB}/relWithDebInfo")
ENDIF()
MESSAGE(STATUS "EXTERNALLIB base dir: " ${EXTERNALLIB_BASE} )
# EXTERNALLIB version
SET(VERSION "0.24.0")
# EXTERNALLIB includes
include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}/include"
"${EXTERNALLIB_BASE}/include"
"${EXTERNALLIB_BASE}/include/container-data"
)
link_directories("${EXTERNALLIB_BASE}/lib")
# executable then list of files
add_executable(
applettutorial1
${applettutorial1_SOURCES}
${applettutorial1_HEADERS_MOC}
# ${applettutorial1_RESOURCES_RCC}
)
target_link_libraries(
applettutorial1
${QT_LIBRARIES}
container-data
)
cmake_minimum_required(VERSION 2.8.8)
project(applettutorial1)
FIND_PACKAGE(Qt4 REQUIRED)
# application headers files
SET(applettutorial1_HEADERS
"include/applettutorial1.h"
"include/applet-tutorial1_global.h"
"include/applettutorial1imp.h"
)
# application files: source and headers again
# so that they show up in project files tree
SET(applettutorial1_SOURCES
${applettutorial1_HEADERS}
src/applettutorial1.cpp
src/applettutorial1imp.cpp
tutorial1.xml
)
MESSAGE(STATUS "Source files: " ${applettutorial1_SOURCES} )
# Required
QT4_WRAP_CPP(applettutorial1_HEADERS_MOC ${applettutorial1_HEADERS})
# SET(applettutorial1_RESOURCES images.qrc)
#QT4_ADD_RESOURCES(applettutorial1_RESOURCES_RCC ${applettutorial1_RESOURCES})
if (QT4_FOUND)
# SET(QT_USE_QTDESIGNER ON)
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})
else()
message(FATAL_ERROR "No Qt4 found")
endif()
IF(CMAKE_BUILD_TYPE MATCHES DEBUG)
SET(EXTERNALLIB_BASE "$ENV{EXTERNALLIB}/debug")
ELSE()
SET(EXTERNALLIB_BASE "$ENV{EXTERNALLIB}/relWithDebInfo")
ENDIF()
MESSAGE(STATUS "EXTERNALLIB base dir: " ${EXTERNALLIB_BASE} )
# EXTERNALLIB version
SET(VERSION "0.24.0")
# EXTERNALLIB includes
include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}/include"
"${EXTERNALLIB_BASE}/include"
"${EXTERNALLIB_BASE}/include/container-data"
)
link_directories("${EXTERNALLIB_BASE}/lib")
# executable then list of files
add_executable(
applettutorial1
${applettutorial1_SOURCES}
${applettutorial1_HEADERS_MOC}
# ${applettutorial1_RESOURCES_RCC}
)
target_link_libraries(
applettutorial1
${QT_LIBRARIES}
container-data
)
To copy to clipboard, switch view to plain text mode
In my code there is no "Q_EXPORT_PLUGIN2" because this is managed by the external lib I use, which acts as a plugin host.
Thanks,
Added after 1 9 minutes:
I've changed "add_executable" to the following but I didn't solve the error for now.
# name, type then list of files
add_library(
applettutorial1 SHARED
${applettutorial1_SOURCES}
${applettutorial1_HEADERS_MOC}
# ${applettutorial1_RESOURCES_RCC}
)
# name, type then list of files
add_library(
applettutorial1 SHARED
${applettutorial1_SOURCES}
${applettutorial1_HEADERS_MOC}
# ${applettutorial1_RESOURCES_RCC}
)
To copy to clipboard, switch view to plain text mode
Bookmarks