CMake swig integration

develop
Petr Mrázek 2010-02-28 04:11:06 +01:00
parent cf4042acce
commit 7c73c7abe6
3 changed files with 21 additions and 4 deletions

@ -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/)

@ -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)
# 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)

@ -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()