I created an Android Studio project that calls c++ code using the JNI. My project worked until I tried to add a package to my project in my CMake file using VCPKG. My CMakeList.txt looks like this:
cmake_minimum_required(VERSION 3.18.1)
**set(CMAKE_TOOLCHAIN_FILE C:/vcpkg/scripts/buildsystems/vcpkg.cmake)**
project("deepsudoku")
**find_package(frugally-deep CONFIG REQUIRED)**
**target_link_libraries(main PRIVATE frugally-deep::fdeep)**
include_directories(${OpenCV_DIR}/jni/include)
add_library( lib_opencv SHARED IMPORTED )
set_target_properties(lib_opencv PROPERTIES IMPORTED_LOCATION ${OpenCV_DIR}/libs/${ANDROID_ABI}/libopencv_java4.so)
add_library(deepsudoku SHARED native-lib.cpp utils.cpp imageProcessing.cpp HoughAccumulator.cpp)
find_library(log-lib log)
target_link_libraries(deepsudoku PRIVATE -ljnigraphics lib_opencv ${jnigraphic-lib} ${log-lib})
The project was building fine until I added the lines marked by **. Now when I try to build the project, I get a CMake Error in CMakeSystem.cmake located in app/.cxx/Debug/u3j6s5y3/arm64-v8a/CMakeFiles/3.18.1-g262b901-dirty/CMakeSystem.cmake. The file looks like this.
set(CMAKE_HOST_SYSTEM "Windows-10.0.19045")
set(CMAKE_HOST_SYSTEM_NAME "Windows")
set(CMAKE_HOST_SYSTEM_VERSION "10.0.19045")
set(CMAKE_HOST_SYSTEM_PROCESSOR "AMD64")
include("C:/vcpkg/scripts/buildsystems/vcpkg.cmake")
set(CMAKE_SYSTEM "Android-28")
set(CMAKE_SYSTEM_NAME "Android")
set(CMAKE_SYSTEM_VERSION "28")
set(CMAKE_SYSTEM_PROCESSOR "aarch64")
**set(CMAKE_ANDROID_NDK "C:\Android\Sdk\ndk\21.4.7075529")**
set(CMAKE_ANDROID_STANDALONE_TOOLCHAIN "")
set(CMAKE_ANDROID_ARCH "arm64")
set(CMAKE_ANDROID_ARCH_ABI "arm64-v8a")
set(CMAKE_ANDROID_ARCH_TRIPLE "aarch64-linux-android")
set(CMAKE_ANDROID_NDK_DEPRECATED_HEADERS "0")
set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG "windows-x86_64")
**set(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED "C:\Android\Sdk\ndk\21.4.7075529/toolchains/llvm/prebuilt/windows-x86_64")
**
set(CMAKE_CROSSCOMPILING "TRUE")
set(CMAKE_SYSTEM_LOADED 1)
I get a syntax error while passing the strings in the lines marked by **(Invalid character escape '\A'). The syntax error emerges because there are backslashes instead of forward slashes in the path of the Android NDK. I tried to change the path by hand, but the file seems to be generated by Android Studio because the file is always reset when I build the project and the same error arises. I also tried to change path of the NDK in the Project Structure section and tried to add a different path by adding ndk.dir to the local.properties file. The actual path of the NDK changes, but it always uses backslashes and the same error while parsing the path is thrown. Is there a way to change the backslashes to forward slashes in the path so that the sting can be parsed? Or is there another to avoid this error?