I don't know if this helps but we are using a construct to do something similar. We do something like this:
cmake_minimum_required(VERSION 2.8) project( cplusplusapi_wrap ) MESSAGE("Please ensure the Environment variable JAVA_HOME has been set correctly") FIND_PACKAGE(SWIG REQUIRED) INCLUDE(${SWIG_USE_FILE}) FIND_PACKAGE(Java REQUIRED) FIND_PACKAGE(JNI REQUIRED) INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH}) INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH2}) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) SET(JAVA_RUNTIME2 $ENV{JAVA_HOME}/bin/java) SET(JAVA_ARCHIVE2 $ENV{JAVA_HOME}/bin/jar) SET(JAVA_COMPILE2 $ENV{JAVA_HOME}/bin/javac) SET(CMAKE_SWIG_FLAGS -package cplusplusapi) SET(SWIG_SOURCES <various .i files> /snip/ <end various .i files> ) SET_SOURCE_FILES_PROPERTIES(${SWIG_SOURCES} PROPERTIES CPLUSPLUS ON) #SET_SOURCE_FILES_PROPERTIES(${SWIG_SOURCES} PROPERTIES SWIG_FLAGS "-includeall") SWIG_ADD_MODULE(cplusplusapi_wrap Java ${SWIG_SOURCES}) SWIG_LINK_LIBRARIES(cplusplusapi_wrap SAIL <required libs go here>) ADD_CUSTOM_COMMAND(TARGET cplusplusapi_wrap POST_BUILD COMMAND cmake -E echo "Compiling Java files..." COMMAND cmake -E make_directory ${cplusplusapi_wrap_BINARY_DIR}/cplusplusapi COMMAND ${JAVA_COMPILE2} *.java -d ${cplusplusapi_wrap_BINARY_DIR} COMMAND cmake -E echo "Creating jar file..." COMMAND ${JAVA_ARCHIVE2} cvf cplusplusapi_wrap.jar wrappedapi ) One of the advantages of being disorderly is that one is constantly making discoveries. -AA Milne -----Original Message----- Message: 1 Date: Tue, 27 Apr 2010 18:04:46 -0400 From: "Simmons, Aaron" <asimm...@rosettastone.com> Subject: [CMake] making a jar from swig-generated jni library To: "cmake@cmake.org" <cmake@cmake.org> Message-ID: <9bf48db58688484396c43886e8e7ad880695725...@rshbgxmbcls1.rosettastone.local> Content-Type: text/plain; charset="us-ascii" I am using swig in cmake to create a JNI wrapper around a C++ library. Everything is working fine, however I would like to jar up all the swig-generated java files. I'm not sure how to do it. My project looks more or less like this: cmake_minimum_required(VERSION 2.8) project(mylib) ...<snip>... # create library include_directories(${CMAKE_SOURCE_DIR}) add_library(mylib mylib.cpp) # create the jni wrapper SET_SOURCE_FILES_PROPERTIES(mylib.i PROPERTIES CPLUSPLUS ON) SWIG_ADD_MODULE(mylib-jni java mylib.i ) target_link_libraries(mylib-jni mylib) project(mylib-jni Java) # jar up the generated swig java sources set(JAVA_SRCS ${CMAKE_SWIG_OUTDIR}/mylib.java ${CMAKE_SWIG_OUTDIR}/mylibJNI.java ) include_directories(${CMAKE_SWIG_OUTDIR}) add_library(mylib-java ${JAVA_SRCS}) However, this gives the error: 'Cannot find source file "mylib.java"'. Which makes a kind of sense because mylib.java doesn't exist at cmake time. Do the swig macros not mark the java files as "generated"? Am I doing something wrong? Thanks, aaron _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake