[CMake] CMake Java Support

Hendrik Sattler post at hendrik-sattler.de
Fri Jan 14 12:06:32 EST 2011


Am Freitag, 14. Januar 2011, 16:48:44 schrieb Andreas Schneider:
> On Friday 14 January 2011 16:32:16 you wrote:
> > Andreas,
> 
> Hi Allen,
> 
> >     Thanks, I do have most everything working, setting the version was
> >     the
> > 
> > key!
> > Concerning the '.' at the beginning of my proposed patch, I added that
> > because the CMAKE_JAVA_INCLUDE_PATH_FINAL started with a seperator and I
> > didn't look into why. I find this 'set' command very useful and I suggest
> > you consider adding it (with or without the leading '.'). Note that I
> > discovered a bug with Windows and the Visual Studio generator. The use of
> > CMAKE_JAVA_INCLUDE_PATH_FINAL in the add_custom_command changes the ';'
> > seperator into spaces - I think it needs to be escaped somehow - maybe
> > the CMake gurus have a suggestion?
> 
> I'm not a java programmer and I haven't tested this stuff on Windows.
> Please tell which variables have the wrong ; or : or whatever and what it
> should look like. I already did some things to get it working on Windows
> but never tested.
> 
> The more details you give the easier it is to fix. If you could print out
> the variables I could try to fix it and add what you need.

I had the same problem for my XSLT modules that can make use of saxon and 
xalan (both java program including some jar files). If you do calls to java, 
the classpath must be it's own list and can then be run like:
     add_custom_command (
        OUTPUT foo
        COMMAND "${JAVA_RUNTIME}" -cp "${FOO_CLASSPATH}" bar
     )

If you import a classpath from the environment, use
     string ( REPLACE ":" ";" .....)
but only on Windows.

This solution works on Linux and Windows.

HS


More information about the CMake mailing list