diff --git a/app/src/main/jni/CMakeLists.txt b/app/src/main/jni/CMakeLists.txt index 1843035ff6..157f99410f 100644 --- a/app/src/main/jni/CMakeLists.txt +++ b/app/src/main/jni/CMakeLists.txt @@ -47,12 +47,9 @@ option(USE_SYSTEM_MARISA "" ON) add_subdirectory(OpenCC) include(OpenccWorkarounds) -include(RimePlugins) - set(X11Keysym "${CMAKE_SOURCE_DIR}/librime/include") include_directories("${X11Keysym}") -option(BUILD_TEST "" OFF) -add_subdirectory(librime) +include(Rime) add_subdirectory(librime_jni) diff --git a/app/src/main/jni/cmake/FindBoost.cmake b/app/src/main/jni/cmake/FindBoost.cmake index ea6339394a..16f320028f 100644 --- a/app/src/main/jni/cmake/FindBoost.cmake +++ b/app/src/main/jni/cmake/FindBoost.cmake @@ -1,20 +1,9 @@ set(Boost_FOUND TRUE) -list(TRANSFORM ${BOOST_INCLUDE_LIBRARIES} - PREPEND Boost:: +list(TRANSFORM BOOST_INCLUDE_LIBRARIES + PREPEND "Boost::" OUTPUT_VARIABLE Boost_LIBRARIES ) -if(NOT TARGET Boost::boost) - add_library(Boost::boost INTERFACE IMPORTED) - foreach(lib ${Boost_LIBRARIES}) - get_target_property(_include ${lib} INTERFACE_INCLUDE_DIRECTORIES) - list(APPEND includes ${_include}) - endforeach() - set_target_properties(Boost::boost PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${includes}" - ) -endif() - # for librime-charcode set(Boost_LOCALE_LIBRARIES Boost::locale) diff --git a/app/src/main/jni/cmake/Rime.cmake b/app/src/main/jni/cmake/Rime.cmake new file mode 100644 index 0000000000..361c11acb4 --- /dev/null +++ b/app/src/main/jni/cmake/Rime.cmake @@ -0,0 +1,40 @@ +# if you want to add some new plugins, add them to librime_jni/rime_jni.cc too +set(RIME_PLUGINS + librime-lua + librime-charcode + librime-octagram + librime-predict +) + +# librime-lua +file(REMOVE "${CMAKE_SOURCE_DIR}/librime/plugins/librime-lua/thirdparty") +file(CREATE_LINK + "${CMAKE_SOURCE_DIR}/librime-lua-deps" + "${CMAKE_SOURCE_DIR}/librime-lua/thirdparty/librime-lua-deps" + SYMBOLIC COPY_ON_ERROR +) + +# symlink plugins +foreach(plugin ${RIME_PLUGINS}) + file(CREATE_LINK + "${CMAKE_SOURCE_DIR}/${plugin}" + "${CMAKE_SOURCE_DIR}/librime/plugins/${plugin}" + SYMBOLIC COPY_ON_ERROR + ) +endforeach() + +# librime-charcode +option(BUILD_WITH_ICU "" OFF) + +option(BUILD_TEST "" OFF) +option(BUILD_STATIC "" ON) +add_subdirectory(librime) + +target_link_libraries(rime-charcode-objs + Boost::asio + Boost::locale +) + +target_link_libraries(rime-lua-objs + Boost::optional +) diff --git a/app/src/main/jni/cmake/RimePlugins.cmake b/app/src/main/jni/cmake/RimePlugins.cmake deleted file mode 100644 index 8d371755ab..0000000000 --- a/app/src/main/jni/cmake/RimePlugins.cmake +++ /dev/null @@ -1,38 +0,0 @@ -# if you want to add some new plugins, add them to librime_jni/rime_jni.cc too -set(RIME_PLUGINS - librime-lua - librime-charcode - librime-octagram - librime-predict -) - -# plugins didn't use target_link_libraries, the usage-requirements won't work, include manually -find_package(Boost) -get_target_property(PLUGIN_INCLUDES Boost::boost - INTERFACE_INCLUDE_DIRECTORIES -) -include_directories(${PLUGIN_INCLUDES}) - -# move plugins -file(GLOB old_plugin_files "librime/plugins/*") -foreach(file ${old_plugin_files}) - if(IS_DIRECTORY ${file}) # plugin is directory - file(REMOVE "${file}") - endif() -endforeach() -foreach(plugin ${RIME_PLUGINS}) - execute_process(COMMAND ln -s - "${CMAKE_SOURCE_DIR}/${plugin}" - "${CMAKE_SOURCE_DIR}/librime/plugins" - ) -endforeach() - -# librime-lua -file(REMOVE "${CMAKE_SOURCE_DIR}/librime/plugins/librime-lua/thirdparty") -execute_process(COMMAND ln -s - "${CMAKE_SOURCE_DIR}/librime-lua-deps" - "${CMAKE_SOURCE_DIR}/librime/plugins/librime-lua/thirdparty" -) - -# librime-charcode -option(BUILD_WITH_ICU "" OFF)