diff --git a/.vscode/settings.json b/.vscode/settings.json index fdb73f9c6c..6d0919271e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -137,7 +137,8 @@ "xstring": "cpp", "xtr1common": "cpp", "xtree": "cpp", - "xutility": "cpp" + "xutility": "cpp", + "execution": "cpp" }, "C_Cpp.vcFormat.indent.namespaceContents": false, "editor.formatOnSave": true, diff --git a/cmake/VISPUtils.cmake b/cmake/VISPUtils.cmake index 90015561b3..b6d9118098 100644 --- a/cmake/VISPUtils.cmake +++ b/cmake/VISPUtils.cmake @@ -1333,37 +1333,22 @@ endmacro() # Get package version from pkg-config macro(vp_get_version_from_pkg LIBNAME PKG_PATH OUTPUT_VAR) - find_package(PkgConfig) - if(PkgConfig_FOUND) - # Since pkg_check_modules updates not only _VERSION but also _FOUND, _INCLUDE_DIRS and _LIBRARIES - # we make a backup of these 3 vars to ensure compat with previous vp_get_version_from_pkg() behavior - string(TOUPPER ${LIBNAME} LIBNAME_UPPER) - if(${LIBNAME_UPPER}_INCLUDE_DIRS) - set(${LIBNAME_UPPER}_INCLUDE_DIRS_backup ${${LIBNAME_UPPER}_INCLUDE_DIRS}) - endif() - if(${LIBNAME_UPPER}_FOUND) - set(${LIBNAME_UPPER}_FOUND_backup ${${LIBNAME_UPPER}_FOUND}) - endif() - if(${LIBNAME_UPPER}_LIBRARIES) - set(${LIBNAME_UPPER}_LIBRARIES_backup ${${LIBNAME_UPPER}_LIBRARIES}) - endif() - pkg_check_modules(${LIBNAME_UPPER} QUIET ${LIBNAME}) - if(${LIBNAME_UPPER}_FOUND_backup) - set(${LIBNAME_UPPER}_FOUND ${${LIBNAME_UPPER}_FOUND_backup}) - endif() - if(${LIBNAME_UPPER}_INCLUDE_DIRS_backup) - set(${LIBNAME_UPPER}_INCLUDE_DIRS ${${LIBNAME_UPPER}_INCLUDE_DIRS_backup}) - endif() - if(${LIBNAME_UPPER}_LIBRARIES_backup) - set(${LIBNAME_UPPER}_LIBRARIES ${${LIBNAME_UPPER}_LIBRARIES_backup}) - endif() - if(${LIBNAME_UPPER}_VERSION) - set(${OUTPUT_VAR} ${${LIBNAME_UPPER}_VERSION}) - endif() - elseif(EXISTS "${PKG_PATH}/${LIBNAME}.pc") + if(EXISTS "${PKG_PATH}/${LIBNAME}.pc") # Consider the case where pkg-config is not installed file(STRINGS "${PKG_PATH}/${LIBNAME}.pc" line_to_parse REGEX "^Version:[ \t]+[0-9.]*.*$" LIMIT_COUNT 1) string(REGEX REPLACE ".*Version: ([^ ]+).*" "\\1" ${OUTPUT_VAR} "${line_to_parse}" ) + else() + find_package(PkgConfig) + if(PkgConfig_FOUND) + string(TOUPPER ${LIBNAME} LIBNAME_UPPER) + pkg_get_variable(${LIBNAME_UPPER}_PCFILEDIR ${LIBNAME} pcfiledir) + if(EXISTS "${${LIBNAME_UPPER}_PCFILEDIR}/${LIBNAME}.pc") + file(STRINGS "${${LIBNAME_UPPER}_PCFILEDIR}/${LIBNAME}.pc" line_to_parse REGEX "^Version:[ \t]+[0-9.]*.*$" LIMIT_COUNT 1) + string(REGEX REPLACE ".*Version: ([^ ]+).*" "\\1" ${OUTPUT_VAR} "${line_to_parse}" ) + unset(LIBNAME_UPPER) + mark_as_advanced(${LIBNAME_UPPER}_PCFILEDIR) + endif() + endif() endif() endmacro() diff --git a/modules/core/include/visp3/core/vpQuaternionVector.h b/modules/core/include/visp3/core/vpQuaternionVector.h index 86081b5300..1de7a148da 100644 --- a/modules/core/include/visp3/core/vpQuaternionVector.h +++ b/modules/core/include/visp3/core/vpQuaternionVector.h @@ -140,7 +140,7 @@ class VISP_EXPORT vpQuaternionVector : public vpRotationVector vpQuaternionVector operator/(double l) const; vpQuaternionVector &operator=(const vpColVector &q); #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) - vpQuaternionVector &operator=(const vpQuaternionVector &q) = default; + vpQuaternionVector &operator=(const vpQuaternionVector &) = default; vpQuaternionVector &operator=(const std::initializer_list &list); #endif diff --git a/modules/core/include/visp3/core/vpRectOriented.h b/modules/core/include/visp3/core/vpRectOriented.h index 241db96d97..dbaf468f3f 100644 --- a/modules/core/include/visp3/core/vpRectOriented.h +++ b/modules/core/include/visp3/core/vpRectOriented.h @@ -47,8 +47,8 @@ class VISP_EXPORT vpRectOriented { public: vpRectOriented(); -#if (VISP_CXX_STANDARD > VISP_CXX_STANDARD_98) - vpRectOriented(const vpRectOriented &rect) = default; +#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) + vpRectOriented(const vpRectOriented &) = default; #else vpRectOriented(const vpRectOriented &rect); #endif @@ -57,8 +57,8 @@ class VISP_EXPORT vpRectOriented vpRectOriented(const vpRect &rect); -#if (VISP_CXX_STANDARD > VISP_CXX_STANDARD_98) - vpRectOriented &operator=(const vpRectOriented &rect) = default; +#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) + vpRectOriented &operator=(const vpRectOriented &) = default; #else vpRectOriented &operator=(const vpRectOriented &rect); #endif diff --git a/modules/core/include/visp3/core/vpRxyzVector.h b/modules/core/include/visp3/core/vpRxyzVector.h index 2a72c79a65..620c930b25 100644 --- a/modules/core/include/visp3/core/vpRxyzVector.h +++ b/modules/core/include/visp3/core/vpRxyzVector.h @@ -200,7 +200,7 @@ class VISP_EXPORT vpRxyzVector : public vpRotationVector vpRxyzVector &operator=(const vpColVector &rxyz); vpRxyzVector &operator=(double x); #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) - vpRxyzVector &operator=(const vpRxyzVector &rxyz) = default; + vpRxyzVector &operator=(const vpRxyzVector &) = default; vpRxyzVector &operator=(const std::initializer_list &list); #endif }; diff --git a/modules/core/include/visp3/core/vpRzyxVector.h b/modules/core/include/visp3/core/vpRzyxVector.h index 0e7156e8ee..bca3794b16 100644 --- a/modules/core/include/visp3/core/vpRzyxVector.h +++ b/modules/core/include/visp3/core/vpRzyxVector.h @@ -201,7 +201,7 @@ class VISP_EXPORT vpRzyxVector : public vpRotationVector vpRzyxVector &operator=(const vpColVector &rzyx); vpRzyxVector &operator=(double x); #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) - vpRzyxVector &operator=(const vpRzyxVector &rzyx) = default; + vpRzyxVector &operator=(const vpRzyxVector &) = default; vpRzyxVector &operator=(const std::initializer_list &list); #endif }; diff --git a/modules/core/include/visp3/core/vpRzyzVector.h b/modules/core/include/visp3/core/vpRzyzVector.h index b7d86a2715..182784cf11 100644 --- a/modules/core/include/visp3/core/vpRzyzVector.h +++ b/modules/core/include/visp3/core/vpRzyzVector.h @@ -200,7 +200,7 @@ class VISP_EXPORT vpRzyzVector : public vpRotationVector vpRzyzVector &operator=(const vpColVector &rzyz); vpRzyzVector &operator=(double x); #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) - vpRzyzVector &operator=(const vpRzyzVector &rzyz) = default; + vpRzyzVector &operator=(const vpRzyzVector &) = default; vpRzyzVector &operator=(const std::initializer_list &list); #endif }; diff --git a/modules/core/src/tools/geometry/vpRectOriented.cpp b/modules/core/src/tools/geometry/vpRectOriented.cpp index b64d5a615f..fae09c79e4 100644 --- a/modules/core/src/tools/geometry/vpRectOriented.cpp +++ b/modules/core/src/tools/geometry/vpRectOriented.cpp @@ -82,13 +82,13 @@ vpRectOriented::vpRectOriented(const vpRect &rect) m_topRight.set_j(m_center.get_j() + m_width / 2.0); } -#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11) +#if (VISP_CXX_STANDARD == VISP_CXX_STANDARD_98) /** Copy constructor. * @param rectOriented Oriented rectangle to copy. */ vpRectOriented::vpRectOriented(const vpRectOriented &rectOriented) { *this = rectOriented; } -/** Assignement operator. +/** Assignment operator. * @param rectOriented Oriented rectangle to copy. */ vpRectOriented &vpRectOriented::operator=(const vpRectOriented &rectOriented) diff --git a/modules/core/test/math/testQuaternion.cpp b/modules/core/test/math/testQuaternion.cpp index b08e1dc4ba..0993377aae 100644 --- a/modules/core/test/math/testQuaternion.cpp +++ b/modules/core/test/math/testQuaternion.cpp @@ -169,14 +169,14 @@ TEST_CASE("Quaternion operators", "[quaternion]") vpQuaternionVector q_copy1 = vpQuaternionVector(0, 0, 1, 1); std::cout << "q_copy1=" << q_copy1 << std::endl; const vpQuaternionVector q_copy2 = q_copy1; - CHECK_FALSE((q_copy2.x() != q_copy1.x() || q_copy2.y() != q_copy1.y() || - q_copy2.z() != q_copy1.z() || q_copy2.w() != q_copy1.w())); + CHECK_FALSE((!vpMath::equal(q_copy2.x(), q_copy1.x()) || !vpMath::equal(q_copy2.y(), q_copy1.y()) || + !vpMath::equal(q_copy2.z(), q_copy1.z()) || !vpMath::equal(q_copy2.w(), q_copy1.w()))); - // compare data pointers: verify that they're not the same + // compare data pointers: verify that they're not the same CHECK(q_copy2.data != q_copy1.data); q_copy1.set(1, 0, 1, 10); - CHECK_FALSE((q_copy2.x() == q_copy1.x() && q_copy2.y() == q_copy1.y() && - q_copy2.z() == q_copy1.z() && q_copy2.w() == q_copy1.w())); + CHECK((vpMath::equal(q_copy2.x(), q_copy1.x()) || vpMath::equal(q_copy2.y(), q_copy1.y()) || + vpMath::equal(q_copy2.z(), q_copy1.z()) || vpMath::equal(q_copy2.w(), q_copy1.w()))); std::cout << "q_copy1 after set = " << q_copy1 << std::endl; std::cout << "q_copy2=" << q_copy2 << std::endl; } @@ -186,15 +186,15 @@ TEST_CASE("Quaternion operators", "[quaternion]") const vpQuaternionVector q1 = vpQuaternionVector(0, 0, 1, 1); vpQuaternionVector q_same(10, 10, 10, 10); q_same = q1; - CHECK_FALSE((q_same.x() != q1.x() || q_same.y() != q1.y() || - q_same.z() != q1.z() || q_same.w() != q1.w())); + + CHECK_FALSE((!vpMath::equal(q_same.x(), q1.x()) || !vpMath::equal(q_same.y(), q1.y()) || + !vpMath::equal(q_same.z(), q1.z()) || !vpMath::equal(q_same.w(), q1.w()))); // compare data pointers: verify that they're not the same CHECK(q_same.data != q1.data); } } - int main(int argc, char *argv[]) { Catch::Session session; // There must be exactly one instance diff --git a/modules/python/generator/visp_python_bindgen/methods.py b/modules/python/generator/visp_python_bindgen/methods.py index 12748c093d..61376860da 100644 --- a/modules/python/generator/visp_python_bindgen/methods.py +++ b/modules/python/generator/visp_python_bindgen/methods.py @@ -352,7 +352,7 @@ def make_keep_alive_str(values) -> str: # Params that are only outputs: they should be declared in function. Assume that they are default constructible param_is_only_output = [not is_input and is_output for is_input, is_output in zip(param_is_input, param_is_output)] param_type_decl = [get_type_for_declaration(method.parameters[i].type, specs, header_env.mapping) for i in range(len(param_is_only_output))] - param_decl_data = [(param_type_decl[i], param_names[i], get_default_assignement_str(param_type_decl[i])) for i in range(len(param_is_only_output)) if param_is_only_output[i]] + param_decl_data = [(param_type_decl[i], param_names[i], get_default_assignment_str(param_type_decl[i])) for i in range(len(param_is_only_output)) if param_is_only_output[i]] param_declarations = [f'{decl_type} {name}{assignment};' for (decl_type, name, assignment) in param_decl_data] param_declarations = '\n'.join(param_declarations) diff --git a/modules/python/generator/visp_python_bindgen/utils.py b/modules/python/generator/visp_python_bindgen/utils.py index b12ec4ce95..1eeeb9140c 100644 --- a/modules/python/generator/visp_python_bindgen/utils.py +++ b/modules/python/generator/visp_python_bindgen/utils.py @@ -259,7 +259,7 @@ def get_type_for_declaration(param: Union[types.FunctionType, types.DecoratedTyp else: return get_type(param, owner_specs, header_env_mapping) -def get_default_assignement_str(type: str) -> str: +def get_default_assignment_str(type: str) -> str: inits = [ (['int', 'unsigned', 'uint8_t', 'uint16_t', 'size_t', 'ssize_t'], '0'), (['float'], '0.f'), diff --git a/modules/sensor/include/visp3/sensor/vpLaserScan.h b/modules/sensor/include/visp3/sensor/vpLaserScan.h index 7c98fcd5ce..bd63f47772 100644 --- a/modules/sensor/include/visp3/sensor/vpLaserScan.h +++ b/modules/sensor/include/visp3/sensor/vpLaserScan.h @@ -90,7 +90,7 @@ class /*VISP_EXPORT*/ vpLaserScan inline std::vector getScanPoints() { return listScanPoints; } #if VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11 - vpLaserScan &operator=(const vpLaserScan &scan) = default; + vpLaserScan &operator=(const vpLaserScan &) = default; #endif /*! Specifies the id of former measurements and increases with every measurement. */ diff --git a/modules/tracker/mbt/src/vpMbtPolygon.cpp b/modules/tracker/mbt/src/vpMbtPolygon.cpp index 5f9a2998c1..3950b3760c 100644 --- a/modules/tracker/mbt/src/vpMbtPolygon.cpp +++ b/modules/tracker/mbt/src/vpMbtPolygon.cpp @@ -61,8 +61,7 @@ vpMbtPolygon::vpMbtPolygon(const vpMbtPolygon &mbtp) minLineLengthThresh(mbtp.minLineLengthThresh), minPolygonAreaThresh(mbtp.minPolygonAreaThresh), name(mbtp.name), hasOrientation(mbtp.hasOrientation) { - //*this = mbtp; // Should not be called by copy constructor to avoid multiple - // assignements. + //*this = mbtp; // Should not be called by copy constructor to avoid multiple assignments. } vpMbtPolygon &vpMbtPolygon::operator=(const vpMbtPolygon &mbtp)