From c6b4f4a8f6ebefb9530f3f2a3a3f280c3ffa1f77 Mon Sep 17 00:00:00 2001 From: Samuel Felton Date: Mon, 23 Sep 2024 17:02:00 +0200 Subject: [PATCH] Python bindings: rbt config, enable parallel LTO when supported by compiler --- modules/python/bindings/CMakeLists.txt | 29 ++- modules/python/config/rbt.json | 262 +++++++++++++++++++++++++ 2 files changed, 290 insertions(+), 1 deletion(-) diff --git a/modules/python/bindings/CMakeLists.txt b/modules/python/bindings/CMakeLists.txt index 9f62524a58..55864de695 100644 --- a/modules/python/bindings/CMakeLists.txt +++ b/modules/python/bindings/CMakeLists.txt @@ -38,15 +38,42 @@ set_source_files_properties(${python_bindings_cpp_src} PROPERTIES GENERATED TRUE pybind11_add_module(_visp ${python_bindings_cpp_src}) + + + # Place library in build/modules/python/bindings dir so that it doesn't pollute lib dir # This .so file is not treated the same as the others and we shouldn't link against it when compiling in C++ # when installing the python module, pip will look into this subfolder for .so files to copy into the site-packages file(MAKE_DIRECTORY "${bindings_gen_location}/src") +get_target_property(PYTHON_CXX_FLAGS _visp COMPILE_OPTIONS) +get_target_property( PYTHON_LINKER_FLAGS _visp LINK_OPTIONS) + + +set_target_properties(_visp PROPERTIES COMPILE_FLAGS ${PYTHON_CXX_FLAGS}) +if(PYTHON_CXX_FLAGS STREQUAL "PYTHON_CXX_FLAGS-NOTFOUND") + SET(PYTHON_CXX_FLAGS "") # Set to empty string +else() + SET(PYTHON_CXX_FLAGS "${PYTHON_CXX_FLAGS} ") # A space to cleanly separate from existing content +endif() +if(PYTHON_LINKER_FLAGS STREQUAL "PYTHON_LINKER_FLAGS-NOTFOUND") +SET(PYTHON_LINKER_FLAGS "") # Set to empty string +else() +SET(PYTHON_LINKER_FLAGS "${PYTHON_LINKER_FLAGS} ") # A space to cleanly separate from existing content +endif() +CHECK_CXX_COMPILER_FLAG("-flto=auto" COMPILER_SUPPORTS_FLTOAUTO) +if(COMPILER_SUPPORTS_FLTOAUTO) + SET(PYTHON_CXX_FLAGS "${PYTHON_CXX_FLAGS} -flto=auto") + SET(PYTHON_LINKER_FLAGS "${PYTHON_LINKER_FLAGS} -flto=auto") +endif() + +set_target_properties(_visp PROPERTIES COMPILE_FLAGS ${PYTHON_CXX_FLAGS}) +set_target_properties(_visp PROPERTIES LINK_FLAGS ${PYTHON_LINKER_FLAGS}) + + set_target_properties(_visp PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" - ) # With MSVC, the compiled pyd file is placed in a Release/Debug folder set(build_configs "NONE" "RELEASE" "DEBUG" "RELEASEWITHDEBINFO" "RELWITHDEBINFO") diff --git a/modules/python/config/rbt.json b/modules/python/config/rbt.json index eb1680fa79..46480c17c0 100644 --- a/modules/python/config/rbt.json +++ b/modules/python/config/rbt.json @@ -23,6 +23,268 @@ "vpRBDriftDetector" ] } + ], + "acknowledge_pointer_or_ref_fields": [ + "std::map(const nlohmann::json&)>>", + "std::function" + ] + }, + "vpRBTracker": { + "methods": [ + { + "static": false, + "signature": "const vpRBFeatureTrackerInput& getMostRecentFrame()", + "return_policy": "reference", + "keep_alive": [ + [ + 1, + 0 + ] + ], + "returns_ref_ok": true + }, + { + "static": false, + "signature": "const vpRBTrackerLogger& getLogger()", + "return_policy": "reference", + "keep_alive": [ + [ + 1, + 0 + ] + ], + "returns_ref_ok": true + }, + { + "static": false, + "signature": "vpObjectCentricRenderer& getRenderer()", + "return_policy": "reference", + "keep_alive": [ + [ + 1, + 0 + ] + ], + "returns_ref_ok": true + } + ] + }, + "vpRBRenderData": { + "methods": [ + { + "static": false, + "signature": " vpRBRenderData(vpRBRenderData&&)", + "ignore": true + }, + { + "static": false, + "signature": "vpRBRenderData& operator=(vpRBRenderData&&)", + "ignore": true + } + ] + }, + "vpRBFeatureTrackerInput": { + "methods": [ + { + "static": false, + "signature": " vpRBFeatureTrackerInput(vpRBFeatureTrackerInput&&)", + "ignore": true + }, + { + "static": false, + "signature": "vpRBFeatureTrackerInput& operator=(vpRBFeatureTrackerInput&&)", + "ignore": true + } + ] + }, + "vpRBFeatureTracker": { + "methods": [ + { + "static": false, + "signature": "const vpColVector& getWeightedError()", + "return_policy": "reference", + "keep_alive": [ + [ + 1, + 0 + ] + ], + "returns_ref_ok": true + } + ] + }, + "vpRBSilhouetteControlPoint": { + "acknowledge_pointer_or_ref_fields": [ + "const vpMe*", + "const vpCameraParameters*" + ], + "methods": [ + { + "static": false, + "signature": " vpRBSilhouetteControlPoint(const vpRBSilhouetteControlPoint&&)", + "ignore": true + }, + { + "static": false, + "signature": "vpRBSilhouetteControlPoint& operator=(const vpRBSilhouetteControlPoint&&)", + "ignore": true + }, + { + "static": false, + "signature": "const vpLine& getLine()", + "return_policy": "reference", + "keep_alive": [ + [ + 1, + 0 + ] + ], + "returns_ref_ok": true + }, + { + "static": false, + "signature": "const vpFeatureLine& getFeatureLine()", + "return_policy": "reference", + "keep_alive": [ + [ + 1, + 0 + ] + ], + "returns_ref_ok": true + }, + { + "static": false, + "signature": "vpMeSite& getSite()", + "return_policy": "reference", + "keep_alive": [ + [ + 1, + 0 + ] + ], + "returns_ref_ok": true + }, + { + "static": false, + "signature": "const vpMeSite& getSite()", + "return_policy": "reference", + "keep_alive": [ + [ + 1, + 0 + ] + ], + "returns_ref_ok": true + }, + { + "static": false, + "signature": "const vpCameraParameters& getCameraParameters()", + "return_policy": "reference", + "keep_alive": [ + [ + 1, + 0 + ] + ], + "returns_ref_ok": true + } + ] + }, + "vpRBKltTracker": { + "methods": [ + { + "static": false, + "signature": "vpKltOpencv& getKltTracker()", + "return_policy": "reference", + "keep_alive": [ + [ + 1, + 0 + ] + ], + "returns_ref_ok": true + }, + { + "static": false, + "signature": "const vpKltOpencv& getKltTracker()", + "ignore": true + } + ] + }, + "vpRBDriftDetectorFactory": { + "methods": [ + { + "static": true, + "signature": "vpRBDriftDetectorFactory& getFactory()", + "return_policy": "reference", + "keep_alive": [ + [ + 1, + 0 + ] + ], + "returns_ref_ok": true + } + ] + }, + "vpObjectMaskFactory": { + "methods": [ + { + "static": true, + "signature": "vpObjectMaskFactory& getFactory()", + "return_policy": "reference", + "keep_alive": [ + [ + 1, + 0 + ] + ], + "returns_ref_ok": true + } + ] + }, + "vpRBFeatureTrackerFactory": { + "methods": [ + { + "static": true, + "signature": "vpRBFeatureTrackerFactory& getFactory()", + "return_policy": "reference", + "keep_alive": [ + [ + 1, + 0 + ] + ], + "returns_ref_ok": true + } + ] + }, + "vpObjectCentricRenderer": { + "methods": [ + { + "static": false, + "signature": "void computeClipping(float&, float&)", + "use_default_param_policy": false, + "param_is_input": [ + false, + false + ], + "param_is_output": [ + true, + true + ] + } + ] + }, + "vpPanda3DDepthGaussianBlur": { + "acknowledge_pointer_or_ref_fields": [ + "const char*" + ] + }, + "vpPanda3DDepthCannyFilter": { + "acknowledge_pointer_or_ref_fields": [ + "const char*" ] } },