[CMake] Creating JAR files with cmake

Andreas Pokorny andreas.pokorny at gmail.com
Thu Mar 5 04:22:13 EST 2009


Hi there,
I just tried building a JAR file with CMake. The project structure
looks like this:


java_projects/
    +---- CMakeLists.txt
    +---- Project1/
               +---- MANIFEST.MF
               +---- src/
                        +---- com
                                 +---- ... and so on with java source files
               +---- CMakeLists.txt
               +---- ...

In the top most CMakeLists.txt I search for external jars that are
required by most of
the subprojects. I then set them as:

INCLUDE_DIRECTORIES( ${FOO_JAR_PATH} )

I this the correct way of extending the classpath?

Then in the second CMakeLists.txt:
PROJECT(Project1 Java)

INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/ )
ADD_LIBRARY(Project1
        src/com/foo/bar/MainClass.java
        MANIFEST.MF )

When using NMake Makefiles I then get a Project1.jar containing:

 +--- META-INF
          +---  MANIFEST.MF   // Default manifest file
 +--- src/com/foo/bar/com/foo/bar
          +--- MainClass.class
          +--- ... and all required classes
 +--- build.make
 +--- cmake_clean.cmake
 +--- cmake_clean_target.cmake
 +--- depend.internal
 +--- depend.make
 +--- DependInfo.cmake
 +--- flags.make
 +--- progress.make

Is there a way to get rid of the path element src/ and the duplicate
path elements com/foo/bar?
If not .. could you give me a starting point in the cmake source where
the Java stuff is handled?

regards
Andreas Pokorny


More information about the CMake mailing list