diff options
author | Brad King <brad.king@kitware.com> | 2016-01-20 13:33:32 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2016-01-20 13:33:32 (GMT) |
commit | 606ad1764ee8aff62368878576ecec7dd8671bae (patch) | |
tree | 07289139ce41c35acfcd51ac348ddb07e29917d0 | |
parent | 211d097998da4b730213645af4767fc24015f397 (diff) | |
parent | 18c3714f4f4cf35f2b040d887850cb3607345e5d (diff) | |
download | CMake-606ad1764ee8aff62368878576ecec7dd8671bae.zip CMake-606ad1764ee8aff62368878576ecec7dd8671bae.tar.gz CMake-606ad1764ee8aff62368878576ecec7dd8671bae.tar.bz2 |
Merge topic 'java-updates'
18c3714f UseJava: Fix create_javah CLASSPATH handling on Windows
-rw-r--r-- | Modules/UseJava.cmake | 4 | ||||
-rw-r--r-- | Tests/JavaJavah/C.cpp | 10 | ||||
-rw-r--r-- | Tests/JavaJavah/C.java | 19 | ||||
-rw-r--r-- | Tests/JavaJavah/CMakeLists.txt | 9 | ||||
-rw-r--r-- | Tests/JavaJavah/HelloWorld2.java | 5 |
5 files changed, 42 insertions, 5 deletions
diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index 6146d78..adaba02 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -1212,7 +1212,7 @@ function (create_javah) set (_output_files) if (WIN32 AND NOT CYGWIN AND CMAKE_HOST_SYSTEM_NAME MATCHES "Windows") - set(_classpath_sep ";") + set(_classpath_sep "$<SEMICOLON>") else () set(_classpath_sep ":") endif() @@ -1242,7 +1242,7 @@ function (create_javah) endif() endforeach() string (REPLACE ";" "${_classpath_sep}" _classpath "${_classpath}") - list (APPEND _javah_options -classpath ${_classpath}) + list (APPEND _javah_options -classpath "${_classpath}") endif() if (_create_javah_OUTPUT_DIR) diff --git a/Tests/JavaJavah/C.cpp b/Tests/JavaJavah/C.cpp new file mode 100644 index 0000000..ec75f42 --- /dev/null +++ b/Tests/JavaJavah/C.cpp @@ -0,0 +1,10 @@ + +#include <jni.h> +#include <stdio.h> + +#include "C.h" + +JNIEXPORT void JNICALL Java_C_printName(JNIEnv *, jobject) +{ + printf("C\n"); +} diff --git a/Tests/JavaJavah/C.java b/Tests/JavaJavah/C.java new file mode 100644 index 0000000..54b1be2 --- /dev/null +++ b/Tests/JavaJavah/C.java @@ -0,0 +1,19 @@ +class C +{ + public C() + { + } + + public native void printName(); + + static { + try { + + System.loadLibrary("B"); + + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load.\n" + e); + System.exit(1); + } + } +} diff --git a/Tests/JavaJavah/CMakeLists.txt b/Tests/JavaJavah/CMakeLists.txt index 83b0ad0..071bf20 100644 --- a/Tests/JavaJavah/CMakeLists.txt +++ b/Tests/JavaJavah/CMakeLists.txt @@ -9,10 +9,13 @@ include (UseJava) # JNI support find_package(JNI) -add_jar(hello3 B.java HelloWorld2.java) -create_javah(TARGET B_javah CLASSES B CLASSPATH hello3) +add_jar(B1 B.java) +add_jar(C1 C.java) +create_javah(TARGET B_javah CLASSES B C CLASSPATH B1 C1) -add_library(B SHARED B.cpp) +add_jar(hello3 HelloWorld2.java) + +add_library(B SHARED B.cpp C.cpp) add_dependencies(B B_javah) target_include_directories(B PRIVATE ${CMAKE_CURRENT_BINARY_DIR} diff --git a/Tests/JavaJavah/HelloWorld2.java b/Tests/JavaJavah/HelloWorld2.java index faf7277..5ff710f 100644 --- a/Tests/JavaJavah/HelloWorld2.java +++ b/Tests/JavaJavah/HelloWorld2.java @@ -5,6 +5,11 @@ class HelloWorld2 B b; b = new B(); b.printName(); + + C c; + c = new C(); + c.printName(); + System.out.println("Hello World!"); } } |