Skip to content

Commit a68cc09

Browse files
committed
Add option and full fcitx file support
1 parent 9ebb875 commit a68cc09

19 files changed

+152
-43
lines changed

CMakeLists.txt

+15-43
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ set(MOZC_SOURCE_DIR ${PROJECT_SOURCE_DIR}/mozc/src)
2424
include_directories(mozc/src)
2525
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
2626
set(MOZC_LIBRARY_TYPE STATIC)
27-
set(MOZC_LIBRARY_TYPE SHARED) # Uncomment to test dependency and missing symbols.
27+
# set(MOZC_LIBRARY_TYPE SHARED) # Uncomment to test dependency and missing symbols.
28+
29+
option(ENABLE_SERVER "Build Fcitx 5 Mozc with server" On)
30+
option(BUILD_SERVER "Build mozc_server" On)
31+
option(BUILD_TOOL "Build mozc_tool" On)
32+
option(BUILD_FCITX "Build fcitx5-mozc" On)
2833

2934
add_subdirectory(protocol)
3035
add_subdirectory(base)
@@ -42,48 +47,15 @@ add_subdirectory(transliteration)
4247
add_subdirectory(session)
4348
add_subdirectory(prediction)
4449
add_subdirectory(engine)
45-
add_subdirectory(gui)
46-
47-
add_executable(mozc_server
48-
mozc/src/server/mozc_server.cc
49-
mozc/src/server/mozc_server_main.cc
50-
)
5150

52-
target_include_directories(mozc_server PRIVATE mozc/src)
53-
target_link_libraries(mozc_server
54-
mozc::protocol::protocol
55-
mozc::base::system_util
56-
mozc::base::run_level
57-
mozc::base::init_mozc
58-
mozc::base::crash_report_handler
59-
mozc::base::process_mutex
60-
mozc::session::session_server
61-
config-stats_config_util
62-
)
63-
64-
add_library(fcitx5-mozc MODULE
65-
mozc/src/unix/fcitx5/surrounding_text_util.cc
66-
mozc/src/unix/fcitx5/fcitx_key_event_handler.cc
67-
mozc/src/unix/fcitx5/fcitx_key_translator.cc
68-
mozc/src/unix/fcitx5/mozc_client_pool.cc
69-
mozc/src/unix/fcitx5/mozc_engine_factory.cc
70-
mozc/src/unix/fcitx5/mozc_engine.cc
71-
mozc/src/unix/fcitx5/mozc_ipc_client.cc
72-
mozc/src/unix/fcitx5/mozc_response_parser.cc
73-
mozc/src/unix/fcitx5/mozc_state.cc
74-
)
75-
set_target_properties(fcitx5-mozc PROPERTIES PREFIX "")
51+
if (BUILD_TOOL)
52+
add_subdirectory(gui)
53+
endif()
7654

77-
target_link_libraries(fcitx5-mozc
78-
Fcitx5::Core
79-
PkgConfig::Fcitx5Module
80-
mozc::protocol::protocol
81-
mozc::base::vlog
82-
mozc::base::process
83-
mozc::base::util
84-
mozc::base::init_mozc
85-
mozc::client::client)
55+
if (BUILD_SERVER)
56+
add_subdirectory(server)
57+
endif()
8658

87-
install(TARGETS mozc_server DESTINATION "${CMAKE_INSTALL_LIBDIR}/mozc")
88-
install(TARGETS mozc_tool DESTINATION "${CMAKE_INSTALL_LIBDIR}/mozc")
89-
install(TARGETS fcitx5-mozc DESTINATION "${CMAKE_INSTALL_LIBDIR}/fcitx5")
59+
if (BUILD_FCITX)
60+
add_subdirectory(fcitx)
61+
endif()

