[CMake] Path problem when building a jar file

George Neill georgen at neillnet.com
Tue Oct 28 14:32:19 EDT 2008


Hi Robert,

On Tue, Oct 28, 2008 at 1:07 PM, Robert Haines <rhaines at manchester.ac.uk> wrote:
> Hi all,
>
> I am building a jar file but I can't get the paths right within it.
>
> I have a directory structure like this
> source-root/org/some/package/<files>.java
> source-root/org/some/other/<files>.java
> and I want the compiled .class files to all go into the same jar file.
>
> If I have a CMakeLists.txt in source-root simply do a
> add_library(JarName ${FILES})
> (where FILES is a list of all the java files relative to source-root) my jar
> file is full of paths like this:
>
> org/some/package/org/some/package/<files>.java
> org/some/other/org/some/other/<files>.java
>
> ie, because CMake builds everything in a directory relative to source-root
> in the binary tree and then javac puts the files in their package
> directories using this as a starting point, the package structure gets
> duplicated.
>
> It seems as though CMake is being over zealous in its use of the -d flag to
> javac. Either that or at the "link" step the wrong directory is being passed
> to jar via the -C flag. I have tried to override the -d and -C flags with a
> combination of set_source_files_properties and set_target_properties with no
> joy.
>
> Another way I have tried is to have a CMakeLists.txt in the
> source-root/org/some/package/ directory. If I do this I can get the paths
> right for that particular branch of the package scheme but can't get the
> classes in the org/some/other/ branch into the same jar file.
>
> Has anyone managed to do this with CMake? It seems to be an overwhelmingly
> simple thing to do so I must be doing it wrong!

I filed a bug on this the other day and posted a temporary solution
(attached to the bug) http://www.cmake.org/Bug/view.php?id=7832

Hope that helps,
George.


More information about the CMake mailing list