[CMake] Building Java

Benjamin Reed rangerrick at gmail.com
Mon Feb 4 22:45:17 EST 2008


I've got a JNI library which has some C code and some java.

It seems like cmake has some support for "compiling" java files, but I
really am not sure how to set up my targets.  How do I turn a set of
*.java files into *.class files?

Also, it looks like there's no specific support for creating a .h file
from a JNI class; I've done this:

  GET_FILENAME_COMPONENT(JAVABIN_PATH ${JAVA_COMPILE} PATH)
  add_custom_target(org_opennms_protocols_icmp_IcmpSocket.h
${JAVABIN_PATH}/javah -classpath classes DEPENDS jicmp-java)

...but obviously the classpath needs to be wherever my .class files
get output, and jicmp-java needs to be the proper dependency to
trigger the build of the class files.

Has anyone done any java building with CMake?  The few examples I've
found googling around involve making ant builds and calling out to
ant, which is a bit overkill for a javac and javah call...

-- 
Benjamin Reed a.k.a. Ranger Rick
Fink, KDE, and Mac OS X development
http://www.racoonfink.com/


More information about the CMake mailing list