base/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ mozc_python_gen_file(base/gen_character_set.py
8585
--jisx0208file=data/unicode/JIS0208.TXT
8686
--output=${CMAKE_CURRENT_BINARY_DIR}/character_set.inc)
8787
add_custom_target(character_set DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/character_set.inc)
88+
set_target_properties(character_set PROPERTIES EXCLUDE_FROM_ALL TRUE)
8889
mozc_library(strings
8990
SOURCES
9091
strings/internal/double_array.cc

cmake/Macros.cmake

+5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ elseif (add_target STREQUAL add_library)
4040
add_library(${TGT} ${LIBRARY_TYPE})
4141
endif()
4242

43+
set_target_properties(${TGT} PROPERTIES EXCLUDE_FROM_ALL TRUE)
44+
4345
set(sources)
4446
foreach(source_arg IN LISTS arg_SOURCES)
4547
if (NOT IS_ABSOLUTE ${source_arg})
@@ -237,6 +239,7 @@ mozc_python_gen_file(build_tools/embed_file.py
237239
add_custom_target(dataset-${dataset_tag}-pos_list
238240
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${POS_LIST_INC}
239241
)
242+
set_target_properties(dataset-${dataset_tag}-pos_list PROPERTIES EXCLUDE_FROM_ALL TRUE)
240243

241244
mozc_python_gen_file(dictionary/gen_pos_matcher_code.py
242245
OUTPUTS ${POS_MATCHER_DATA}
@@ -309,6 +312,7 @@ mozc_binary_gen_file(mozc::dictionary::gen_system_dictionary_data_main
309312
add_custom_target(dataset-${dataset_tag}-system_dictionary
310313
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${SYSTEM_DICTIONARY}
311314
)
315+
set_target_properties(dataset-${dataset_tag}-system_dictionary PROPERTIES EXCLUDE_FROM_ALL TRUE)
312316

313317
set(SUGGESTION_FILTER_FILE ${MOZC_SOURCE_DIR}/data/dictionary_oss/suggestion_filter.txt)
314318
set(SUGGESTION_FILTER_DATA suggestion_filter_data.data)
@@ -637,5 +641,6 @@ mozc_python_gen_file(build_tools/embed_file.py
637641
add_custom_target(dataset-${dataset_tag}-mozc_data
638642
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${MOZC_DATA_INC}
639643
)
644+
set_target_properties(dataset-${dataset_tag}-mozc_data PROPERTIES EXCLUDE_FROM_ALL TRUE)
640645

641646
endfunction()

data_manager/oss/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ mozc_python_gen_file(build_tools/redirect.py
2222
add_custom_target(segmenter_inl
2323
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/segmenter_inl.inc
2424
)
25+
set_target_properties(segmenter_inl PROPERTIES EXCLUDE_FROM_ALL TRUE)
2526

2627
mozc_executable(gen_oss_segmenter_bitarray_main.cc
2728
DEPENDS

dictionary/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ mozc_python_gen_file(dictionary/gen_pos_matcher_code.py
55
--output_pos_matcher_h=${CMAKE_CURRENT_BINARY_DIR}/pos_matcher_impl.inc
66
)
77
add_custom_target(pos_matcher_impl DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/pos_matcher_impl.inc)
8+
set_target_properties(pos_matcher_impl PROPERTIES EXCLUDE_FROM_ALL TRUE)
89

910
mozc_library(pos_matcher.h)
1011
target_include_directories(dictionary-pos_matcher INTERFACE ${PROJECT_BINARY_DIR})
@@ -26,6 +27,7 @@ mozc_python_gen_file(dictionary/gen_pos_map.py
2627
--output=${CMAKE_CURRENT_BINARY_DIR}/pos_map.inc
2728
)
2829
add_custom_target(pos_map DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/pos_map.inc)
30+
set_target_properties(pos_map PROPERTIES EXCLUDE_FROM_ALL TRUE)
2931
mozc_library(user_dictionary_importer.cc
3032
DEPENDS mozc::protocol::protocol mozc::base::mmap mozc::base::strings mozc::base::vlog mozc::base::number_util mozc::base::hash mozc::dictionary::user_dictionary_util)
3133
add_dependencies(dictionary-user_dictionary_importer pos_map)

fcitx/CMakeLists.txt

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
find_package(Gettext REQUIRED)
2+
3+
add_library(fcitx5-mozc MODULE
4+
${MOZC_SOURCE_DIR}/unix/fcitx5/surrounding_text_util.cc
5+
${MOZC_SOURCE_DIR}/unix/fcitx5/fcitx_key_event_handler.cc
6+
${MOZC_SOURCE_DIR}/unix/fcitx5/fcitx_key_translator.cc
7+
${MOZC_SOURCE_DIR}/unix/fcitx5/mozc_client_pool.cc
8+
${MOZC_SOURCE_DIR}/unix/fcitx5/mozc_engine_factory.cc
9+
${MOZC_SOURCE_DIR}/unix/fcitx5/mozc_engine.cc
10+
${MOZC_SOURCE_DIR}/unix/fcitx5/mozc_ipc_client.cc
11+
${MOZC_SOURCE_DIR}/unix/fcitx5/mozc_response_parser.cc
12+
${MOZC_SOURCE_DIR}/unix/fcitx5/mozc_state.cc
13+
)
14+
set_target_properties(fcitx5-mozc PROPERTIES PREFIX "")
15+
16+
target_link_libraries(fcitx5-mozc
17+
Fcitx5::Core
18+
PkgConfig::Fcitx5Module
19+
mozc::protocol::protocol
20+
mozc::base::vlog
21+
mozc::base::process
22+
mozc::base::util
23+
mozc::base::init_mozc
24+
mozc::client::client)
25+
install(TARGETS fcitx5-mozc DESTINATION "${CMAKE_INSTALL_LIBDIR}/fcitx5")
26+
install(FILES ${MOZC_SOURCE_DIR}/unix/fcitx5/mozc-addon.conf RENAME mozc.conf DESTINATION "${FCITX_INSTALL_PKGDATADIR}/addon"
27+
COMPONENT config)
28+
install(FILES ${MOZC_SOURCE_DIR}/unix/fcitx5/mozc.conf RENAME mozc.conf DESTINATION "${FCITX_INSTALL_PKGDATADIR}/inputmethod"
29+
COMPONENT config)
30+
fcitx5_translate_desktop_file(${MOZC_SOURCE_DIR}/unix/fcitx5/org.fcitx.Fcitx5.Addon.Mozc.metainfo.xml.in
31+
org.fcitx.Fcitx5.Addon.Mozc.metainfo.xml XML PO_DIRECTORY ${MOZC_SOURCE_DIR}/unix/fcitx5/po)
32+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/org.fcitx.Fcitx5.Addon.Mozc.metainfo.xml" DESTINATION ${CMAKE_INSTALL_DATADIR}/metainfo)
33+
34+
install(FILES ${MOZC_SOURCE_DIR}/data/images/product_icon_32bpp-128.png
35+
RENAME org.fcitx.Fcitx5.fcitx_mozc.png
36+
DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/128x128/apps")
37+
install(FILES ${MOZC_SOURCE_DIR}/data/images/unix/ime_product_icon_opensource-32.png
38+
RENAME org.fcitx.Fcitx5.fcitx_mozc.png
39+
DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/32x32/apps")
40+
install(FILES ${MOZC_SOURCE_DIR}/../scripts/icons/ui-alpha_full.png
41+
RENAME org.fcitx.Fcitx5.fcitx_mozc_alpha_full.png
42+
DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/48x48/apps")
43+
install(FILES ${MOZC_SOURCE_DIR}/../scripts/icons/ui-direct.png
44+
RENAME org.fcitx.Fcitx5.fcitx_mozc_direct.png
45+
DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/48x48/apps")
46+
install(FILES ${MOZC_SOURCE_DIR}/../scripts/icons/ui-hiragana.png
47+
RENAME org.fcitx.Fcitx5.fcitx_mozc_hiragana.png
48+
DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/48x48/apps")
49+
install(FILES ${MOZC_SOURCE_DIR}/../scripts/icons/ui-katakana_full.png
50+
RENAME org.fcitx.Fcitx5.fcitx_mozc_katakana_full.png
51+
DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/48x48/apps")
52+
install(FILES ${MOZC_SOURCE_DIR}/../scripts/icons/ui-katakana_half.png
53+
RENAME org.fcitx.Fcitx5.fcitx_mozc_katakana_half.png
54+
DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/48x48/apps")
55+
install(FILES ${MOZC_SOURCE_DIR}/../scripts/icons/ui-dictionary.png
56+
RENAME org.fcitx.Fcitx5.fcitx_mozc_dictionary.png
57+
DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/48x48/apps")
58+
install(FILES ${MOZC_SOURCE_DIR}/../scripts/icons/ui-properties.png
59+
RENAME org.fcitx.Fcitx5.fcitx_mozc_properties.png
60+
DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/48x48/apps")
61+
install(FILES ${MOZC_SOURCE_DIR}/../scripts/icons/ui-tool.png
62+
RENAME org.fcitx.Fcitx5.fcitx_mozc_tool.png
63+
DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/48x48/apps")
64+
65+
install(FILES icons/fcitx_mozc.png DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/128x128/apps")
66+
install(FILES icons/fcitx_mozc.png DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/32x32/apps")
67+
install(FILES
68+
icons/fcitx_mozc_alpha_full.png
69+
icons/fcitx_mozc_properties.png
70+
icons/fcitx_mozc_hiragana.png
71+
icons/fcitx_mozc_dictionary.png
72+
icons/fcitx_mozc_katakana_half.png
73+
icons/fcitx_mozc_alpha_half.png
74+
icons/fcitx_mozc_direct.png
75+
icons/fcitx_mozc_tool.png
76+
icons/fcitx_mozc_katakana_full.png
77+
DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/48x48/apps"
78+
)
79+
80+
file(GLOB PO_FILES "${MOZC_SOURCE_DIR}/unix/fcitx5/po/*.po")
81+
set(MO_FILES)
82+
foreach(PO_FILE IN LISTS PO_FILES)
83+
get_filename_component(PO_LANG ${PO_FILE} NAME_WE)
84+
get_filename_component(ABS_PO_FILE ${PO_FILE} ABSOLUTE)
85+
set(MO_FILE ${CMAKE_CURRENT_BINARY_DIR}/fcitx5-mozc-${PO_LANG}.mo)
86+
87+
add_custom_command(
88+
OUTPUT ${MO_FILE}
89+
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${MO_FILE} ${ABS_PO_FILE}
90+
DEPENDS ${ABS_PO_FILE}
91+
)
92+
93+
install(FILES ${MO_FILE} RENAME fcitx5-mozc.mo DESTINATION ${FCITX_INSTALL_LOCALEDIR}/${PO_LANG}/LC_MESSAGES
94+
COMPONENT translation)
95+
set(MO_FILES ${MO_FILES} ${MO_FILE})
96+
endforeach ()
97+
add_custom_target("fcitx5-mozc-translation" ALL DEPENDS ${MO_FILES})

fcitx/icons/fcitx_mozc.png

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.fcitx.Fcitx5.fcitx_mozc.png

fcitx/icons/fcitx_mozc_alpha_full.png

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.fcitx.Fcitx5.fcitx_mozc_alpha_full.png

fcitx/icons/fcitx_mozc_alpha_half.png

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.fcitx.Fcitx5.fcitx_mozc_alpha_half.png

fcitx/icons/fcitx_mozc_dictionary.png

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.fcitx.Fcitx5.fcitx_mozc_dictionary.png

fcitx/icons/fcitx_mozc_direct.png

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.fcitx.Fcitx5.fcitx_mozc_direct.png

fcitx/icons/fcitx_mozc_hiragana.png

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.fcitx.Fcitx5.fcitx_mozc_hiragana.png
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.fcitx.Fcitx5.fcitx_mozc_katakana_full.png
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.fcitx.Fcitx5.fcitx_mozc_katakana_half.png

fcitx/icons/fcitx_mozc_properties.png

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.fcitx.Fcitx5.fcitx_mozc_properties.png

fcitx/icons/fcitx_mozc_tool.png

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.fcitx.Fcitx5.fcitx_mozc_tool.png

gui/tool/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ target_link_libraries(mozc_tool
1313
word_register_dialog
1414
dictionary_tool
1515
)
16+
17+
install(TARGETS mozc_tool DESTINATION "${CMAKE_INSTALL_LIBDIR}/mozc")

server/CMakeLists.txt

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
add_executable(mozc_server
3+
${MOZC_SOURCE_DIR}/server/mozc_server.cc
4+
${MOZC_SOURCE_DIR}/server/mozc_server_main.cc
5+
)
6+
7+
target_link_libraries(mozc_server
8+
mozc::protocol::protocol
9+
mozc::base::system_util
10+
mozc::base::run_level
11+
mozc::base::init_mozc
12+
mozc::base::crash_report_handler
13+
mozc::base::process_mutex
14+
mozc::session::session_server
15+
config-stats_config_util
16+
)
17+
18+
install(TARGETS mozc_server DESTINATION "${CMAKE_INSTALL_LIBDIR}/mozc")

usage_stats/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ mozc_python_gen_file(usage_stats/gen_stats_list.py
77
add_custom_target(usage_state_list
88
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/usage_stats_list.inc
99
)
10+
set_target_properties(usage_state_list PROPERTIES EXCLUDE_FROM_ALL TRUE)
1011

1112
mozc_library(usage_stats.proto)
1213
mozc_library(usage_stats_uploader.cc DEPENDS mozc::storage::registry absl::strings)

0 commit comments

Comments
 (0)