[CMake] CMake Java Support

Allen D Byrne byrn at hdfgroup.org
Wed Jan 12 09:32:08 EST 2011


Andreas,
Thanks for providing these files! I have finally been able to progress on converting our java product to cmake.
I have one suggestion:

Add to the add_java function the classpath for the target;

    set(${_TARGET_NAME}_CLASSPATH ".${CMAKE_JAVA_INCLUDE_PATH_FINAL}/${_TARGET_NAME}.jar" PARENT_SCOPE)

I needed this on linux (uses ':' in classpath not ';' ) to do an add_test.

Also two questions: 
How do I get the jar files into an output folder for build/test (not install task)?

After I build my JNI Library with normal C process how do I connect the java JAR  to use the library? I'm not sure how to use INSTALL_JNI_SYMLINK?

Allen


> 
> Hello CMake,
> 
> my name is Andreas Schneider and I'm working for Red Hat. At the end of last 
> year I've worked on Dogtag PKI [1]. The Dogtag Certificate System [2] is an 
> enterprise-class open source Certificate Authority.
> 
> The project is written in serveral different laguages (C, C++ and Java), so 
> I've used CMake as the new build system. To be able to build the java project 
> I needed Java support in CMake. So I've started to write functions to compile 
> java files, find jar files, bundle jar files and generate javadoc.
> 
> It should provide everything to build java and jni projects. You find the 
> files here:
> 
> http://git.cryptomilk.org/projects/cmake-tools.git/tree/language/java
> 
> 
> FindJNI.cmake:
> 
> 	Find JNI libraries and headers. I think this is the file from CMake
> 	itself.
> 
> FindJava.cmake:
> 
> 	Find all needed Java tools like javac, javadoc, jar, etc.
> 
> UseJava.cmake:
> 
> 	This file provides all needed function to support creating java
> 	projects in CMake. Most of the function are documented in detail.
> 	There is some documentation missing. I will add this soon.
> 
> UseJavaClassFilelist.cmake:
> 
> 	This is needed to find the class files in the build directory. One
> 	.java file can create multiple .class files. So you have to glob for
> 	these file. There is support to only look for certain .class files.
> 
> UseJavaSymlinks.cmake:
> 
> 	This is a helper to create symlinks for versioned jar files.
> 
> 
> git clone git://git.cryptomilk.org/projects/cmake-tools.git
> 
> 
> It would be nice if this would be included into the CMake distribution, but at 
> the moment there is still documentation missing. I hope that this will help 
> some people to get their Java project built with CMake.
> 
> Comments, suggestions and patches are welcome!
> 
> Best regards,
> 
> 
> 	-- andreas
> 
> 
> [1] https://fedorahosted.org/pki/browser/trunk/pki
> [2] http://pki.fedoraproject.org/wiki/PKI_Main_Page
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110112/ba1e49d5/attachment.htm>


More information about the CMake mailing list