Garmaine Staff asked 4 months ago

I am having trouble doing two things and would appreciate any help:

1. Acquiring a list of the files generated by SWIG (the java files in this case).

I can access/change what the output directory is. But I need a list of the java files. The only way I see people do this is using some custom command after build time. I am hoping there is a more modern cmake approach.

I have attempted to use the property SWIG_SUPPORT_FILES but it is missing one of the java files for some reason.

2. Putting the shared library (javaExample target) into the jar.

CMakeLists.txt:

find_package(SWIG REQUIRED)
include(${SWIG_USE_FILE})

find_package(Java REQUIRED)
find_package(JNI REQUIRED)
include(UseJava)

set_property(SOURCE java.i PROPERTY CPLUSPLUS ON)

swig_add_library(javaExample
  TYPE SHARED
    LANGUAGE java
    SOURCES java.i)

set_property(TARGET javaExample PROPERTY SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE)
target_include_directories(javaExample PRIVATE ${JNI_INCLUDE_DIRS})
target_link_libraries(javaExample PRIVATE api)

add_jar(SDK
  #Swig generated java files
)

install_jar(SDK .)
install(TARGETS javaExample) # Would like to put this into the jar