summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-01-05 14:02:06 (GMT)
committerKitware Robot <kwrobot@kitware.com>2021-01-05 14:02:12 (GMT)
commit522015e04f2fc22ba4e58ddf94fa035bc6dc9c85 (patch)
tree5b7dbc399aa89fb73545573ed9344b0dafb0d9bf /Tests
parent78c95e5a1cf00afd222e2cfcaebd7bb38ce71d4e (diff)
parent53235626a2b7d2c07e0e50339a4039a4f5e03001 (diff)
downloadCMake-522015e04f2fc22ba4e58ddf94fa035bc6dc9c85.zip
CMake-522015e04f2fc22ba4e58ddf94fa035bc6dc9c85.tar.gz
CMake-522015e04f2fc22ba4e58ddf94fa035bc6dc9c85.tar.bz2
Merge topic 'java-export-native_headers'
53235626a2 UseJava: enable exportation of native headers target Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5658
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeLists.txt3
-rw-r--r--Tests/JavaNativeHeaders/CMakeLists.txt9
-rw-r--r--Tests/JavaNativeHeaders/Import/CMakeLists.txt19
3 files changed, 30 insertions, 1 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 2a59d66..74fca5c 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -3394,6 +3394,9 @@ if(BUILD_TESTING)
${build_generator_args}
--build-project helloJavaNativeHeaders
--build-run-dir "${CMake_BINARY_DIR}/Tests/JavaNativeHeaders/"
+ --build-target install
+ --build-options
+ "-DCMAKE_INSTALL_PREFIX:PATH=${CMake_BINARY_DIR}/Tests/JavaNativeHeaders/Install"
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIG>)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaNativeHeaders")
endif()
diff --git a/Tests/JavaNativeHeaders/CMakeLists.txt b/Tests/JavaNativeHeaders/CMakeLists.txt
index 2023d25..f3cc89d 100644
--- a/Tests/JavaNativeHeaders/CMakeLists.txt
+++ b/Tests/JavaNativeHeaders/CMakeLists.txt
@@ -11,7 +11,7 @@ include (UseJava)
# JNI support
find_package(JNI)
-add_jar(B1 D.java GENERATE_NATIVE_HEADERS D1-native)
+add_jar(B1 D.java GENERATE_NATIVE_HEADERS D1-native DESTINATION INSTALL include)
add_jar(E1 E.java GENERATE_NATIVE_HEADERS E1-native)
add_jar(hello4 HelloWorld3.java)
@@ -19,6 +19,13 @@ add_jar(hello4 HelloWorld3.java)
add_library(D SHARED D.cpp E.cpp)
target_link_libraries (D PRIVATE D1-native E1-native)
+install(TARGETS D1-native EXPORT native)
+install(DIRECTORY "$<TARGET_PROPERTY:D1-native,NATIVE_HEADERS_DIRECTORY>/" DESTINATION include)
+install(EXPORT native DESTINATION "${CMAKE_INSTALL_PREFIX}" NAMESPACE D1::)
+
add_test (NAME Java.NativeHeaders
COMMAND "${Java_JAVA_EXECUTABLE}" -Djava.library.path=$<TARGET_FILE_DIR:D> -classpath hello4.jar HelloWorld3)
+
+add_test (NAME Java.ImportNativeHeaders
+ COMMAND "${CMAKE_COMMAND}" "-DNATIVE_HEADERS_IMPORT_DIR=${CMAKE_INSTALL_PREFIX}" -S "${CMAKE_CURRENT_SOURCE_DIR}/Import" -B "${CMAKE_CURRENT_BINARY_DIR}/Import")
diff --git a/Tests/JavaNativeHeaders/Import/CMakeLists.txt b/Tests/JavaNativeHeaders/Import/CMakeLists.txt
new file mode 100644
index 0000000..5486da9
--- /dev/null
+++ b/Tests/JavaNativeHeaders/Import/CMakeLists.txt
@@ -0,0 +1,19 @@
+project(ImportJavaNativeHeaders LANGUAGES NONE)
+
+cmake_minimum_required (VERSION 3.19...3.20)
+set(CMAKE_VERBOSE_MAKEFILE 1)
+
+include(${NATIVE_HEADERS_IMPORT_DIR}/native.cmake)
+
+if(NOT TARGET D1::D1-native)
+ message(FATAL_ERROR "Target 'D1::D1-native' not found.")
+endif()
+
+get_property(incs TARGET D1::D1-native PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
+if (NOT incs MATCHES "${NATIVE_HEADERS_IMPORT_DIR}/include")
+ message(FATAL_ERROR "Target 'D1::D1-native', property 'INTERFACE_INCLUDE_DIRECTORIES' badly defined: ${incs}.")
+endif()
+
+if (NOT EXISTS "${NATIVE_HEADERS_IMPORT_DIR}/include/D.h")
+ message(FATAL_ERROR "file '${NATIVE_HEADERS_IMPORT_DIR}/include/D.h' not found.")
+endif()