[CMake] CMake Java Support

Allen D Byrne byrn at hdfgroup.org
Fri Jan 14 13:39:55 EST 2011


Hendrik,
   Thanks! I put '"' around the classpath on line 233 of UseJava.cmake file and windows was happy to compile the sources.

Andreas,
    So that makes only two changes to UseJava.cmake, both in the add_jar function;
  Quotes around the ${CMAKE_JAVA_INCLUDE_PATH_FINAL} in line 233 and
  add the 
    set(${_TARGET_NAME}_CLASSPATH ".${CMAKE_JAVA_INCLUDE_PATH_FINAL}/${_TARGET_NAME}.jar" PARENT_SCOPE)
at the end of the same function (line 300) 

Allen

> 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
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110114/20d65a82/attachment-0001.htm>


More information about the CMake mailing list