From 769d2d8a370a99f25750b900df5a88741cc75834 Mon Sep 17 00:00:00 2001 From: WhiredPlanck Date: Mon, 13 Nov 2023 23:50:20 +0800 Subject: [PATCH] build(jni): more neat way to find headers --- app/src/main/jni/CMakeLists.txt | 9 ++------- app/src/main/jni/cmake/FindGlog.cmake | 1 + app/src/main/jni/cmake/FindOpencc.cmake | 2 +- app/src/main/jni/cmake/OpenccWorkarounds.cmake | 10 ---------- 4 files changed, 4 insertions(+), 18 deletions(-) delete mode 100644 app/src/main/jni/cmake/OpenccWorkarounds.cmake diff --git a/app/src/main/jni/CMakeLists.txt b/app/src/main/jni/CMakeLists.txt index b84a05d99e..0ae01bf274 100644 --- a/app/src/main/jni/CMakeLists.txt +++ b/app/src/main/jni/CMakeLists.txt @@ -7,6 +7,8 @@ set(CMAKE_CXX_STANDARD 14) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) +set(CMAKE_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/librime/include") + # general options option(BUILD_SHARED_LIBS "" OFF) option(BUILD_TESTING "" OFF) @@ -53,17 +55,10 @@ option(LEVELDB_INSTALL "" OFF) add_subdirectory(librime/deps/leveldb) add_subdirectory(OpenCC) -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" -) - add_subdirectory(librime) add_subdirectory(librime_jni) diff --git a/app/src/main/jni/cmake/FindGlog.cmake b/app/src/main/jni/cmake/FindGlog.cmake index f3a16b2796..028759ea4b 100644 --- a/app/src/main/jni/cmake/FindGlog.cmake +++ b/app/src/main/jni/cmake/FindGlog.cmake @@ -1,2 +1,3 @@ set(Glog_FOUND TRUE) set(Glog_LIBRARY glog) +set(Glog_INCLUDE_PATH "${CMAKE_BINARY_DIR}/librime/deps/glog" "${CMAKE_SOURCE_DIR}/librime/deps/glog/src") \ No newline at end of file diff --git a/app/src/main/jni/cmake/FindOpencc.cmake b/app/src/main/jni/cmake/FindOpencc.cmake index bcb9ca3e0f..5e2a6cbdb8 100644 --- a/app/src/main/jni/cmake/FindOpencc.cmake +++ b/app/src/main/jni/cmake/FindOpencc.cmake @@ -1,3 +1,3 @@ set(Opencc_FOUND TRUE) set(Opencc_LIBRARY libopencc) -set(Opencc_INCLUDE_PATH "${CMAKE_BINARY_DIR}/include") +set(Opencc_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/OpenCC/src" "${CMAKE_BINARY_DIR}/OpenCC/src") diff --git a/app/src/main/jni/cmake/OpenccWorkarounds.cmake b/app/src/main/jni/cmake/OpenccWorkarounds.cmake deleted file mode 100644 index 6a4e3ead36..0000000000 --- a/app/src/main/jni/cmake/OpenccWorkarounds.cmake +++ /dev/null @@ -1,10 +0,0 @@ -# install opencc headers manually -file(GLOB LIBOPENCC_HEADERS - OpenCC/src/*.hpp - OpenCC/src/*.h - "${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()