diff --git a/lang/python/CMakeLists.txt b/lang/python/CMakeLists.txt index c36e5f95b5..e1cb3517d3 100644 --- a/lang/python/CMakeLists.txt +++ b/lang/python/CMakeLists.txt @@ -52,6 +52,8 @@ if(Python_Interpreter_FOUND) WORKING_DIRECTORY ${PYTHON_BINARY_DIR} COMMENT "Creating python wheel" ) + + set_property(TARGET ${create_python_wheel} PROPERTY FOLDER lang/python) else() message(FATAL_ERROR "Could not find python interpreter! This is needed to install the eCAL python binding!") endif() diff --git a/lang/python/core/CMakeLists.txt b/lang/python/core/CMakeLists.txt index ec37e6f661..7a2b72c25f 100644 --- a/lang/python/core/CMakeLists.txt +++ b/lang/python/core/CMakeLists.txt @@ -16,9 +16,21 @@ # # ========================= eCAL LICENSE ================================= +if (WIN32) + add_custom_target(copy_ecal_core_dll ALL + COMMAND cmake -E copy_if_different "$" "${PYTHON_BINARY_MODULE_DIR}" + COMMENT "Copy eCAL Core DLL to python directory" + DEPENDS eCAL::core + ) + set_property(TARGET copy_ecal_core_dll PROPERTY FOLDER lang/python/core) +endif() + +# ========================================== + project(_ecal_core_py) find_package(Python COMPONENTS Development Interpreter) +find_package(Protobuf REQUIRED) set(ecal_lang_py_src src/ecal_wrap.cxx @@ -26,11 +38,16 @@ set(ecal_lang_py_src ecal_add_python_module(${PROJECT_NAME} SOURCES ${ecal_lang_py_src} PYTHON_CODE ${CMAKE_CURRENT_SOURCE_DIR}/ecal) -target_link_libraries(${PROJECT_NAME} PRIVATE Python::Python) -target_link_libraries(${PROJECT_NAME} PRIVATE eCAL::core) -target_link_libraries(${PROJECT_NAME} PRIVATE eCAL::pb) +target_link_libraries(${PROJECT_NAME} + PRIVATE + Python::Python + eCAL::core + eCAL::pb +) -find_package(Protobuf REQUIRED) +if (WIN32) + add_dependencies(${PROJECT_NAME} copy_ecal_core_dll) +endif() set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER lang/python/core) @@ -41,4 +58,4 @@ if(ECAL_INCLUDE_PY_SAMPLES) set_property(TARGET ecal_core_py PROPERTY FOLDER lang/python/core) endif() -endif() +endif() \ No newline at end of file diff --git a/lang/python/ecalhdf5/CMakeLists.txt b/lang/python/ecalhdf5/CMakeLists.txt index 70fea24d00..3a9d933470 100644 --- a/lang/python/ecalhdf5/CMakeLists.txt +++ b/lang/python/ecalhdf5/CMakeLists.txt @@ -16,6 +16,19 @@ # # ========================= eCAL LICENSE ================================= +if (WIN32) + if (TARGET hdf5::hdf5-shared) + add_custom_target(copy_hdf5_dll ALL + COMMAND cmake -E copy_if_different "$" "${PYTHON_BINARY_MODULE_DIR}" + COMMENT "Copy hdf5 DLL to python directory" + DEPENDS hdf5::hdf5-shared + ) + set_property(TARGET copy_hdf5_dll PROPERTY FOLDER lang/python/hdf5) + endif() +endif() + +# ========================================== + project(_ecal_hdf5_py) find_package(Python COMPONENTS Development) @@ -26,8 +39,17 @@ set(ecal_lang_py_src ecal_add_python_module(${PROJECT_NAME} SOURCES ${ecal_lang_py_src} PYTHON_CODE ${CMAKE_CURRENT_SOURCE_DIR}/ecal) -target_link_libraries(${PROJECT_NAME} PRIVATE Python::Python) -target_link_libraries(${PROJECT_NAME} PRIVATE eCAL::hdf5) +target_link_libraries(${PROJECT_NAME} + PRIVATE + Python::Python + eCAL::hdf5 +) + +if (WIN32) + if (TARGET hdf5::hdf5-shared) + add_dependencies(${PROJECT_NAME} copy_hdf5_dll) + endif() +endif() if(MSVC) set_property(TARGET ${PROJECT_NAME} PROPERTY LINK_FLAGS "/ignore:4098,4099") diff --git a/lang/python/setup.py.in b/lang/python/setup.py.in index 4d56c1b114..de3707982e 100644 --- a/lang/python/setup.py.in +++ b/lang/python/setup.py.in @@ -30,10 +30,6 @@ class BinaryDistribution(Distribution): # this is the input file for cmake. for further details have a look at the # CMakeLists.txt in this directory. -data_files_platform = [] -if platform.system() == 'Windows': - data_files_platform = [('ecal',["../bin/Release/ecal_core.dll", "../bin/Release/hdf5.dll"])] - setuptools.setup ( name = 'ecal', version = '@eCAL_VERSION_STRING@', @@ -42,8 +38,8 @@ setuptools.setup ( author = 'Rex Schilasky', author_email = 'rex.schilasky@continental-corporation.com', packages = setuptools.find_packages(), - data_files = data_files_platform, - package_data = {'ecal': ['*.pyd', '*.so']}, + data_files = [], + package_data = {'ecal': ['*.pyd', '*.so', '*.dll']}, install_requires = [ 'protobuf@Protobuf_required_versions@' ],