How to use FIND_JNI on cmake

2019-03-23 11:51发布

I'm trying to write a build for my project where I'm trying to replace autobuild, and I need to proper use FIND_JNI.

I could make a simple build but it's not properly finding jni.h

And I need to find a proper way (without a hack) to define the Java include as this needs to be portable to other users.

1条回答
神经病院院长
2楼-- · 2019-03-23 12:27

The following code works for me. In your root CMakeLists.txt file add:

find_package(JNI)

if (JNI_FOUND)
    message (STATUS "JNI_INCLUDE_DIRS=${JNI_INCLUDE_DIRS}")
    message (STATUS "JNI_LIBRARIES=${JNI_LIBRARIES}")
endif()
查看更多
登录 后发表回答