CMakeLists.txt 和 Qt 的 *.pri 文件
我正在尝试为 KDE4/Qt4 项目创建 CMakeLists.txt 文件。目前该项目中包含一个创建独立库的 *.pri 文件。我想将该库包含到我的 CMakeLists.txt 中。我不知道该怎么做...... 目前我的 *.pro 文件如下所示:
include(utils/qtpropertybrowser/src/qtpropertybrowser.pri)
QT += core gui console xml
TARGET = photoframeseditor
TEMPLATE = app
SOURCES += main.cpp\
plugin/photoframeseditor.cpp \
....
HEADERS += plugin/photoframeseditor.h \
widgets/photo_context_menu.h \
....
LIBS += \
-L/usr \
-lkdeui \
-lkio \
-lkipi \
-lkdecore
INCLUDEPATH += \
plugin \
....
OTHER_FILES += \
resources/photoframeseditorui.rc \
resources/photoframeseditor.kcfg \
CMakeLists.txt \
resources/PFEConfigSkeleton.kcfgc
RESOURCES += \
resources/icons.qrc
和 CMakeLists.txt
PROJECT( photoframeseditor )
FIND_PACKAGE( KDE4 REQUIRED )
INCLUDE(KDE4Defaults)
SET( INCLUDE_DIRS
./
./plugin
.....
)
INCLUDE_DIRECTORIES(${QT_INCLUDE} ${KDE4_INCLUDES} ${INCLUDE_DIRS})
# sources
SET( SAMPLE_SRCS
./main.cpp
.....
)
# moc headers
SET( SAMPLE_MOC_HDRS
./plugin/photoframeseditor.h
.....
)
SET( SAMPLE_RCS
./resources/icons.qrc
)
ADD_DEFINITIONS( -Wall )
SET( QT_USE_QTXML TRUE )
SET( QT_USE_QTCONSOLE TRUE )
FIND_PACKAGE( Qt4 REQUIRED )
INCLUDE( ${QT_USE_FILE} )
QT4_ADD_RESOURCES( SAMPLE_RC_SRCS ${SAMPLE_RCS} )
QT4_WRAP_CPP( SAMPLE_MOC_SRCS ${SAMPLE_MOC_HDRS} )
KDE4_ADD_EXECUTABLE( photoframeseditor ${SAMPLE_SRCS} ${SAMPLE_MOC_SRCS} ${SAMPLE_RC_SRCS} )
TARGET_LINK_LIBRARIES( photoframeseditor ${QT_LIBRARIES} ${KDE4_KDEUI_LIBS} ${KDE4_KPARTS_LIBS} ./utils/qtpropertybrowser/src/qtpropertybrowser.pri)
KDE4_ADD_KCFG_FILES(photoframeseditor_SRCS ./resources/PFEConfigSkeleton.kcfgc)
INSTALL( FILES ./resources/PFEConfigSkeleton.kcfgc DESTINATION ${KCFG_INSTALL_DIR} )
INSTALL( TARGETS photoframeseditor ${INSTALL_TARGETS_DEFAULT_ARGS} )
最后还有 *.pri 文件,我想将其包含到我的 CMakeLists.txt 中
include(../common.pri)
INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD
qtpropertybrowser-uselib:!qtpropertybrowser-buildlib {
LIBS += -L$$QTPROPERTYBROWSER_LIBDIR -l$$QTPROPERTYBROWSER_LIBNAME
} else {
SOURCES += $$PWD/qtpropertybrowser.cpp \
$$PWD/qtpropertymanager.cpp \
$$PWD/qteditorfactory.cpp \
$$PWD/qtvariantproperty.cpp \
$$PWD/qttreepropertybrowser.cpp \
$$PWD/qtbuttonpropertybrowser.cpp \
$$PWD/qtgroupboxpropertybrowser.cpp \
$$PWD/qtpropertybrowserutils.cpp
HEADERS += $$PWD/qtpropertybrowser.h \
$$PWD/qtpropertymanager.h \
$$PWD/qteditorfactory.h \
$$PWD/qtvariantproperty.h \
$$PWD/qttreepropertybrowser.h \
$$PWD/qtbuttonpropertybrowser.h \
$$PWD/qtgroupboxpropertybrowser.h \
$$PWD/qtpropertybrowserutils_p.h
RESOURCES += $$PWD/qtpropertybrowser.qrc
}
win32 {
contains(TEMPLATE, lib):contains(CONFIG, shared):DEFINES += QT_QTPROPERTYBROWSER_EXPORT
else:qtpropertybrowser-uselib:DEFINES += QT_QTPROPERTYBROWSER_IMPORT
}
感谢您提前提供的任何帮助!
I'm trying to create CMakeLists.txt file for KDE4/Qt4 project. In this project currently there is included one *.pri file which creates independent library. I would like to include that library into my CMakeLists.txt. I don't have any idea how to do this...
Currently my *.pro file looks like below:
include(utils/qtpropertybrowser/src/qtpropertybrowser.pri)
QT += core gui console xml
TARGET = photoframeseditor
TEMPLATE = app
SOURCES += main.cpp\
plugin/photoframeseditor.cpp \
....
HEADERS += plugin/photoframeseditor.h \
widgets/photo_context_menu.h \
....
LIBS += \
-L/usr \
-lkdeui \
-lkio \
-lkipi \
-lkdecore
INCLUDEPATH += \
plugin \
....
OTHER_FILES += \
resources/photoframeseditorui.rc \
resources/photoframeseditor.kcfg \
CMakeLists.txt \
resources/PFEConfigSkeleton.kcfgc
RESOURCES += \
resources/icons.qrc
And CMakeLists.txt
PROJECT( photoframeseditor )
FIND_PACKAGE( KDE4 REQUIRED )
INCLUDE(KDE4Defaults)
SET( INCLUDE_DIRS
./
./plugin
.....
)
INCLUDE_DIRECTORIES(${QT_INCLUDE} ${KDE4_INCLUDES} ${INCLUDE_DIRS})
# sources
SET( SAMPLE_SRCS
./main.cpp
.....
)
# moc headers
SET( SAMPLE_MOC_HDRS
./plugin/photoframeseditor.h
.....
)
SET( SAMPLE_RCS
./resources/icons.qrc
)
ADD_DEFINITIONS( -Wall )
SET( QT_USE_QTXML TRUE )
SET( QT_USE_QTCONSOLE TRUE )
FIND_PACKAGE( Qt4 REQUIRED )
INCLUDE( ${QT_USE_FILE} )
QT4_ADD_RESOURCES( SAMPLE_RC_SRCS ${SAMPLE_RCS} )
QT4_WRAP_CPP( SAMPLE_MOC_SRCS ${SAMPLE_MOC_HDRS} )
KDE4_ADD_EXECUTABLE( photoframeseditor ${SAMPLE_SRCS} ${SAMPLE_MOC_SRCS} ${SAMPLE_RC_SRCS} )
TARGET_LINK_LIBRARIES( photoframeseditor ${QT_LIBRARIES} ${KDE4_KDEUI_LIBS} ${KDE4_KPARTS_LIBS} ./utils/qtpropertybrowser/src/qtpropertybrowser.pri)
KDE4_ADD_KCFG_FILES(photoframeseditor_SRCS ./resources/PFEConfigSkeleton.kcfgc)
INSTALL( FILES ./resources/PFEConfigSkeleton.kcfgc DESTINATION ${KCFG_INSTALL_DIR} )
INSTALL( TARGETS photoframeseditor ${INSTALL_TARGETS_DEFAULT_ARGS} )
And finally there is *.pri file, I would like to include into my CMakeLists.txt
include(../common.pri)
INCLUDEPATH += $PWD
DEPENDPATH += $PWD
qtpropertybrowser-uselib:!qtpropertybrowser-buildlib {
LIBS += -L$QTPROPERTYBROWSER_LIBDIR -l$QTPROPERTYBROWSER_LIBNAME
} else {
SOURCES += $PWD/qtpropertybrowser.cpp \
$PWD/qtpropertymanager.cpp \
$PWD/qteditorfactory.cpp \
$PWD/qtvariantproperty.cpp \
$PWD/qttreepropertybrowser.cpp \
$PWD/qtbuttonpropertybrowser.cpp \
$PWD/qtgroupboxpropertybrowser.cpp \
$PWD/qtpropertybrowserutils.cpp
HEADERS += $PWD/qtpropertybrowser.h \
$PWD/qtpropertymanager.h \
$PWD/qteditorfactory.h \
$PWD/qtvariantproperty.h \
$PWD/qttreepropertybrowser.h \
$PWD/qtbuttonpropertybrowser.h \
$PWD/qtgroupboxpropertybrowser.h \
$PWD/qtpropertybrowserutils_p.h
RESOURCES += $PWD/qtpropertybrowser.qrc
}
win32 {
contains(TEMPLATE, lib):contains(CONFIG, shared):DEFINES += QT_QTPROPERTYBROWSER_EXPORT
else:qtpropertybrowser-uselib:DEFINES += QT_QTPROPERTYBROWSER_IMPORT
}
Thanks for any help in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好的,我已经为这个 *.pri 文件提供了正确的 CMakeLists.txt:
Ok I've got correct CMakeLists.txt for this *.pri file:
您可以按照此链接中的说明仅创建一个 CMakeLists.txt 文件
http://developer.qt.nokia.com/quarterly/view/using_cmake_to_build_qt_projects
您不需要 *.pri 文件。只需将 *.pri 中的文件包含到 CMakeLists.txt 中
You can create just a CMakeLists.txt file as described in this link
http://developer.qt.nokia.com/quarterly/view/using_cmake_to_build_qt_projects
you don't need the *.pri file. just include the files in *.pri into your CMakeLists.txt
只需向您的 cmakelists.txt 添加一些内容
喜欢:
just add something to your cmakelists.txt
like: