I am working on an algorithm library that provides pre-compiled .so file for an Android application. We want to use PyTorch C++ API in our library so I put some effort on it. However I encountered some problems when trying to build with CMake.
Building works well without using android.cmake.toolchain
provided in the NDK, and the compiled program behaves as expected. Things go wrong when I try to use android.cmake.toolchain
to build library, the following two lines in TorchConfig.cmake
(this file is provided by Torch) went wrong weirdly:
find_package(Caffe2 REQUIRED PATHS ${CMAKE_CURRENT_LIST_DIR}/../Caffe2) [Line 40]
find_library(C10_LIBRARY c10 PATHS "${TORCH_INSTALL_PREFIX}/lib") [Line 47]
Although those commands used PATHS
to specify absolute path, CMake insists that those package and library cannot be found. I tried use message
to print out those path and check, the files CMaKe should be looking for (Caffe2Config.cmake
and libc10.so
) do exist in the path specified.
I am aware that android toolchain will change the compilers to be used (to bundled clang), but I cannot see the reason why cmake behaves oddly in my case.