gpt4 book ai didi

qt - CMakeLists.txt 和 Qt 的 *.pri 文件

转载 作者:行者123 更新时间:2023-12-05 01:48:42 24 4
gpt4 key购买 nike

我正在尝试为 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
}

提前感谢您的帮助!

最佳答案

好的,我已经为这个 *.pri 文件找到了正确的 CMakeLists.txt:

PROJECT(PropertyBrowser)
SET(QT_MIN_VERSION "4.5.0")
FIND_PACKAGE(Qt4 REQUIRED)

IF(NOT QT4_FOUND)
MESSAGE(SEND_ERROR "Failed to find Qt 4.5 or greater.")
ELSE(NOT QT4_FOUND)

INCLUDE(${QT_USE_FILE})
SET(CMAKE_PACKAGE_QTGUI TRUE)

SET(qtpropertyeditor_SRCS
src/qtpropertybrowser.cpp
src/qtpropertymanager.cpp
src/qteditorfactory.cpp
src/qtvariantproperty.cpp
src/qttreepropertybrowser.cpp
src/qtbuttonpropertybrowser.cpp
src/qtgroupboxpropertybrowser.cpp
src/qtpropertybrowserutils.cpp
)

include_directories(${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/src)
include_directories(src)
INCLUDE_DIRECTORIES(
${QT_INCLUDE_DIR}
)

qt4_generate_moc(
src/qtpropertybrowser.h
${CMAKE_CURRENT_BINARY_DIR}/moc_qtpropertybrowser.cpp
)
qt4_generate_moc(
src/qtpropertymanager.h
${CMAKE_CURRENT_BINARY_DIR}/moc_qtpropertymanager.cpp
)
qt4_generate_moc(
src/qteditorfactory.h
${CMAKE_CURRENT_BINARY_DIR}/moc_qteditorfactory.cpp
)
qt4_generate_moc(
src/qtvariantproperty.h
${CMAKE_CURRENT_BINARY_DIR}/moc_qtvariantproperty.cpp
)
qt4_generate_moc(
src/qttreepropertybrowser.h
${CMAKE_CURRENT_BINARY_DIR}/moc_qttreepropertybrowser.cpp
)
qt4_generate_moc(
src/qtbuttonpropertybrowser.h
${CMAKE_CURRENT_BINARY_DIR}/moc_qtbuttonpropertybrowser.cpp
)
qt4_generate_moc(
src/qtgroupboxpropertybrowser.h
${CMAKE_CURRENT_BINARY_DIR}/moc_qtgroupboxpropertybrowser.cpp
)
qt4_generate_moc(
src/qtpropertymanager.cpp
${CMAKE_CURRENT_BINARY_DIR}/qtpropertymanager.moc
)
qt4_generate_moc(
src/qteditorfactory.cpp
${CMAKE_CURRENT_BINARY_DIR}/qteditorfactory.moc
)
qt4_generate_moc(
src/qttreepropertybrowser.cpp
${CMAKE_CURRENT_BINARY_DIR}/qttreepropertybrowser.moc
)

set(
qtpropertyeditor_HEADERS_ONLY_MOC
${CMAKE_CURRENT_BINARY_DIR}/moc_qtpropertybrowser.cpp
${CMAKE_CURRENT_BINARY_DIR}/moc_qtpropertymanager.cpp
${CMAKE_CURRENT_BINARY_DIR}/moc_qteditorfactory.cpp
${CMAKE_CURRENT_BINARY_DIR}/moc_qtvariantproperty.cpp
${CMAKE_CURRENT_BINARY_DIR}/moc_qttreepropertybrowser.cpp
${CMAKE_CURRENT_BINARY_DIR}/moc_qtbuttonpropertybrowser.cpp
${CMAKE_CURRENT_BINARY_DIR}/moc_qtgroupboxpropertybrowser.cpp
${CMAKE_CURRENT_BINARY_DIR}/qtpropertymanager.moc
${CMAKE_CURRENT_BINARY_DIR}/qteditorfactory.moc
${CMAKE_CURRENT_BINARY_DIR}/qttreepropertybrowser.moc
)

set_source_files_properties(
${qtpropertyeditor_HEADERS_ONLY_MOC}
PROPERTIES
HEADER_FILE_ONLY true
)

qt4_generate_moc(
src/qtpropertybrowserutils_p.h
${CMAKE_CURRENT_BINARY_DIR}/moc_qtpropertybrowserutils_p.cpp
)

set(
qtpropertyeditor_HEADERS_MOC
${CMAKE_CURRENT_BINARY_DIR}/moc_qtpropertybrowserutils_p.cpp
)

set(
qtpropertyeditor_MOC
${qtpropertyeditor_HEADERS_MOC}
${qtpropertyeditor_HEADERS_ONLY_MOC}
)

qt4_add_resources(
qtpropertyeditor_RESOURCES
src/qtpropertybrowser.qrc
)

#set(
# extension_SRCS
# main.cpp
#)

#qt4_generate_moc(
# main.cpp
# ${CMAKE_CURRENT_SOURCE_DIR}/main.moc
#)

#set(
# extension_MOC
# ${CMAKE_CURRENT_SOURCE_DIR}/main.moc
#)

#set_source_files_properties(
# ${extension_MOC}
# PROPERTIES
# HEADER_FILE_ONLY true
#)

QT4_ADD_RESOURCES(RESOURCE_SRCS src/qtpropertybrowser.qrc)

#${extension_SRCS}

SET(SRCS ${extension_MOC}
${qtpropertyeditor_MOC}
${qtpropertyeditor_SRCS}
${qtpropertyeditor_RESOURCES}
)

ADD_LIBRARY(PropertyBrowser SHARED ${SRCS})

TARGET_LINK_LIBRARIES(PropertyBrowser ${QT_LIBRARIES})

ADD_DEFINITIONS(${QT_DEFINITIONS})
ADD_DEFINITIONS(-DQT_DLL)
ADD_DEFINITIONS(-DQT_QTPROPERTYBROWSER_EXPORT)
ADD_DEFINITIONS(-DQT_PLUGIN)
#ADD_DEFINITIONS(-DQT_NO_DEBUG)
ADD_DEFINITIONS(-DQT_SHARED)

INSTALL( TARGETS PropertyBrowser LIBRARY DESTINATION lib ${INSTALL_TARGETS_DEFAULT_ARGS} )

ENDIF(NOT QT4_FOUND)

关于qt - CMakeLists.txt 和 Qt 的 *.pri 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7192129/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com