生成痛饮绑定通过CMake(Generating SWIG bindings with CMake)

2019-07-20 05:50发布

我怎么会产生对于使用CMake的构建一个C项目自动绑定?

我想自动生成的Python,Java和.NET,PHP,Perl的,TCL,Ruby和倍频绑定。

Answer 1:

你可以找到一个例子在这里 。

片段:

下面的例子是为用于SW​​IG接口文件,example.i创建Python包装一个CMake的输入文件:

 # This is a CMake example for Python FIND_PACKAGE(SWIG REQUIRED) INCLUDE(${SWIG_USE_FILE}) FIND_PACKAGE(PythonLibs) INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) SET(CMAKE_SWIG_FLAGS "") SET_SOURCE_FILES_PROPERTIES(example.i PROPERTIES CPLUSPLUS ON) SET_SOURCE_FILES_PROPERTIES(example.i PROPERTIES SWIG_FLAGS "-includeall") SWIG_ADD_MODULE(example python example.i example.cxx) SWIG_LINK_LIBRARIES(example ${PYTHON_LIBRARIES}) 


文章来源: Generating SWIG bindings with CMake