Browse Source

pcl: fix pcb conflict for msbuild (#6852)

icysky 5 months ago
parent
commit
7a7e5c96ad

+ 4 - 4
packages/f/flann/xmake.lua

@@ -44,7 +44,7 @@ package("flann")
                 elseif is_kind("shared") then
                     add_defines("FLANN_EXPORTS")
                 end
-                add_cxxflags("/bigobj")
+                add_cxxflags("/bigobj", {tools = {"clang_cl", "cl"}})
             end
             if is_kind("static") then
                 set_suffixname("_s")
@@ -56,7 +56,7 @@ package("flann")
                 add_includedirs(".")
                 add_includedirs("flann")
                 add_packages("lz4")
-                add_languages("cxx11")
+                add_languages("cxx14")
                 add_headerfiles("(flann/config.h)", "(flann/defines.h)", "(flann/flann.h)")
                 add_headerfiles("(flann/flann.hpp)", "(flann/general.h)", "(flann/algorithms/*.h)", "(flann/io/*.h)", "(flann/nn/*.h)", "(flann/util/*.h)")
             target("flann_cuda")
@@ -68,11 +68,11 @@ package("flann")
                 add_includedirs(".")
                 add_includedirs("flann")
                 add_packages("lz4")
-                add_languages("cxx11")
+                add_languages("cxx14")
         ]], package:config("with_cuda") and "true" or "false"))
         import("package.tools.xmake").install(package)
     end)
 
     on_test(function (package)
-        assert(package:has_cfuncs("flann_find_nearest_neighbors_index", {includes = "flann/flann.h"}))
+        assert(package:has_cfuncs("flann_find_nearest_neighbors_index", {languages = "cxx14", includes = "flann/flann.h"}))
     end)

+ 106 - 0
packages/p/pcl/patches/1.14.1/clang.patch

