diff --git a/Wrapping/Python/CMakeLists.txt b/Wrapping/Python/CMakeLists.txt index f23c21df89..24baee8eb4 100644 --- a/Wrapping/Python/CMakeLists.txt +++ b/Wrapping/Python/CMakeLists.txt @@ -1,65 +1,66 @@ # Version 2.8.1 is the minium requirement for this script. # this is lower than the general minimum requirement. #cmake_minimum_required ( VERSION 2.8.1 FATAL_ERROR ) project( MITK_Python ) # function taken from # https://stackoverflow.com/questions/37205274/swig-and-cmake-make-use-of-information-provided-by-target-include-directories function(swig_add_library_dependencies swig_module library_names) foreach(library_name ${library_names}) get_property(LIBRARY_INCLUDES TARGET ${library_name} PROPERTY INTERFACE_INCLUDE_DIRECTORIES) foreach(INCLUDE_PATH ${LIBRARY_INCLUDES}) include_directories(${INCLUDE_PATH}) file(GLOB_RECURSE header_files "${INCLUDE_PATH}/*.h") list(APPEND SWIG_MODULE_${swig_module}_EXTRA_DEPS ${header_files}) message(STATUS ${header_files}) # export variable to parent scope set(SWIG_MODULE_${swig_module}_EXTRA_DEPS ${SWIG_MODULE_${swig_module}_EXTRA_DEPS} PARENT_SCOPE) endforeach() endforeach() endfunction() # # Find the necessary libraries etc.. # if ( MITK_UNDEFINED_SYMBOLS_ALLOWED ) set( _QUIET_LIBRARY "QUIET" ) else() set( _QUIET_LIBRARY "REQUIRED" ) endif() find_package ( PythonInterp REQUIRED ) find_package ( PythonLibs ${_QUIET_LIBRARY} ) # # Options # option ( MITK_PYTHON_THREADS "Enable threaded python usage by unlocking the GIL." ON ) mark_as_advanced( MITK_PYTHON_THREADS ) option ( MITK_PYTHON_EGG "Add building of python eggs to the dist target." OFF ) mark_as_advanced( MITK_PYTHON_EGG ) option ( MITK_PYTHON_WHEEL "Add building of python wheels to the dist target." ON ) mark_as_advanced( MITK_PYTHON_WHEEL ) set_source_files_properties ( MITK.i PROPERTIES CPLUSPLUS ON ) +set_source_files_properties ( MITK.i PROPERTIES SWIG_FLAGS "-IE:/Projects/MitkPython/mitk/Modules/Core/include" ) # Run swig set(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_GLOBAL_FLAGS} -features autodoc=1 -keyword ) if( MITK_PYTHON_THREADS ) set(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_FLAGS} -threads) endif() set(CMAKE_SWIG_OUTDIR ${CMAKE_CURRENT_BINARY_DIR}) swig_add_module ( PythonMITK python MITK.i ) swig_link_libraries(PythonMITK MitkCore ) swig_link_libraries(PythonMITK ${PYTHON_LIBRARIES} ) include_directories( ${PYTHON_INCLUDE_DIR}) list(APPEND SWIG_MODULE_PythonMITK_EXTRA_DEPS ${PYTHON_INCLUDE_DIR}) swig_add_library_dependencies(PythonMITK "MitkCore;mbilog;CppMicroServices") \ No newline at end of file diff --git a/Wrapping/Python/MITK.i b/Wrapping/Python/MITK.i index dbd3834dfe..b3b1f826ab 100644 --- a/Wrapping/Python/MITK.i +++ b/Wrapping/Python/MITK.i @@ -1,9 +1,21 @@ %module PythonMITK %{ #include +using namespace mitk; int hello() {return 1;}; + +mitk::BaseData::Pointer Load(const std::string &path) +{ + return mitk::IOUtil::Load(path)[0]; +} + %} -#include -extern int hello(); \ No newline at end of file +%include + +#define MITKCORE_EXPORT + +%include +extern int hello(); +extern mitk::BaseData::Pointer Load(const std::string &path);