diff --git a/cmake/GtsamCythonWrap.cmake b/cmake/GtsamCythonWrap.cmake index e963a0d9c..f1382729f 100644 --- a/cmake/GtsamCythonWrap.cmake +++ b/cmake/GtsamCythonWrap.cmake @@ -87,6 +87,15 @@ endfunction() # - output_dir: The output directory function(build_cythonized_cpp target cpp_file output_lib_we output_dir) add_library(${target} MODULE ${cpp_file}) + + if(WIN32) + # Use .pyd extension instead of .dll on Windows + set_target_properties(${target} PROPERTIES SUFFIX ".pyd") + + # Add full path to the Python library + target_link_libraries(${target} ${PYTHON_LIBRARIES}) + endif() + if(APPLE) set(link_flags "-undefined dynamic_lookup") endif() diff --git a/cython/CMakeLists.txt b/cython/CMakeLists.txt index a351ec52b..4cc9d2f5d 100644 --- a/cython/CMakeLists.txt +++ b/cython/CMakeLists.txt @@ -7,6 +7,11 @@ if (GTSAM_INSTALL_CYTHON_TOOLBOX) add_subdirectory(gtsam_eigency) include_directories(${PROJECT_BINARY_DIR}/cython/gtsam_eigency) + # Fix for error "C1128: number of sections exceeded object file format limit" + if(MSVC) + add_compile_options(/bigobj) + endif() + # wrap gtsam add_custom_target(gtsam_header DEPENDS "../gtsam.h") wrap_and_install_library_cython("../gtsam.h" # interface_header diff --git a/cython/setup.py.in b/cython/setup.py.in index aefa11241..df92b564c 100644 --- a/cython/setup.py.in +++ b/cython/setup.py.in @@ -35,7 +35,7 @@ setup( packages=packages, package_data={package: - [f for f in os.listdir(package.replace('.', os.path.sep)) if os.path.splitext(f)[1] in ('.so', '.dll')] + [f for f in os.listdir(package.replace('.', os.path.sep)) if os.path.splitext(f)[1] in ('.so', '.pyd')] for package in packages }, install_requires=[line.strip() for line in '''