I am setting up a jni project (Java Native Interface). A java class is
supposed to call native methods, and the native methods are to be
compiled into a dll/so.
To compile the native part, a c header file is generated from the java
class, using the "javah -jni" command. This header file should only be
generated if:
It does not exist yet
The java class changes
My first attempt was:
set(INTERFACE_HEADER_FILE
${PROJECT_BINARY_DIR}/include/main_java_nl_tba_Testproject_java_HelloWor
ld.h)
set(INTERFACE_JAVA_CLASS main.java.nl.tba.Testproject_Java.HelloWorld)
set(INTERFACE_JAVA_CLASS_FILE
${COMMON_ROOT_BIN_DIRECTORY}/main/java/nl/tba/Testproject_Java/HelloWorl
d.class)
add_custom_command(OUTPUT ${INTERFACE_HEADER_FILE}
COMMAND ${JNI_JAVAH} -jni -d ${PROJECT_BINARY_DIR}/include
${INTERFACE_JAVA_CLASS}
WORKING_DIRECTORY ${COMMON_ROOT_BIN_DIRECTORY}
COMMENT "generating jni header file ${INTERFACE_HEADER_FILE}"
)
set_source_files_properties(HelloWorld.c OBJECT_DEPENDS
${INTERFACE_HEADER_FILE})
add_library(HelloWorldNative SHARED HelloWorld.c
${INTERFACE_HEADER_FILE})
cMake however claims there is no rule to make the header file
I found somebody who used the following:
add_custom_target(
HelloWorldNativeHeader
COMMAND ${JNI_JAVAH} -jni -d ${PROJECT_BINARY_DIR}/include
${INTERFACE_JAVA_CLASS}
WORKING_DIRECTORY ${COMMON_ROOT_BIN_DIRECTORY}
COMMENT "generating jni header file ${INTERFACE_HEADER_FILE}"
)
add_library(HelloWorldNative SHARED HelloWorld.c
${INTERFACE_HEADER_FILE})
add_dependencies(HelloWorldNative HelloWorldNativeHeader)
If I understand the documentation correctly, this would force the file
to be generated every time. Is that correct?
Which one am I supposed to use? (Cmake 2.6)
If that is the first one, how can I make sure cmake can find the target?
Jonatan
-------------------------------------------------------------
This e-mail is intended exclusively for the addressee. If you
are not the addressee you must not read, copy, use or
disclose the e-mail nor the content; please notify us
immediately [by clicking 'Reply'] and delete this e-mail.
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake