From 7c73c7abe636f2764d94217882bf90fc6068e90f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 28 Feb 2010 04:11:06 +0100 Subject: [PATCH] CMake swig integration --- CMakeLists.txt | 1 + library/CMakeLists.txt | 17 ++++++++++++++++- output/stones.py | 7 ++++--- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 133879e1c..74cbb8bf3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,7 @@ SET(SO_VERSION "${SO_MAJOR_VERSION}.${SO_MINOR_VERSION}.${SO_BUILD_VERSION}") SET( LIBRARY_OUTPUT_PATH ${dfhack_SOURCE_DIR}/output CACHE PATH "Output directory for the dfhack library" ) SET( EXECUTABLE_OUTPUT_PATH ${dfhack_SOURCE_DIR}/output CACHE PATH "Output directory for the dfhack tools" ) +SET( CMAKE_SWIG_OUTDIR ${dfhack_SOURCE_DIR}/output CACHE PATH "Global output directory for swig generated language wrappers" ) include_directories (${CMAKE_SOURCE_DIR}/library/) include_directories (${CMAKE_SOURCE_DIR}/shmserver/) diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 0f172f0dd..97c4e7458 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -104,4 +104,19 @@ IF(UNIX) install(FILES ${CMAKE_SOURCE_DIR}/output/Memory.xml DESTINATION share/dfhack) ENDIF(UNIX) -#install(TARGETS mySharedLib DESTINATION /some/full/path) \ No newline at end of file +# SWIG stuff +FIND_PACKAGE(SWIG) + +IF(SWIG_FOUND) + INCLUDE(${SWIG_USE_FILE}) + FIND_PACKAGE(PythonLibs) + IF(PYTHONLIBS_FOUND) + INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}) + SET(CMAKE_SWIG_FLAGS "-c++") + SET_SOURCE_FILES_PROPERTIES(pydfhack.i PROPERTIES CPLUSPLUS ON) +# SET(CMAKE_DFHACK_SWIG_OUTDIR ${dfhack_SOURCE_DIR}/output CACHE PATH "Directory where Java wrapped libraries will be saved.") + # SET_SOURCE_FILES_PROPERTIES(pydfhack.i PROPERTIES SWIG_FLAGS "-includeall") + SWIG_ADD_MODULE(pydfhack python pydfhack.i) + SWIG_LINK_LIBRARIES(pydfhack ${PYTHON_LIBRARIES} dfhack) + ENDIF(PYTHONLIBS_FOUND) +ENDIF(SWIG_FOUND) \ No newline at end of file diff --git a/output/stones.py b/output/stones.py index b506713fa..5feb53210 100644 --- a/output/stones.py +++ b/output/stones.py @@ -1,6 +1,7 @@ -import dfhack -x = dfhack.API("Memory.xml") -y = dfhack.MatglossVector() +# -*- coding: utf-8 -*- +import pydfhack +x = pydfhack.API("Memory.xml") +y = pydfhack.MatglossVector() if x.Attach(): success,stones = x.ReadStoneMatgloss()