On Tue, Mar 24, 2009 at 04:37:31PM +0100, Jonatan Bijl wrote:
> 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:
>
> 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)
>
Have you read:
http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_generate_a_source_file_during_the_build.3F
You need both a custom_command and a custom_target. You can use
add_custom_command's DEPENDS argument to insure that the headers are
only regenerated when they are out of date.
hth,
tyler
_______________________________________________
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