diff --git a/CMake/mitkSwigAddLibraryDependencies.cmake b/CMake/mitkSwigAddLibraryDependencies.cmake index a2166beb99..b9125ca13c 100644 --- a/CMake/mitkSwigAddLibraryDependencies.cmake +++ b/CMake/mitkSwigAddLibraryDependencies.cmake @@ -1,43 +1,43 @@ #! This CMake macro adds the necessary library and incllude #! directories to a swig-project. #! #! params: #! swig_module : Name of the SWIG module, for example PythonMITK #! library_names : Semicolon separated list of the libraries that are included, for example "MitkCore;mbilog" #! # function inspired by # https://stackoverflow.com/questions/37205274/swig-and-cmake-make-use-of-information-provided-by-target-include-directories # This function tells cmake which additional dependencies are existing # especially with respect to the linker dependencies. function(mitkSwigAddLibraryDependencies swig_module library_names) foreach(library_name ${library_names}) # Adding each library as a linker dependency: swig_link_libraries(${swig_module} ${library_name}) # Extracting all include directories from each given project and # then including these directories to the newly created swig project. get_property(LIBRARY_INCLUDES TARGET ${library_name} PROPERTY INTERFACE_INCLUDE_DIRECTORIES) # Checking each given librarie to include all includes from this library. foreach(INCLUDE_PATH ${LIBRARY_INCLUDES}) file(GLOB_RECURSE header_files "${INCLUDE_PATH}/*.h") list(APPEND SWIG_MODULE_${swig_module}_EXTRA_DEPS ${header_files}) # export variable to parent scope set(SWIG_MODULE_${swig_module}_EXTRA_DEPS ${SWIG_MODULE_${swig_module}_EXTRA_DEPS} PARENT_SCOPE) endforeach() endforeach() # In addition include python dependencies: include_directories( ${PYTHON_INCLUDE_DIR}) list(APPEND SWIG_MODULE_${swig_module}_EXTRA_DEPS ${PYTHON_INCLUDE_DIR}) - swig_link_libraries(${swig_module} ${PYTHON_LIBRARIES} ) + #swig_link_libraries(${swig_module} ${PYTHON_LIBRARIES} ) # Add additional include paths, for example to the common files: list(APPEND SWIG_MODULE_${swig_module}_EXTRA_DEPS ${SWIG_EXTRA_DEPS}) set(SWIG_MODULE_${swig_module}_EXTRA_DEPS ${SWIG_MODULE_${swig_module}_EXTRA_DEPS} PARENT_SCOPE) -endfunction() \ No newline at end of file +endfunction() diff --git a/Wrapping/Python/CMakeLists.txt b/Wrapping/Python/CMakeLists.txt index d27beea285..3c1703dde9 100644 --- a/Wrapping/Python/CMakeLists.txt +++ b/Wrapping/Python/CMakeLists.txt @@ -1,68 +1,77 @@ # 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 ) include(mitkTargetLinkLibrariesWithDynamicLookup) project( MITK_Python ) +set(CMAKE_SHARED_LINKER_FLAGS "" CACHE INTERNAL "" FORCE) +set(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "" FORCE) + +sitk_check_dynamic_lookup(MODULE + SHARED + MITK_UNDEFINED_SYMBOLS_ALLOWED + ) + # # 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 ) # Prepare the SWIG-File, i.e. especially add necessary include folders mitkSwigPrepareFiles(MITK.i "MitkCore") # Add additional SWIG Parameters # These parameters depend on the target language 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}) # Create the actual SWIG project swig_add_module(PythonMITK python MITK.i ) mitkSwigAddLibraryDependencies(PythonMITK "MitkCore") mitk_target_link_libraries_with_dynamic_lookup(${SWIG_MODULE_PythonMITK_REAL_NAME} ${PYTHON_LIBRARIES}) if(DEFINED SKBUILD) message(WARNING "SKBuild exists") # Currently this installation install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PythonMITK.py ${CMAKE_CURRENT_SOURCE_DIR}/Packaging/__init__.py # ${SimpleITK_DOC_FILES} DESTINATION PythonMITK COMPONENT Runtime ) install(TARGETS ${SWIG_MODULE_PythonMITK_REAL_NAME} RUNTIME DESTINATION PythonMITK LIBRARY DESTINATION PythonMITK COMPONENT Runtime ) else() message(WARNING "SKBuild missing") include(LegacyPackaging.cmake) endif()