Skip to content

Commit

Permalink
build(jni): more neat way to find headers
Browse files Browse the repository at this point in the history
  • Loading branch information
WhiredPlanck committed Nov 15, 2023
1 parent db1581f commit 5bd4b60
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 17 deletions.
9 changes: 3 additions & 6 deletions app/src/main/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,10 @@ include(OpenccWorkarounds)

include(RimePlugins)

option(BUILD_TEST "" OFF)
include_directories(
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/librime/include"
PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/librime/deps/glog"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/librime/deps/glog/src"
)
set(X11Keysym "${CMAKE
_SOURCE_DIR}/librime/include")

option(BUILD_TEST "" OFF)
add_subdirectory(librime)

add_subdirectory(librime_jni)
2 changes: 2 additions & 0 deletions app/src/main/jni/cmake/FindGlog.cmake
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
set(Glog_FOUND TRUE)
set(Glog_LIBRARY glog)
get_target_property(Glog_INCLUDE_PATH glog::glog
INTERFACE_INCLUDE_DIRECTORIES)
2 changes: 1 addition & 1 deletion app/src/main/jni/cmake/FindYamlCpp.cmake
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
set(YamlCpp_FOUNT TRUE)
set(YamlCpp_FOUND TRUE)
set(YamlCpp_LIBRARY yaml-cpp)
13 changes: 5 additions & 8 deletions app/src/main/jni/cmake/OpenccWorkarounds.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# install opencc headers manually
# Since OpenCC doesn't include its headers in the binary dir,
# we need to install them manually.
file(GLOB LIBOPENCC_HEADERS
OpenCC/src/*.hpp
OpenCC/src/*.h
"${CMAKE_BINARY_DIR}/OpenCC/src/opencc_config.h"
OpenCC/src/*.hpp
"${CMAKE_BINARY_DIR}/OpenCC/src/opencc_config.h"
)
make_directory("${CMAKE_BINARY_DIR}/include/opencc")
foreach(header ${LIBOPENCC_HEADERS})
configure_file(${header} "${CMAKE_BINARY_DIR}/include/opencc" COPYONLY)
endforeach()
file(COPY ${LIBOPENCC_HEADERS} DESTINATION "${CMAKE_BINARY_DIR}/include/opencc")
4 changes: 2 additions & 2 deletions app/src/main/jni/librime_jni/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
find_package(Opencc REQUIRED)

file(GLOB RIME_JNI_SOURCES
set(RIME_JNI_SOURCES
key_table.cc
levers.cc
opencc.cc
rime_jni.cc
)
add_library(rime_jni SHARED ${RIME_JNI_SOURCES})
target_link_libraries(rime_jni log rime-static ${Opencc_LIBRARY})
target_include_directories(rime_jni PRIVATE
"${CMAKE_SOURCE_DIR}/librime/src"
"${Opencc_INCLUDE_PATH}"
)
target_link_libraries(rime_jni rime-static log ${Opencc_LIBRARY})

string(TIMESTAMP TODAY "%Y%m%d")
execute_process(
Expand Down

0 comments on commit 5bd4b60

Please sign in to comment.