Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: use javac -h for creating JNI native headers #21822

Merged
merged 2 commits into from May 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 15 additions & 12 deletions src/java/CMakeLists.txt
Expand Up @@ -21,19 +21,22 @@ set(java_srcs
# warning: [options] bootstrap class path not set in conjunction with -source 1.7
# as per
# https://blogs.oracle.com/darcy/entry/bootclasspath_older_source
set(CMAKE_JAVA_COMPILE_FLAGS "-source" "1.7" "-target" "1.7" "-Xlint:-options")
add_jar(libcephfs ${java_srcs})
install_jar(libcephfs share/java)
set(CMAKE_JAVA_COMPILE_FLAGS "-source" "1.8" "-target" "1.8" "-Xlint:-options")
set(jni_header_dir "${CMAKE_CURRENT_BINARY_DIR}/native")
if(CMAKE_VERSION VERSION_LESS 3.11)
set(CMAKE_JAVA_COMPILE_FLAGS ${CMAKE_JAVA_COMPILE_FLAGS} "-h" ${jni_header_dir})
add_jar(libcephfs ${java_srcs})
add_custom_target(
jni-header
DEPENDS libcephfs)
add_dependencies(jni-header libcephfs)
else()
add_jar(libcephfs ${java_srcs}
GENERATE_NATIVE_HEADERS jni-header
DESTINATION ${jni_header_dir})
endif()
get_property(libcephfs_jar TARGET libcephfs PROPERTY JAR_FILE)

set(java_h native/com_ceph_fs_CephMount.h)
add_custom_command(
OUTPUT ${java_h}
COMMAND ${Java_JAVAH_EXECUTABLE} -classpath ${libcephfs_jar} -jni -o ${CMAKE_CURRENT_BINARY_DIR}/${java_h} com.ceph.fs.CephMount)
add_custom_target(
jni-header
DEPENDS ${java_h})
add_dependencies(jni-header libcephfs)
install_jar(libcephfs share/java)

find_jar(JUNIT_JAR
NAMES junit4 junit
Expand Down