@@ -0,0 +1,106 @@
+diff --git a/registration/include/pcl/registration/correspondence_rejection_features.h b/registration/include/pcl/registration/correspondence_rejection_features.h
+index 44835c379..f3bab8fef 100644
+--- a/registration/include/pcl/registration/correspondence_rejection_features.h
++++ b/registration/include/pcl/registration/correspondence_rejection_features.h
+@@ -269,9 +269,9 @@ protected:
+       // Check if the representations are valid
+       if (!feature_representation_->isValid(feat_src) ||
+           !feature_representation_->isValid(feat_tgt)) {
+-        PCL_ERROR("[pcl::registration::%s::getCorrespondenceScore] Invalid feature "
+-                  "representation given!\n",
+-                  this->getClassName().c_str());
++        PCL_ERROR(
++            "[pcl::registration::CorrespondenceRejectorFeatures::FeatureContainer::"
++            "getCorrespondenceScore] Invalid feature representation given!\n");
+         return (std::numeric_limits<double>::max());
+       }
+ 
+diff --git a/surface/include/pcl/surface/3rdparty/poisson4/octree_poisson.hpp b/surface/include/pcl/surface/3rdparty/poisson4/octree_poisson.hpp
+index 7ed8aaf9d..e7f45b650 100644
+--- a/surface/include/pcl/surface/3rdparty/poisson4/octree_poisson.hpp
++++ b/surface/include/pcl/surface/3rdparty/poisson4/octree_poisson.hpp
+@@ -746,7 +746,10 @@ namespace pcl
+       Real temp,dist2;
+       if(!children){return this;}
+       for(int i=0;i<Cube::CORNERS;i++){
+-        temp=SquareDistance(children[i].center,p);
++        Point3D<Real> child_center;
++        Real child_width;
++        children[i].centerAndWidth(child_center, child_width);
++        temp=SquareDistance(child_center,p);
+         if(!i || temp<dist2){
+           dist2=temp;
+           nearest=i;
+@@ -807,7 +810,7 @@ namespace pcl
+       children=NULL;
+ 
+       d=node.depth ();
+-      for(i=0;i<DIMENSION;i++){this->offset[i] = node.offset[i];}
++      for(i=0;i<DIMENSION;i++){this->off[i] = node.off[i];}
+       if(node.children){
+         initChildren();
+         for(i=0;i<Cube::CORNERS;i++){children[i] = node.children[i];}
+@@ -817,7 +820,7 @@ namespace pcl
+ 
+     template <class NodeData,class Real>
+     int OctNode<NodeData,Real>::CompareForwardDepths(const void* v1,const void* v2){
+-      return ((const OctNode<NodeData,Real>*)v1)->depth-((const OctNode<NodeData,Real>*)v2)->depth;
++      return ((const OctNode<NodeData,Real>*)v1)->depth()-((const OctNode<NodeData,Real>*)v2)->depth();
+     }
+ 
+     template< class NodeData , class Real >
+@@ -874,7 +877,7 @@ namespace pcl
+ 
+     template <class NodeData,class Real>
+     int OctNode<NodeData,Real>::CompareBackwardDepths(const void* v1,const void* v2){
+-      return ((const OctNode<NodeData,Real>*)v2)->depth-((const OctNode<NodeData,Real>*)v1)->depth;
++      return ((const OctNode<NodeData,Real>*)v2)->depth()-((const OctNode<NodeData,Real>*)v1)->depth();
+     }
+ 
+     template <class NodeData,class Real>
+diff --git a/surface/include/pcl/surface/3rdparty/poisson4/sparse_matrix.hpp b/surface/include/pcl/surface/3rdparty/poisson4/sparse_matrix.hpp
+index 24f0a5402..5e54ac786 100644
+--- a/surface/include/pcl/surface/3rdparty/poisson4/sparse_matrix.hpp
++++ b/surface/include/pcl/surface/3rdparty/poisson4/sparse_matrix.hpp
+@@ -228,14 +228,18 @@ namespace pcl
+     template<class T>
+     void SparseMatrix<T>::SetZero()
+     {
+-      Resize(this->m_N, this->m_M);
++      // copied from operator *=
++      for (int i=0; i<rows; i++)
++      {
++        for(int ii=0;ii<rowSizes[i];ii++){m_ppElements[i][ii].Value=T(0);}
++      }
+     }
+ 
+     template<class T>
+     void SparseMatrix<T>::SetIdentity()
+     {
+       SetZero();
+-      for(int ij=0; ij < Min( this->Rows(), this->Columns() ); ij++)
++      for(int ij=0; ij < std::min<int>( rows, _maxEntriesPerRow ); ij++)
+         (*this)(ij,ij) = T(1);
+     }
+ 
+@@ -388,7 +392,7 @@ namespace pcl
+       T alpha,beta,rDotR;
+       int i;
+ 
+-      solution.Resize(M.Columns());
++      solution.Resize(bb.Dimensions());
+       solution.SetZero();
+ 
+       d=r=bb;
+diff --git a/visualization/include/pcl/visualization/impl/registration_visualizer.hpp b/visualization/include/pcl/visualization/impl/registration_visualizer.hpp
+index 884735e4a..83d63906d 100644
+--- a/visualization/include/pcl/visualization/impl/registration_visualizer.hpp
++++ b/visualization/include/pcl/visualization/impl/registration_visualizer.hpp
+@@ -39,6 +39,7 @@
+ #pragma once
+ 
+ #include <thread>
++#include <chrono>
+ 
+ 
+ namespace pcl

+ 0 - 17
packages/p/pcl/patches/1.14.1/correspondence_rejection_features.patch

@@ -1,17 +0,0 @@
-diff --git a/registration/include/pcl/registration/correspondence_rejection_features.h b/registration/include/pcl/registration/correspondence_rejection_features.h
-index 44835c379..f3bab8fef 100644
---- a/registration/include/pcl/registration/correspondence_rejection_features.h
-+++ b/registration/include/pcl/registration/correspondence_rejection_features.h
-@@ -269,9 +269,9 @@ protected:
-       // Check if the representations are valid
-       if (!feature_representation_->isValid(feat_src) ||
-           !feature_representation_->isValid(feat_tgt)) {
--        PCL_ERROR("[pcl::registration::%s::getCorrespondenceScore] Invalid feature "
--                  "representation given!\n",
--                  this->getClassName().c_str());
-+        PCL_ERROR(
-+            "[pcl::registration::CorrespondenceRejectorFeatures::FeatureContainer::"
-+            "getCorrespondenceScore] Invalid feature representation given!\n");
-         return (std::numeric_limits<double>::max());
-       }
- 

+ 17 - 0
packages/p/pcl/patches/1.14.1/msbuild.patch

@@ -0,0 +1,17 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 41fb8120d..8682201ee 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -204,10 +204,8 @@ if(CMAKE_COMPILER_IS_MSVC)
+   endif()
+   string(APPEND CMAKE_CXX_FLAGS " /bigobj")
+ 
+-  if(CMAKE_GENERATOR STREQUAL "Ninja")
+-    string(APPEND CMAKE_C_FLAGS " /FS")
+-    string(APPEND CMAKE_CXX_FLAGS " /FS")
+-  endif()
++  string(APPEND CMAKE_C_FLAGS " /FS")
++  string(APPEND CMAKE_CXX_FLAGS " /FS")
+ endif()
+ 
+ if(CMAKE_COMPILER_IS_PATHSCALE)

+ 0 - 43
packages/p/pcl/patches/1.14.1/octree_poisson.patch

@@ -1,43 +0,0 @@
-diff --git a/surface/include/pcl/surface/3rdparty/poisson4/octree_poisson.hpp b/surface/include/pcl/surface/3rdparty/poisson4/octree_poisson.hpp
-index 7ed8aaf9d..e7f45b650 100644
---- a/surface/include/pcl/surface/3rdparty/poisson4/octree_poisson.hpp
-+++ b/surface/include/pcl/surface/3rdparty/poisson4/octree_poisson.hpp
-@@ -746,7 +746,10 @@ namespace pcl
-       Real temp,dist2;
-       if(!children){return this;}
-       for(int i=0;i<Cube::CORNERS;i++){
--        temp=SquareDistance(children[i].center,p);
-+        Point3D<Real> child_center;
-+        Real child_width;
-+        children[i].centerAndWidth(child_center, child_width);
-+        temp=SquareDistance(child_center,p);
-         if(!i || temp<dist2){
-           dist2=temp;
-           nearest=i;
-@@ -807,7 +810,7 @@ namespace pcl
-       children=NULL;
- 
-       d=node.depth ();
--      for(i=0;i<DIMENSION;i++){this->offset[i] = node.offset[i];}
-+      for(i=0;i<DIMENSION;i++){this->off[i] = node.off[i];}
-       if(node.children){
-         initChildren();
-         for(i=0;i<Cube::CORNERS;i++){children[i] = node.children[i];}
-@@ -817,7 +820,7 @@ namespace pcl
- 
-     template <class NodeData,class Real>
-     int OctNode<NodeData,Real>::CompareForwardDepths(const void* v1,const void* v2){
--      return ((const OctNode<NodeData,Real>*)v1)->depth-((const OctNode<NodeData,Real>*)v2)->depth;
-+      return ((const OctNode<NodeData,Real>*)v1)->depth()-((const OctNode<NodeData,Real>*)v2)->depth();
-     }
- 
-     template< class NodeData , class Real >
-@@ -874,7 +877,7 @@ namespace pcl
- 
-     template <class NodeData,class Real>
-     int OctNode<NodeData,Real>::CompareBackwardDepths(const void* v1,const void* v2){
--      return ((const OctNode<NodeData,Real>*)v2)->depth-((const OctNode<NodeData,Real>*)v1)->depth;
-+      return ((const OctNode<NodeData,Real>*)v2)->depth()-((const OctNode<NodeData,Real>*)v1)->depth();
-     }
- 
-     template <class NodeData,class Real>

+ 0 - 34
packages/p/pcl/patches/1.14.1/sparse_matrix.patch

@@ -1,34 +0,0 @@
-diff --git a/surface/include/pcl/surface/3rdparty/poisson4/sparse_matrix.hpp b/surface/include/pcl/surface/3rdparty/poisson4/sparse_matrix.hpp
-index 24f0a5402..5e54ac786 100644
---- a/surface/include/pcl/surface/3rdparty/poisson4/sparse_matrix.hpp
-+++ b/surface/include/pcl/surface/3rdparty/poisson4/sparse_matrix.hpp
-@@ -228,14 +228,18 @@ namespace pcl
-     template<class T>
-     void SparseMatrix<T>::SetZero()
-     {
--      Resize(this->m_N, this->m_M);
-+      // copied from operator *=
-+      for (int i=0; i<rows; i++)
-+      {
-+        for(int ii=0;ii<rowSizes[i];ii++){m_ppElements[i][ii].Value=T(0);}
-+      }
-     }
- 
-     template<class T>
-     void SparseMatrix<T>::SetIdentity()
-     {
-       SetZero();
--      for(int ij=0; ij < Min( this->Rows(), this->Columns() ); ij++)
-+      for(int ij=0; ij < std::min<int>( rows, _maxEntriesPerRow ); ij++)
-         (*this)(ij,ij) = T(1);
-     }
- 
-@@ -388,7 +392,7 @@ namespace pcl
-       T alpha,beta,rDotR;
-       int i;
- 
--      solution.Resize(M.Columns());
-+      solution.Resize(bb.Dimensions());
-       solution.SetZero();
- 
-       d=r=bb;

+ 2 - 3
packages/p/pcl/xmake.lua

@@ -11,9 +11,8 @@ package("pcl")
     add_versions("1.14.0", "de297b929eafcb93747f12f98a196efddf3d55e4edf1b6729018b436d5be594d")
     add_versions("1.14.1", "5dc5e09509644f703de9a3fb76d99ab2cc67ef53eaf5637db2c6c8b933b28af6")
 
-    add_patches("1.14.1", "patches/1.14.1/octree_poisson.patch", "5423a29bbb3f51bb66dca3bcb7851e037944cc33e62e816a8a8d2d00b0bdc964")
-    add_patches("1.14.1", "patches/1.14.1/sparse_matrix.patch", "90b20730956104f3ed61fc2d4de156401d0c470257def7ac4e1e2ec0a9456442")
-    add_patches("1.14.1", "patches/1.14.1/correspondence_rejection_features.patch", "20bc608eb0bd7892a6c5fc34773fd7479021d6f5f2e6f311c17b5fe60ddff6fe")
+    add_patches("1.14.1", "patches/1.14.1/clang.patch", "01bf08ac7eafc5748d38fdabac1be3b18b9ec1b2e88a4f458a2cfab3dfac5356")
+    add_patches("1.14.1", "patches/1.14.1/msbuild.patch", "2a256b8916d8c32c204bf0ec57b279d212856a5a1b28ef174aaa63e14554d082")
 
     add_configs("vtk", {description = "Build with vtk.", default = false, type = "boolean"})
     add_configs("cuda", {description = "Build with cuda.", default = false, type = "boolean"})