diff options
-rw-r--r-- | Modules/FindJNI.cmake | 2 | ||||
-rw-r--r-- | Modules/FindJava.cmake | 4 | ||||
-rw-r--r-- | Tests/CMakeLists.txt | 50 | ||||
-rw-r--r-- | Tests/Java/CMakeLists.txt | 9 | ||||
-rw-r--r-- | Tests/JavaJavah/CMakeLists.txt | 5 | ||||
-rw-r--r-- | Tests/JavaNativeHeaders/CMakeLists.txt | 6 |
6 files changed, 30 insertions, 46 deletions
diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake index 237ea96..3a5bd31 100644 --- a/Modules/FindJNI.cmake +++ b/Modules/FindJNI.cmake @@ -143,7 +143,7 @@ endif() if (WIN32) set (_JNI_HINTS) - execute_process(COMMAND REG QUERY HKLM\\SOFTWARE\\JavaSoft\\JDK /f "." /k + execute_process(COMMAND REG QUERY HKLM\\SOFTWARE\\JavaSoft\\JDK RESULT_VARIABLE _JNI_RESULT OUTPUT_VARIABLE _JNI_VERSIONS ERROR_QUIET) diff --git a/Modules/FindJava.cmake b/Modules/FindJava.cmake index 0d62cd6..945df3c 100644 --- a/Modules/FindJava.cmake +++ b/Modules/FindJava.cmake @@ -85,7 +85,7 @@ if(_JAVA_HOME) endif() if (WIN32) macro (_JAVA_GET_INSTALLED_VERSIONS _KIND) - execute_process(COMMAND REG QUERY HKLM\\SOFTWARE\\JavaSoft\\${_KIND} /f "." /k + execute_process(COMMAND REG QUERY HKLM\\SOFTWARE\\JavaSoft\\${_KIND} RESULT_VARIABLE _JAVA_RESULT OUTPUT_VARIABLE _JAVA_VERSIONS ERROR_QUIET) @@ -153,7 +153,7 @@ find_program(Java_JAVA_EXECUTABLE ) if(Java_JAVA_EXECUTABLE) - execute_process(COMMAND ${Java_JAVA_EXECUTABLE} -version + execute_process(COMMAND "${Java_JAVA_EXECUTABLE}" -version RESULT_VARIABLE res OUTPUT_VARIABLE var ERROR_VARIABLE var # sun-java output to stderr diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 789fc0e..ed20b91 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -3349,81 +3349,45 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH if(JNI_H AND EXISTS "${JNI_H}") # in case jni.h is a broken symlink file(READ "${JNI_H}" JNI_FILE) if("${JNI_FILE}" MATCHES "JDK1_2") - add_test(Java.Jar ${CMAKE_CTEST_COMMAND} + add_test(NAME Java.Jar COMMAND ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/Java" "${CMake_BINARY_DIR}/Tests/JavaJar" ${build_generator_args} --build-project hello - --build-target hello - --build-two-config --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJar/" - --test-command ${JAVA_RUNTIME} -classpath hello.jar HelloWorld) + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIG>) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJar") - add_test(Java.JarSourceList ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/Java" - "${CMake_BINARY_DIR}/Tests/JavaJarSourceList" - ${build_generator_args} - --build-project hello - --build-target hello2 - --build-two-config - --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJarSourceList/" - --test-command ${JAVA_RUNTIME} -classpath hello2.jar HelloWorld) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJarSourceList") - add_test(Java.JarSourceListAndOutput ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/Java" - "${CMake_BINARY_DIR}/Tests/JavaJarSourceListAndOutput" - ${build_generator_args} - --build-project hello - --build-target hello3 - --build-two-config - --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJarSourceListAndOutput/hello3" - --test-command ${JAVA_RUNTIME} -classpath hello3.jar HelloWorld) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJarSourceListAndOutput") # For next tests, java tool must have same architecture as toolchain math(EXPR _object_mode "${CMAKE_SIZEOF_VOID_P} * 8") execute_process( - COMMAND "${Java_JAVA_EXECUTABLE}" -d${_object_mode} -version - OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE _result + COMMAND "${Java_JAVA_EXECUTABLE}" -version + OUTPUT_VARIABLE _version ERROR_VARIABLE _version RESULT_VARIABLE _result ) - if(_result EQUAL 0) + if(_result EQUAL 0 AND _version MATCHES "${_object_mode}-Bit") ## next test is valid only if Java version is less than 1.10 if ("${Java_VERSION}" VERSION_LESS 1.10) - if(_isMultiConfig) - set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah/$<CONFIGURATION>) - else() - set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah) - endif() add_test(NAME Java.Javah COMMAND ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/JavaJavah" "${CMake_BINARY_DIR}/Tests/JavaJavah" ${build_generator_args} --build-project helloJavah - --build-two-config --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJavah/" - --test-command ${JAVA_RUNTIME} -Djava.library.path=${JAVAH_LIBRARY_PATH} -classpath hello3.jar HelloWorld2) + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIG>) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJavah") endif() ## next test is valid only if Java is, at least, version 1.8 if (NOT "${Java_VERSION}" VERSION_LESS 1.8) - if(_isMultiConfig) - set (JAVANATIVEHEADERS_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaNativeHeaders/$<CONFIGURATION>) - else() - set (JAVANATIVEHEADERS_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaNativeHeaders) - endif() add_test(NAME Java.NativeHeaders COMMAND ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/JavaNativeHeaders" "${CMake_BINARY_DIR}/Tests/JavaNativeHeaders" ${build_generator_args} --build-project helloJavaNativeHeaders - --build-two-config --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaNativeHeaders/" - --test-command ${JAVA_RUNTIME} -Djava.library.path=${JAVANATIVEHEADERS_LIBRARY_PATH} -classpath hello4.jar HelloWorld3) + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIG>) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaNativeHeaders") endif() endif() diff --git a/Tests/Java/CMakeLists.txt b/Tests/Java/CMakeLists.txt index 0b8269b..aea4282 100644 --- a/Tests/Java/CMakeLists.txt +++ b/Tests/Java/CMakeLists.txt @@ -3,6 +3,8 @@ project(hello Java) cmake_minimum_required (VERSION 2.6) set(CMAKE_VERBOSE_MAKEFILE 1) +include(CTest) + find_package(Java COMPONENTS Development) include (UseJava) @@ -14,3 +16,10 @@ add_jar(hello2 @${CMAKE_CURRENT_BINARY_DIR}/java_fileslist) # use listing file to specify sources and specify output directory (issue #17316) add_jar(hello3 @${CMAKE_CURRENT_BINARY_DIR}/java_fileslist OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/hello3") + +add_test (NAME Java.Jar + COMMAND "${Java_JAVA_EXECUTABLE}" -classpath hello.jar HelloWorld) +add_test (NAME Java.JarSourceList + COMMAND "${Java_JAVA_EXECUTABLE}" -classpath hello2.jar HelloWorld) +add_test (NAME Java.JarSourceListAndOutput + COMMAND "${Java_JAVA_EXECUTABLE}" -classpath "${CMAKE_CURRENT_BINARY_DIR}/hello3/hello3.jar" HelloWorld) diff --git a/Tests/JavaJavah/CMakeLists.txt b/Tests/JavaJavah/CMakeLists.txt index 071bf20..77c292a 100644 --- a/Tests/JavaJavah/CMakeLists.txt +++ b/Tests/JavaJavah/CMakeLists.txt @@ -3,6 +3,8 @@ project(helloJavah Java CXX) cmake_minimum_required (VERSION 2.6) set(CMAKE_VERBOSE_MAKEFILE 1) +include(CTest) + find_package(Java COMPONENTS Development) include (UseJava) @@ -21,3 +23,6 @@ add_dependencies(B B_javah) target_include_directories(B PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2}) + +add_test (NAME Java.Javah + COMMAND "${Java_JAVA_EXECUTABLE}" -Djava.library.path=$<TARGET_FILE_DIR:B> -classpath hello3.jar HelloWorld2) diff --git a/Tests/JavaNativeHeaders/CMakeLists.txt b/Tests/JavaNativeHeaders/CMakeLists.txt index 7dc2679..2023d25 100644 --- a/Tests/JavaNativeHeaders/CMakeLists.txt +++ b/Tests/JavaNativeHeaders/CMakeLists.txt @@ -3,6 +3,8 @@ project(helloJavaNativeHeaders Java CXX) cmake_minimum_required (VERSION 2.6) set(CMAKE_VERBOSE_MAKEFILE 1) +include (CTest) + find_package(Java COMPONENTS Development) include (UseJava) @@ -16,3 +18,7 @@ add_jar(hello4 HelloWorld3.java) add_library(D SHARED D.cpp E.cpp) target_link_libraries (D PRIVATE D1-native E1-native) + + +add_test (NAME Java.NativeHeaders + COMMAND "${Java_JAVA_EXECUTABLE}" -Djava.library.path=$<TARGET_FILE_DIR:D> -classpath hello4.jar HelloWorld3) |