Alright so I've got some very basic skeleton stuff put together using CMake and 
SWIG.  I followed the Python example and poked and prodded at it to make a Java 
version of the same thing.  Then added my stuff to it.  So I've got:

FIND_PACKAGE(SWIG REQUIRED)
INCLUDE(${SWIG_USE_FILE})

FIND_PACKAGE(Java REQUIRED)
INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH})

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})

SET(CMAKE_SWIG_FLAGS "")

SET(SWIG_SOURCES
  <BUNCH OF .H FILES WITH EMBEDDED SWIG HEADER INFO>
)

SET_SOURCE_FILES_PROPERTIES(${SWIG_SOURCES} PROPERTIES CPLUSPLUS ON)
SET_SOURCE_FILES_PROPERTIES(${SWIG_SOURCES} PROPERTIES SWIG_FLAGS "-includeall")
SWIG_ADD_MODULE(<MYWRAPPED_LIB_DLL> Java ${SWIG_SOURCES})
SWIG_LINK_LIBRARIES(<MYWRAPPED_LIB_DLL> <LIB_TO_BE_WRAPPED>)

Each of the .h files has a special header of this form embedded in them:

//variousandsundry.h - Does various and sundry things
#ifdef SWIG
%module <MYWRAPPED_LIB_DLL>
%{
#include "variousandsundry.h"
        %}
#endif //SWIG

Void foo();
Int bat();

I sort of expected to see various *.java files created (like 
variousandsundry.java) and I expected to see a MYWRAPPED_LIB_DLL.dll and a 
MYWRAPPED_LIB_DLL.jar.  All I can easily find is the MYWRAPPED_LIB_DLL.dll.  Am 
I missing something or am I setting my expectations too high.

Basically I want to create a java interface to a c++ lib using SWIG as part of 
my CMake build process.  This library has been successfully created before 
using SWIG so I'm sure it can be done.  It's just a matter of figuring out how  
integrate it with the CMake process.

Michael Caron

Nothing is impossible for the man who doesn't have to do it himself.
-A. H. Weiler
Ops Analysis (BAE Internal) wiki site: http://bluas0752/display/EWOA/Home



_______________________________________________
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

Reply via email to