fix:解决使用find_package无法正常使用ukui-search接口的问题

This commit is contained in:
iaom 2024-02-02 17:02:15 +08:00
parent 31e1474ccb
commit 806aa95930
7 changed files with 28 additions and 31 deletions

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.14) cmake_minimum_required(VERSION 3.14)
project(ukui-search VERSION 1.0 LANGUAGES C CXX) project(frontend VERSION 1.0 LANGUAGES C CXX)
set(VERSION_MAJOR 2) set(VERSION_MAJOR 2)
set(VERSION_MINOR 2) set(VERSION_MINOR 2)
@ -66,18 +66,22 @@ qt5_create_translation(UKUI_SEARCH_QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${UKUI_S
file(GLOB UKUI_SEARCH_APP_WIDGET_TS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../translations/ukui-search/appwidget/*.ts) file(GLOB UKUI_SEARCH_APP_WIDGET_TS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../translations/ukui-search/appwidget/*.ts)
set_source_files_properties(${UKUI_SEARCH_APP_WIDGET_TS_FILES} PROPERTIES OUTPUT_LOCATION ${CMAKE_BINARY_DIR}/frontend/.qm) set_source_files_properties(${UKUI_SEARCH_APP_WIDGET_TS_FILES} PROPERTIES OUTPUT_LOCATION ${CMAKE_BINARY_DIR}/frontend/.qm)
qt5_create_translation(UKUI_SEARCH_APP_WIDGET_QM_FILES ${PROJECT_SOURCE_DIR} ${UKUI_SEARCH_APP_WIDGET_TS_FILES}) qt5_create_translation(UKUI_SEARCH_APP_WIDGET_QM_FILES ${PROJECT_SOURCE_DIR} ${UKUI_SEARCH_APP_WIDGET_TS_FILES})
add_executable(ukui-search add_executable(frontend
${UKUI_SEARCH_SRC} ${UKUI_SEARCH_SRC}
${QRC_FILES} ${QRC_FILES}
${UKUI_SEARCH_QM_FILES} ${UKUI_SEARCH_QM_FILES}
${UKUI_SEARCH_APP_WIDGET_QM_FILES}) ${UKUI_SEARCH_APP_WIDGET_QM_FILES})
set_target_properties(frontend
PROPERTIES
OUTPUT_NAME ukui-search
)
set(UKUI_SEARCH_QM_INSTALL_PATH /usr/share/ukui-search/translations/ukui-search) set(UKUI_SEARCH_QM_INSTALL_PATH /usr/share/ukui-search/translations/ukui-search)
target_compile_definitions(ukui-search PRIVATE target_compile_definitions(frontend PRIVATE
VERSION="${UKUI_SEARCH_VERSION}" VERSION="${UKUI_SEARCH_VERSION}"
UKUI_SEARCH_QM_INSTALL_PATH="${UKUI_SEARCH_QM_INSTALL_PATH}" UKUI_SEARCH_QM_INSTALL_PATH="${UKUI_SEARCH_QM_INSTALL_PATH}"
) )
target_link_libraries(ukui-search PRIVATE target_link_libraries(frontend PRIVATE
KF5::WindowSystem KF5::WindowSystem
Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::DBus Qt${QT_VERSION_MAJOR}::DBus
@ -87,14 +91,14 @@ target_link_libraries(ukui-search PRIVATE
gsettings-qt gsettings-qt
ukui-appwidget-manager ukui-appwidget-manager
ukui-appwidget-provider ukui-appwidget-provider
libukui-search ukui-search
chinese-segmentation chinese-segmentation
kysdk-waylandhelper kysdk-waylandhelper
qtsingleapplication qtsingleapplication
tcmalloc_minimal tcmalloc_minimal
) )
target_include_directories(ukui-search PRIVATE target_include_directories(frontend PRIVATE
../3rd-parties/qtsingleapplication/src ../3rd-parties/qtsingleapplication/src
../libchinese-segmentation ../libchinese-segmentation
../libsearch ../libsearch
@ -107,7 +111,6 @@ target_include_directories(ukui-search PRIVATE
model model
search-app-widget-plugin search-app-widget-plugin
view view
xatom
) )
set(APP_WIDGET_FILES_PRE set(APP_WIDGET_FILES_PRE
@ -123,7 +126,7 @@ install(FILES
install(FILES ${APP_WIDGET_FILES_PRE}/data/search.qml DESTINATION /usr/share/appwidget/qml/) install(FILES ${APP_WIDGET_FILES_PRE}/data/search.qml DESTINATION /usr/share/appwidget/qml/)
install(FILES ${UKUI_SEARCH_APP_WIDGET_QM_FILES} DESTINATION /usr/share/appwidget/translations/) install(FILES ${UKUI_SEARCH_APP_WIDGET_QM_FILES} DESTINATION /usr/share/appwidget/translations/)
# #
install(TARGETS ukui-search RUNTIME DESTINATION /usr/bin) install(TARGETS frontend RUNTIME DESTINATION /usr/bin)
# #
install(FILES ${UKUI_SEARCH_QM_FILES} DESTINATION ${UKUI_SEARCH_QM_INSTALL_PATH}) install(FILES ${UKUI_SEARCH_QM_FILES} DESTINATION ${UKUI_SEARCH_QM_INSTALL_PATH})
#desktop #desktop

View File

@ -1,3 +1,6 @@
cmake_minimum_required(VERSION 3.14)
project(ukui-search VERSION 1.0 LANGUAGES C CXX)
set(VERSION_MAJOR 2) set(VERSION_MAJOR 2)
set(VERSION_MINOR 3) set(VERSION_MINOR 3)
set(VERSION_MICRO 0) set(VERSION_MICRO 0)
@ -14,10 +17,10 @@ find_package(PkgConfig REQUIRED)
find_package(KF5WindowSystem) find_package(KF5WindowSystem)
find_package(qt5xdg) find_package(qt5xdg)
find_package(ukui-file-metadata) find_package(ukui-file-metadata)
find_package(xapian)
set(LIBUKUI_SEARCH_EXTERNAL_LIBS "") set(LIBUKUI_SEARCH_EXTERNAL_LIBS "")
set(LIBUKUI_SEARCH_PC_PKGS set(LIBUKUI_SEARCH_PC_PKGS
xapian-core
gio-2.0 gio-2.0
glib-2.0 glib-2.0
gio-unix-2.0 gio-unix-2.0
@ -109,7 +112,7 @@ file(GLOB TS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../translations/libukui-search/*.
set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION ${CMAKE_BINARY_DIR}/libsearch/.qm) set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION ${CMAKE_BINARY_DIR}/libsearch/.qm)
qt5_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES}) qt5_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES})
add_library(libukui-search SHARED add_library(${PROJECT_NAME} SHARED
${LIBUKUI_SEARCH_SRC} ${LIBUKUI_SEARCH_SRC}
${QRC_FILES} ${QRC_FILES}
${QM_FILES} ${QM_FILES}
@ -152,12 +155,12 @@ include_directories(
websearch websearch
) )
target_compile_definitions(libukui-search PRIVATE target_compile_definitions(${PROJECT_NAME} PRIVATE
PLUGIN_INSTALL_DIRS="/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/ukui-search-plugins" PLUGIN_INSTALL_DIRS="/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/ukui-search-plugins"
QT_NO_KEYWORDS QT_NO_KEYWORDS
) )
target_link_libraries(libukui-search PUBLIC target_link_libraries(${PROJECT_NAME} PRIVATE
KF5::WindowSystem KF5::WindowSystem
Qt5Xdg Qt5Xdg
Qt${QT_VERSION_MAJOR}::Concurrent Qt${QT_VERSION_MAJOR}::Concurrent
@ -180,7 +183,7 @@ set(CMAKE_CONFIG_INSTALL_DIR "/usr/share/cmake/ukui-search")
set(HEADERS_INSTALL_DIR /usr/include/ukui-search) set(HEADERS_INSTALL_DIR /usr/include/ukui-search)
set(PC_INSTALL_DIR "/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig") set(PC_INSTALL_DIR "/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig")
target_include_directories(libukui-search PUBLIC $<INSTALL_INTERFACE:${HEADERS_INSTALL_DIR}>) target_include_directories(${PROJECT_NAME} PUBLIC $<INSTALL_INTERFACE:${HEADERS_INSTALL_DIR}>)
configure_package_config_file( configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/ukui-search-config.cmake.in" "${CMAKE_CURRENT_SOURCE_DIR}/ukui-search-config.cmake.in"
@ -196,18 +199,18 @@ configure_package_config_file(
"${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/ukui-search.pc" "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/ukui-search.pc"
INSTALL_DESTINATION ${PC_INSTALL_DIR}) INSTALL_DESTINATION ${PC_INSTALL_DIR})
set_target_properties(libukui-search PROPERTIES set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION ${LIBUKUI_SEARCH_VERSION} VERSION ${LIBUKUI_SEARCH_VERSION}
SOVERSION ${VERSION_MAJOR} SOVERSION ${VERSION_MAJOR}
OUTPUT_NAME ukui-search OUTPUT_NAME ukui-search
) )
install(TARGETS libukui-search install(TARGETS ${PROJECT_NAME}
EXPORT libukui-search EXPORT ${PROJECT_NAME}
PUBLIC_HEADER DESTINATION ${HEADERS_INSTALL_DIR} PUBLIC_HEADER DESTINATION ${HEADERS_INSTALL_DIR}
LIBRARY DESTINATION /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} LIBRARY DESTINATION /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}
) )
install(EXPORT libukui-search install(EXPORT ${PROJECT_NAME}
FILE ukui-search-targets.cmake FILE ${PROJECT_NAME}-targets.cmake
DESTINATION ${CMAKE_CONFIG_INSTALL_DIR}) DESTINATION ${CMAKE_CONFIG_INSTALL_DIR})
install(FILES ${QM_FILES} DESTINATION /usr/share/ukui-search/translations/libukui-search) install(FILES ${QM_FILES} DESTINATION /usr/share/ukui-search/translations/libukui-search)

View File

@ -1,10 +1 @@
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
find_dependency(chinese-segmentation)
find_dependency(Qt@QT_VERSION_MAJOR@Core "@REQUIRED_QT_VERSION@")
if(TARGET Qt6::Core)
find_dependency(Qt6Core5Compat @REQUIRED_QT_VERSION@)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/ukui-search-targets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/ukui-search-targets.cmake")

View File

@ -27,5 +27,5 @@ target_include_directories(tests PRIVATE
target_link_libraries(tests PRIVATE target_link_libraries(tests PRIVATE
# Remove: L${CMAKE_CURRENT_BINARY_DIR}/../libsearch/ # Remove: L${CMAKE_CURRENT_BINARY_DIR}/../libsearch/
Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Core
libukui-search ukui-search
) )

View File

@ -56,7 +56,7 @@ target_link_libraries(ukui-search-app-data-service PRIVATE
Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::Network
Qt${QT_VERSION_MAJOR}::Sql Qt${QT_VERSION_MAJOR}::Sql
chinese-segmentation chinese-segmentation
libukui-search ukui-search
qtsingleapplication qtsingleapplication
) )

View File

@ -61,7 +61,7 @@ target_link_libraries(ukui-search-service-dir-manager PRIVATE
Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::Network
Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Widgets
qtsingleapplication qtsingleapplication
libukui-search ukui-search
${UKUI_SEARCH_SERVICE_DIR_MANAGER_EXTERNAL_LIBS} ${UKUI_SEARCH_SERVICE_DIR_MANAGER_EXTERNAL_LIBS}
) )
install(FILES conf/com.ukui.search.fileindex.service DESTINATION /usr/share/dbus-1/services/) install(FILES conf/com.ukui.search.fileindex.service DESTINATION /usr/share/dbus-1/services/)

View File

@ -62,7 +62,7 @@ target_link_libraries(ukui-search-service PRIVATE
Qt${QT_VERSION_MAJOR}::Quick Qt${QT_VERSION_MAJOR}::Quick
Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::RemoteObjects Qt${QT_VERSION_MAJOR}::RemoteObjects
libukui-search ukui-search
qtsingleapplication qtsingleapplication
${UKUI_SEARCH_SERVICE_EXTERNAL_LIBS} ${UKUI_SEARCH_SERVICE_EXTERNAL_LIBS}
) )