diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2020-12-29 16:13:15 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2020-12-29 16:14:20 (GMT) |
commit | 53235626a2b7d2c07e0e50339a4039a4f5e03001 (patch) | |
tree | d8daa6b7a924f7241b54b55de8821d0b0946420f /Tests/JavaNativeHeaders | |
parent | c2a8d9b94ed8ac6856f3595e51d78fc716d77e75 (diff) | |
download | CMake-53235626a2b7d2c07e0e50339a4039a4f5e03001.zip CMake-53235626a2b7d2c07e0e50339a4039a4f5e03001.tar.gz CMake-53235626a2b7d2c07e0e50339a4039a4f5e03001.tar.bz2 |
UseJava: enable exportation of native headers target
Diffstat (limited to 'Tests/JavaNativeHeaders')
-rw-r--r-- | Tests/JavaNativeHeaders/CMakeLists.txt | 9 | ||||
-rw-r--r-- | Tests/JavaNativeHeaders/Import/CMakeLists.txt | 19 |
2 files changed, 27 insertions, 1 deletions
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() |