]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: use javac -h for creating JNI native headers
authorKefu Chai <kchai@redhat.com>
Fri, 4 May 2018 14:32:35 +0000 (22:32 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 4 May 2018 14:34:57 +0000 (22:34 +0800)
JDK 1.10 does not offer javah anymore, so we need to use "javac -h" or
add_jar(... GENERATE_NATIVE_HEADERS) instead.

Fixes: http://tracker.ceph.com/issues/24012
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/java/CMakeLists.txt

index fe365501de9e4736f9a584a0c67e4e1944e5fcc7..b4cb3f84932702bd348d8e9cdc1255c850c5b531 100644 (file)
@@ -22,18 +22,21 @@ set(java_srcs
 # 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(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