[CMake] please review: fix UseJava.cmake to support dependent jars (was: how to add jar that depends on other built jar?)

Matthew Woehlke matthew.woehlke at kitware.com
Thu Mar 14 10:47:38 EDT 2013


On 2013-03-13 18:14, Matthew Woehlke wrote:
> On 2013-03-13 17:09, Matthew Woehlke wrote:
>> I have a project that builds a bunch of jar's with add_jar from
>> UseJava.cmake. Let's say we have myjar1 and myjar2. How do I write the
>> build rules for myjar2 such that it depends on myjar1?
>>
>> It looks like add_jar is intended to accept names of jar's as source
>> arguments, but this doesn't work (they are appended to
>> CMAKE_JAVA_INCLUDE_PATH which is not pushed back to parent scope and is
>> not used after the point where the append happens). Also, there does not
>> seem to be *any* way to enforce that myjar1 is built before myjar2.
>>
>> Do I miss something, or is this not supported?
>
> So... I fixed this locally by hacking on UseJava.cmake. Basically, I did
> three things:
>
> - Also set CMAKE_JAVA_INCLUDE_PATH_FINAL when a jar is seen in add_jar
> arguments.
> - Accept targets as a means of specifying jar files.
> - Add jars as dependencies of the javac step.
>
> ...and I also moved some path logic to after the extension check, as it
> is only used for .java files.
>
> Is there any chance of getting this accepted for 2.8.11?

This is now pushed to stage/fix-java-jar-depends. If someone 
knowledgeable could have a look, that would be much appreciated.

-- 
Matthew



More information about the CMake mailing list