-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
206 lines (185 loc) · 5.43 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
cmake_minimum_required(VERSION 3.27)
project(fcitx5-plugins VERSION 0.1.0)
option(ANTHY "" ON)
option(BAMBOO "" ON)
option(CHEWING "" ON)
option(CHINESE_ADDONS "" ON)
option(HALLELUJAH "" ON)
option(HANGUL "" ON)
option(MOZC "" ON)
option(RIME "" ON)
option(SAYURA "" ON)
option(SKK "" ON)
option(TABLE_EXTRA "" ON)
option(THAI "" ON)
option(UNIKEY "" ON)
list(PREPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
set(CMAKE_INSTALL_PREFIX /usr)
set(FIND_ROOT_PATH "${PROJECT_BINARY_DIR}/usr")
set(PREBUILDER_INCLUDE_DIR "${FIND_ROOT_PATH}/include")
set(PREBUILDER_LIB_DIR "${FIND_ROOT_PATH}/lib")
set(ENV{PKG_CONFIG_SYSROOT_DIR} "${PROJECT_BINARY_DIR}")
set(ENV{PKG_CONFIG_PATH} "${PREBUILDER_LIB_DIR}/pkgconfig")
# We don't build testing frontends so fake it.
set(Fcitx5ModuleTestFrontend_DIR "${PROJECT_SOURCE_DIR}/cmake")
if (APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET 13) # Also need to update CGO_CFLAGS
set(APP_CONTENTS_PATH "/Library/Input Methods/Fcitx5.app/Contents")
set(CMAKE_FIND_ROOT_PATH
"${APP_CONTENTS_PATH}"
"${FIND_ROOT_PATH}"
)
elseif (EMSCRIPTEN)
list(PREPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/js")
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-sSIDE_MODULE")
set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-sSIDE_MODULE")
add_compile_options(-fPIC -fexceptions)
list(PREPEND CMAKE_FIND_ROOT_PATH "${FIND_ROOT_PATH}")
option(ENABLE_DATA "" OFF)
option(ENABLE_TOOLS "" OFF)
else()
message(FATAL_ERROR "Unsupported platform")
endif()
# Shared by some fcitx5 engines
option(ENABLE_TEST "" OFF)
option(ENABLE_QT "" OFF)
option(ENABLE_GUI "" OFF)
# anthy
if (ANTHY)
add_subdirectory(fcitx5-anthy)
endif()
# bamboo
if (BAMBOO)
if (NOT EMSCRIPTEN) # https://github.com/golang/go/issues/55351
add_subdirectory(fcitx5-bamboo)
endif()
endif()
# chewing
if (CHEWING)
add_subdirectory(fcitx5-chewing)
endif()
# lua and chinese-addons
if (CHINESE_ADDONS)
option(USE_DLOPEN "" OFF)
add_subdirectory(fcitx5-lua)
option(BUILD_SHARED_LIBS "" OFF)
add_subdirectory(libime)
# suppress configure error
install(TARGETS kenlm EXPORT LibIMECoreTargets LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib)
set(LIBIME_INSTALL_PKGDATADIR "../libime")
if (APPLE)
set(CMAKE_INSTALL_RPATH "${APP_CONTENTS_PATH}/lib") # scel2org5
elseif (EMSCRIPTEN)
option(ENABLE_CLOUDPINYIN "" OFF)
endif()
add_subdirectory(fcitx5-chinese-addons)
target_link_libraries(chttrans "${PREBUILDER_LIB_DIR}/libmarisa.a")
if (EMSCRIPTEN)
# Wherever exception is caught there must be explicit link option.
target_link_libraries(pinyin -fexceptions)
target_link_libraries(table -fexceptions)
target_link_libraries(chttrans -fexceptions)
target_link_libraries(pinyinhelper -fexceptions)
target_link_libraries(punctuation -fexceptions)
endif()
endif()
# hallelujah
if (HALLELUJAH)
add_subdirectory(fcitx5-hallelujah)
endif()
# hangul
if (HANGUL)
add_library(Hangul_static STATIC IMPORTED)
set_target_properties(Hangul_static PROPERTIES
IMPORTED_LOCATION "${PREBUILDER_LIB_DIR}/libhangul.a"
INTERFACE_INCLUDE_DIRECTORIES "${PREBUILDER_INCLUDE_DIR}/hangul-1.0"
)
set(HANGUL_TARGET Hangul_static)
add_subdirectory(fcitx5-hangul)
endif()
# mozc
if (MOZC)
set(MOZC_TARGET
"-L${PREBUILDER_LIB_DIR}"
"-lmozc-static"
"-lutf8_validity"
"-lprotobuf"
"-labsl"
)
if (APPLE)
list(APPEND MOZC_TARGET "-Wl,-framework,CoreFoundation")
endif()
add_subdirectory(fcitx5-mozc)
target_include_directories(mozc PRIVATE "${PREBUILDER_INCLUDE_DIR}/mozc")
if (EMSCRIPTEN)
target_include_directories(mozc PRIVATE
"${PREBUILDER_INCLUDE_DIR}"
"${PREBUILDER_INCLUDE_DIR}/Fcitx5/Module"
)
endif()
endif()
# rime
if (RIME)
set(Rime_VERSION 1.12)
# RIME_DATA_DIR is not actually used on macOS but must exist.
set(RIME_DATA_DIR "/usr/share/rime-data")
set(Rime_dependencies
"-L${PREBUILDER_LIB_DIR}"
"-lleveldb"
"-lyaml-cpp"
"-lmarisa"
"-lopencc"
"-lglog"
"-llua"
)
add_library(Rime_static STATIC IMPORTED)
set_target_properties(Rime_static PROPERTIES
IMPORTED_LOCATION "${PREBUILDER_LIB_DIR}/librime.a"
INTERFACE_INCLUDE_DIRECTORIES "${PREBUILDER_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${Rime_dependencies}"
)
# plugins use __attribute__((constructor))
set(RIME_TARGET $<LINK_LIBRARY:WHOLE_ARCHIVE,Rime_static>)
add_subdirectory(fcitx5-rime)
if (APPLE)
target_link_options(rime PUBLIC
LINKER:-U,_f5m_is_linear_layout
LINKER:-U,_f5m_is_vertical_rl
LINKER:-U,_f5m_is_vertical_lr
)
endif()
endif()
# sayura
if (SAYURA)
add_subdirectory(fcitx5-sayura)
endif()
# skk
if (SKK)
if (NOT EMSCRIPTEN)
set(SKK_DEFAULT_PATH "$XDG_DATA_DIRS/skk/SKK-JISYO.L" CACHE STRING "")
add_subdirectory(fcitx5-skk)
target_include_directories(skk PRIVATE "${PREBUILDER_INCLUDE_DIR}/gee-0.8")
target_link_libraries(skk "-L${PREBUILDER_LIB_DIR}" -lgee-0.8 -lffi -lgio-2.0 -lgmodule-2.0 -ljson-glib-1.0 -lz -lresolv)
endif()
endif()
# table-extra
if (TABLE_EXTRA)
if (APPLE) # Universal so unnecessary on other platforms.
add_subdirectory(fcitx5-table-extra)
endif()
endif()
# thai
if (THAI)
add_library(Thai_static STATIC IMPORTED)
set_target_properties(Thai_static PROPERTIES
IMPORTED_LOCATION "${PREBUILDER_LIB_DIR}/libthai.a"
INTERFACE_INCLUDE_DIRECTORIES "${PREBUILDER_INCLUDE_DIR}"
)
set(THAI_TARGET Thai_static)
add_subdirectory(fcitx5-thai)
endif()
# unikey
if (UNIKEY)
add_subdirectory(fcitx5-unikey)
endif()