In my CMAKE project I use currently the source code to compile a library and finaly use it to link with an JNI Library. I want to remove now the build step for my library FoxSDKCore and just to build the JNI library and link it with the prebuild FoxSDKCore.
My script looks currently like:
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html
# Sets the minimum version of CMake required to build the native library.
cmake_minimum_required(VERSION 3.4.1)
set(PATH_TO_FOXSDK "~/Downloads/fosdkcore")
message(${PATH_TO_FOXSDK})
add_definitions(-DLINUX)
add_definitions(-D_FILE_OFFSET_BITS=64)
set( CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++" )
set(CMAKE_BUILD_TYPE Debug)
include_directories(${PATH_TO_FOXSDK}/Include)
include_directories(${PATH_TO_FOXSDK}/Development/winhdrs)
include_directories(${PATH_TO_FOXSDK}/Development/SDK)
find_package(JNI)
if (JNI_FOUND)
message (STATUS "JNI_INCLUDE_DIRS=${JNI_INCLUDE_DIRS}")
message (STATUS "JNI_LIBRARIES=${JNI_LIBRARIES}")
endif()
include_directories(${JNI_INCLUDE_DIRS})
set(fox_files
${PATH_TO_FOXSDK}/Development/SDK/CallBacks.h
...
)
add_library(FoxSDKCore
SHARED
${fox_files})
add_library( # Sets the name of the library.
JNIViie
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
JNIViie.cpp
)
target_link_libraries(FoxSDKCore
${CMAKE_THREAD_LIBS_INIT}
)
target_link_libraries( # Specifies the target library.
JNIViie
FoxSDKCore)
As far as I understand I have to set the IMPORTED flag, so I use
add_library(FoxSDKCore
SHARED
IMPORTED)
add_library( # Sets the name of the library.
JNIViie
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
JNIViie.cpp
)
target_link_libraries( # Specifies the target library.
JNIViie
FoxSDKCore)
But this will fail. Any hint how to link the existing library?