From 21a350f106375962c05ee984161edc88e18a195d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 27 Sep 2021 07:30:41 +0200 Subject: Examples: Build using a set of idiomatic names, one recipe for each examples; Add jar install for example/java! --- examples/java/CMakeLists.txt | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'examples/java/CMakeLists.txt') diff --git a/examples/java/CMakeLists.txt b/examples/java/CMakeLists.txt index d35e1c0a..1d1f3786 100644 --- a/examples/java/CMakeLists.txt +++ b/examples/java/CMakeLists.txt @@ -2,17 +2,25 @@ find_package(Java REQUIRED) include(UseJava) -add_jar(DBTScanner10 SOURCES DBTScanner10.java INCLUDE_JARS direct_bt_jar ENTRY_POINT Notification) -add_custom_command(TARGET DBTScanner10 - POST_BUILD - COMMAND cp "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/DBTScanner10.dir/DBTScanner10.class" "${CMAKE_CURRENT_BINARY_DIR}" +# These examples use the standard separate compilation +set( SOURCES_IDIOMATIC_EXAMPLES + DBTScanner10.java + DBTPeripheral00.java ) -add_dependencies(DBTScanner10 direct_bt_jar) -add_jar(DBTPeripheral00 SOURCES DBTPeripheral00.java INCLUDE_JARS direct_bt_jar ENTRY_POINT Notification) -add_custom_command(TARGET DBTPeripheral00 - POST_BUILD - COMMAND cp "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/DBTPeripheral00.dir/DBTPeripheral00.class" "${CMAKE_CURRENT_BINARY_DIR}" -) -add_dependencies(DBTPeripheral00 direct_bt_jar) +string( REPLACE ".java" "" BASENAMES_IDIOMATIC_EXAMPLES "${SOURCES_IDIOMATIC_EXAMPLES}" ) +set( TARGETS_IDIOMATIC_EXAMPLES ${BASENAMES_IDIOMATIC_EXAMPLES} ) + +string( REPLACE ".java" ".jar" BASENAMES_IDIOMATIC_EXAMPLE_JARS "${SOURCES_IDIOMATIC_EXAMPLES}" ) +set( TARGETS_IDIOMATIC_EXAMPLE_JARS ${BASENAMES_IDIOMATIC_EXAMPLE_JARS} ) + +foreach( name ${TARGETS_IDIOMATIC_EXAMPLES} ) + add_jar(${name} SOURCES ${name}.java INCLUDE_JARS direct_bt_jar ENTRY_POINT Notification) + add_custom_command(TARGET ${name} + POST_BUILD + COMMAND cp "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${name}.dir/${name}.class" "${CMAKE_CURRENT_BINARY_DIR}" + ) + add_dependencies(${name} direct_bt_jar) + install_jar(${name} DESTINATION ${CMAKE_INSTALL_BINDIR}/java) +endforeach() -- cgit v1.2.3