Skip to content

Commit 9acf240

Browse files
committed
Fix FindLibKKC
1. pc name is not libkkc, but kkc-1.0 2. error when pc failed. 3. fix the link/compile options and cleanup
1 parent 37a3ec6 commit 9acf240

File tree

4 files changed

+14
-16
lines changed

4 files changed

+14
-16
lines changed

CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ find_package(PkgConfig REQUIRED)
1616
find_package(Fcitx5Core ${REQUIRED_FCITX_VERSION} REQUIRED)
1717
find_package(LibKKC REQUIRED)
1818
find_package(Gettext REQUIRED)
19-
pkg_check_modules(Gee IMPORTED_TARGET "gee-0.8" REQUIRED)
20-
pkg_check_modules(JSonGlib IMPORTED_TARGET "json-glib-1.0" REQUIRED)
21-
pkg_check_modules(GObject2 IMPORTED_TARGET "gobject-2.0" REQUIRED)
2219

2320
if (ENABLE_QT)
2421
set(QT_MAJOR_VERSION 6)

cmake/FindLibKKC.cmake

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,39 @@
1717
# use pkg-config to get the directories and then use these values
1818
# in the find_path() and find_library() calls
1919
find_package(PkgConfig QUIET)
20-
pkg_check_modules(PC_LibKKC QUIET libkkc)
20+
pkg_check_modules(PC_LibKKC QUIET kkc-1.0)
2121

2222
find_path(LIBKKC_INCLUDE_DIR NAMES libkkc/libkkc.h
2323
HINTS
24-
${PC_LIBKKC_INCLUDEDIR}
25-
${PC_LIBKKC_INCLUDE_DIRS}
24+
${PC_LibKKC_INCLUDEDIR}
25+
${PC_LibKKC_INCLUDE_DIRS}
2626
)
2727

2828
find_library(LIBKKC_LIBRARIES NAMES kkc
2929
HINTS
30-
${PC_LIBKKC_LIBDIR}
31-
${PC_LIBKKC_LIBRARY_DIRS}
30+
${PC_LibKKC_LIBDIR}
31+
${PC_LibKKC_LIBRARY_DIRS}
3232
)
3333

34-
if(PC_LIBKKC_VERSION)
35-
set(LIBKKC_VERSION_STRING ${PC_LIBKKC_VERSION})
34+
if(PC_LibKKC_FOUND)
35+
set(LIBKKC_VERSION_STRING ${PC_LibKKC_VERSION})
3636
endif()
3737

3838
# handle the QUIETLY and REQUIRED arguments and set LIBKKC_FOUND to TRUE if
3939
# all listed variables are TRUE
4040
include(FindPackageHandleStandardArgs)
4141
find_package_handle_standard_args(LibKKC
42-
REQUIRED_VARS LIBKKC_LIBRARIES LIBKKC_INCLUDE_DIR
42+
REQUIRED_VARS LIBKKC_VERSION_STRING LIBKKC_LIBRARIES LIBKKC_INCLUDE_DIR
4343
VERSION_VAR LIBKKC_VERSION_STRING)
4444

4545
mark_as_advanced(LIBKKC_INCLUDE_DIR LIBKKC_LIBRARIES)
4646

4747
if (LIBKKC_FOUND AND NOT TARGET LibKKC::LibKKC)
48-
add_library(LibKKC::LibKKC UNKNOWN IMPORTED)
48+
add_library(LibKKC::LibKKC INTERFACE IMPORTED)
4949
set_target_properties(LibKKC::LibKKC PROPERTIES
50-
IMPORTED_LOCATION "${LIBKKC_LIBRARIES}"
51-
INTERFACE_INCLUDE_DIRECTORIES "${LIBKKC_INCLUDE_DIR}"
50+
INTERFACE_COMPILE_OPTIONS "${PC_LibKKC_CFLAGS}"
51+
INTERFACE_LINK_OPTIONS "${PC_LibKKC_LDFLAGS_OTHER}"
52+
INTERFACE_LINK_LIBRARIES "${PC_LibKKC_LINK_LIBRARIES}"
5253
)
5354
endif()
5455

gui/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ target_link_libraries(fcitx5-kkc-config
2828
Qt${QT_MAJOR_VERSION}::Core
2929
Qt${QT_MAJOR_VERSION}::Widgets
3030
Fcitx5Qt${QT_MAJOR_VERSION}::WidgetsAddons
31-
LibKKC::LibKKC PkgConfig::GObject2 PkgConfig::JSonGlib PkgConfig::Gee
31+
LibKKC::LibKKC
3232
)
3333

3434
install(TARGETS fcitx5-kkc-config DESTINATION ${CMAKE_INSTALL_LIBDIR}/fcitx5/qt${QT_MAJOR_VERSION})

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ set(KKC_SOURCES
22
kkc.cpp
33
)
44
add_fcitx5_addon(kkc ${KKC_SOURCES})
5-
target_link_libraries(kkc Fcitx5::Core Fcitx5::Config LibKKC::LibKKC PkgConfig::GObject2 PkgConfig::JSonGlib PkgConfig::Gee)
5+
target_link_libraries(kkc Fcitx5::Core Fcitx5::Config LibKKC::LibKKC)
66
target_include_directories(kkc PRIVATE ${PROJECT_BINARY_DIR})
77
set_target_properties(kkc PROPERTIES PREFIX "")
88
install(TARGETS kkc DESTINATION "${CMAKE_INSTALL_LIBDIR}/fcitx5")

0 commit comments

Comments
 (0)