Skip to content

Commit

Permalink
[pcl] Devendor zlib, cleanup, enable arm64-windows (microsoft#30996)
Browse files Browse the repository at this point in the history
* [pcl] De-vendor zlib, misc fixes

* WIP

* vcpkg_copy_tools with AUTO_CLEAN

* WIP

* Fix empty executable suffix

* Finish PR

* [glew] arm64 MSVC is unsupported

* [openmvg] x86 family only
  • Loading branch information
dg0yt authored Apr 24, 2023
1 parent 9342b62 commit 0df4519
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 32 deletions.
3 changes: 2 additions & 1 deletion ports/glew/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "glew",
"version": "2.2.0",
"port-version": 1,
"port-version": 2,
"description": "The OpenGL Extension Wrangler Library (GLEW) is a cross-platform open-source C/C++ extension loading library.",
"homepage": "https://github.com/nigels-com/glew",
"supports": "!(arm64 & windows)",
"dependencies": [
"opengl",
{
Expand Down
4 changes: 2 additions & 2 deletions ports/openmvg/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "openmvg",
"version": "2.0",
"port-version": 6,
"port-version": 7,
"description": "open Multiple View Geometry library. Basis for 3D computer vision and Structure from Motion.",
"license": "MPL-2.0-no-copyleft-exception",
"supports": "!(osx & arm64)",
"supports": "x86 | x64",
"dependencies": [
"cereal",
{
Expand Down
76 changes: 76 additions & 0 deletions ports/pcl/devendor-zlib.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
diff --git a/surface/include/pcl/surface/3rdparty/opennurbs/opennurbs_zlib.h b/surface/include/pcl/surface/3rdparty/opennurbs/opennurbs_zlib.h
index 12787e1..b500233 100644
--- a/surface/include/pcl/surface/3rdparty/opennurbs/opennurbs_zlib.h
+++ b/surface/include/pcl/surface/3rdparty/opennurbs/opennurbs_zlib.h
@@ -31,13 +31,16 @@

#if !defined(Z_PREFIX)
/* decorates zlib functions with a "z_" prefix to prevent symbol collision. */
-#define Z_PREFIX
#endif
+#define z_deflate deflate
+#define z_inflate inflate
+#define z_Bytef Bytef

#if !defined(MY_ZCALLOC)
/* have zlib use oncalloc() and onfree() for memory managment*/
-#define MY_ZCALLOC
#endif
+#define zcalloc pcl_zcalloc
+#define zcfree pcl_zcfree

#include "zlib.h"

diff --git a/surface/src/3rdparty/opennurbs/openNURBS.cmake b/surface/src/3rdparty/opennurbs/openNURBS.cmake
index 51ca678..4ee5192 100644
--- a/surface/src/3rdparty/opennurbs/openNURBS.cmake
+++ b/surface/src/3rdparty/opennurbs/openNURBS.cmake
@@ -102,6 +102,8 @@ set(OPENNURBS_INCLUDES
include/pcl/${SUBSYS_NAME}/3rdparty/opennurbs/opennurbs_workspace.h
include/pcl/${SUBSYS_NAME}/3rdparty/opennurbs/opennurbs_xform.h
include/pcl/${SUBSYS_NAME}/3rdparty/opennurbs/opennurbs_zlib.h
+)
+file(REMOVE
include/pcl/${SUBSYS_NAME}/3rdparty/opennurbs/crc32.h
include/pcl/${SUBSYS_NAME}/3rdparty/opennurbs/deflate.h
include/pcl/${SUBSYS_NAME}/3rdparty/opennurbs/inffast.h
@@ -222,6 +224,8 @@ set(OPENNURBS_SOURCES
src/3rdparty/opennurbs/opennurbs_xform.cpp
src/3rdparty/opennurbs/opennurbs_zlib.cpp
src/3rdparty/opennurbs/opennurbs_zlib_memory.cpp
+)
+file(REMOVE
src/3rdparty/opennurbs/adler32.c
src/3rdparty/opennurbs/compress.c
src/3rdparty/opennurbs/crc32.c
diff --git a/surface/src/3rdparty/opennurbs/opennurbs_zlib.cpp b/surface/src/3rdparty/opennurbs/opennurbs_zlib.cpp
index 688c803..d1bc977 100644
--- a/surface/src/3rdparty/opennurbs/opennurbs_zlib.cpp
+++ b/surface/src/3rdparty/opennurbs/opennurbs_zlib.cpp
@@ -68,7 +68,6 @@

#endif // if WIN64 else WIN32

-#pragma comment(lib, "\"" OPENNURBS_ZLIB_OUTPUT_ROOT_DIR "/" OPENNURBS_CONFIGURATION_DIR "/" OPENNURBS_ZLIB_FILE_NAME "\"")

#endif // ON_DLL_EXPORTS

@@ -641,7 +640,7 @@ struct ON_CompressedBufferHelper
sizeof_x_buffer = 16384
};
unsigned char buffer[sizeof_x_buffer];
- z_stream strm;
+ z_stream strm = []() { z_stream zs; zs.zalloc = zcalloc; zs.zfree = zcfree; return zs; } ();
std::size_t m_buffer_compressed_capacity;
};

diff --git a/surface/src/on_nurbs/on_nurbs.cmake b/surface/src/on_nurbs/on_nurbs.cmake
index 20d4269..a7b5631 100644
--- a/surface/src/on_nurbs/on_nurbs.cmake
+++ b/surface/src/on_nurbs/on_nurbs.cmake
@@ -55,3 +55,5 @@ else()
set(ON_NURBS_SOURCES ${ON_NURBS_SOURCES} src/on_nurbs/nurbs_solve_eigen.cpp)
endif()

+find_package(ZLIB REQUIRED)
+set(ON_NURBS_LIBRARIES ${ON_NURBS_LIBRARIES} ${ZLIB_LIBRARIES})
54 changes: 32 additions & 22 deletions ports/pcl/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,54 +16,59 @@ vcpkg_from_github(
outofcore_viewer_remove_include.patch
fix_opennurbs_win32.patch
disable_kinfu_for_cuda12.patch
devendor-zlib.patch
)

string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" PCL_SHARED_LIBS)

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
openni2 WITH_OPENNI2
qt WITH_QT
pcap WITH_PCAP
apps BUILD_apps
cuda WITH_CUDA
cuda BUILD_CUDA
cuda BUILD_GPU
tools BUILD_tools
opengl WITH_OPENGL
examples BUILD_examples
libusb WITH_LIBUSB
opengl WITH_OPENGL
openni2 WITH_OPENNI2
pcap WITH_PCAP
qt WITH_QT
simulation BUILD_simulation
surface-on-nurbs BUILD_surface_on_nurbs
tools BUILD_tools
visualization WITH_VTK
visualization BUILD_visualization
examples BUILD_examples
apps BUILD_apps
# These 2 apps need openni1
#apps BUILD_apps_in_hand_scanner
#apps BUILD_apps_3d_rec_framework
simulation BUILD_simulation
)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
# BUILD
-DBUILD_surface_on_nurbs=ON
# PCL
-DPCL_ALLOW_BOTH_SHARED_AND_STATIC_DEPENDENCIES=ON
-DPCL_BUILD_WITH_BOOST_DYNAMIC_LINKING_WIN32=${PCL_SHARED_LIBS}
-DPCL_BUILD_WITH_FLANN_DYNAMIC_LINKING_WIN32=${PCL_SHARED_LIBS}
-DPCL_BUILD_WITH_QHULL_DYNAMIC_LINKING_WIN32=${PCL_SHARED_LIBS}
-DPCL_SHARED_LIBS=${PCL_SHARED_LIBS}
-DPCL_ALLOW_BOTH_SHARED_AND_STATIC_DEPENDENCIES=ON
# WITH
-DWITH_PNG=ON
-DWITH_QHULL=ON
-DWITH_OPENNI=OFF
-DWITH_ENSENSO=OFF
-DWITH_DAVIDSDK=OFF
-DWITH_DOCS=OFF
-DWITH_DSSDK=OFF
-DWITH_ENSENSO=OFF
-DWITH_OPENMP=OFF
-DWITH_OPENNI=OFF
-DWITH_PNG=ON
-DWITH_QHULL=ON
-DWITH_RSSDK=OFF
-DWITH_RSSDK2=OFF
-DWITH_OPENMP=OFF
# FEATURES
${FEATURE_OPTIONS}
OPTIONS_DEBUG
-DBUILD_apps=OFF
-DBUILD_examples=OFF
-DBUILD_tools=OFF
MAYBE_UNUSED_VARIABLES
PCL_BUILD_WITH_FLANN_DYNAMIC_LINKING_WIN32
PCL_BUILD_WITH_QHULL_DYNAMIC_LINKING_WIN32
Expand Down Expand Up @@ -103,12 +108,17 @@ file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")

if(BUILD_tools OR BUILD_apps OR BUILD_examples)
file(GLOB EXEFILES_RELEASE "${CURRENT_PACKAGES_DIR}/bin/*${VCPKG_TARGET_EXECUTABLE_SUFFIX}")
file(GLOB EXEFILES_DEBUG "${CURRENT_PACKAGES_DIR}/debug/bin/*${VCPKG_TARGET_EXECUTABLE_SUFFIX}")
file(COPY ${EXEFILES_RELEASE} DESTINATION "${CURRENT_PACKAGES_DIR}/tools/pcl")
file(REMOVE ${EXEFILES_RELEASE} ${EXEFILES_DEBUG})
vcpkg_copy_tool_dependencies("${CURRENT_PACKAGES_DIR}/tools/pcl")
file(GLOB tool_names
LIST_DIRECTORIES false
RELATIVE "${CURRENT_PACKAGES_DIR}/bin"
"${CURRENT_PACKAGES_DIR}/bin/*${VCPKG_TARGET_EXECUTABLE_SUFFIX}"
)
if(VCPKG_TARGET_EXECUTABLE_SUFFIX)
string(REPLACE "." "[.]" suffix "${VCPKG_TARGET_EXECUTABLE_SUFFIX}")
list(TRANSFORM tool_names REPLACE "${suffix}\$" "")
endif()
vcpkg_copy_tools(TOOL_NAMES ${tool_names} AUTO_CLEAN)
endif()

file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(INSTALL "${SOURCE_PATH}/LICENSE.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt")
14 changes: 11 additions & 3 deletions ports/pcl/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"name": "pcl",
"version": "1.13.0",
"port-version": 2,
"port-version": 3,
"description": "Point Cloud Library (PCL) is open source library for 2D/3D image and point cloud processing.",
"homepage": "https://github.com/PointCloudLibrary/pcl",
"license": "BSD-3-Clause",
"supports": "!(arm64 & windows)",
"dependencies": [
"boost-asio",
"boost-date-time",
Expand Down Expand Up @@ -78,7 +77,10 @@
]
},
"opengl": {
"description": "OpenGL support for PCL"
"description": "OpenGL support for PCL",
"dependencies": [
"opengl"
]
},
"openni2": {
"description": "OpenNI2 support for PCL",
Expand Down Expand Up @@ -131,6 +133,12 @@
}
]
},
"surface-on-nurbs": {
"description": "Fitting NURBS to point clouds",
"dependencies": [
"zlib"
]
},
"tools": {
"description": "Build PCL utilities",
"supports": "!static",
Expand Down
1 change: 0 additions & 1 deletion scripts/ci.baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ gherkin-c:x64-windows = skip
gherkin-c:x64-windows-static = skip
gherkin-c:x64-windows-static-md = skip
gherkin-c:x86-windows = skip
glew:arm64-windows=fail
glfw3:arm-uwp=fail
glfw3:x64-uwp=fail
glibmm:x64-windows-static-md=fail
Expand Down
6 changes: 3 additions & 3 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -2802,7 +2802,7 @@
},
"glew": {
"baseline": "2.2.0",
"port-version": 1
"port-version": 2
},
"glfw3": {
"baseline": "3.3.8",
Expand Down Expand Up @@ -5862,7 +5862,7 @@
},
"openmvg": {
"baseline": "2.0",
"port-version": 6
"port-version": 7
},
"openmvs": {
"baseline": "2.1.0",
Expand Down Expand Up @@ -6058,7 +6058,7 @@
},
"pcl": {
"baseline": "1.13.0",
"port-version": 2
"port-version": 3
},
"pcre": {
"baseline": "8.45",
Expand Down
5 changes: 5 additions & 0 deletions versions/g-/glew.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "1fbf96a084cd511f49fa7f7009b56bd3d3361fb0",
"version": "2.2.0",
"port-version": 2
},
{
"git-tree": "90dfc684e6af42587e36df4e2167d7420424e829",
"version": "2.2.0",
Expand Down
5 changes: 5 additions & 0 deletions versions/o-/openmvg.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "58d0c2b4b7785f8ace8ff861d5e45ef40619dcc6",
"version": "2.0",
"port-version": 7
},
{
"git-tree": "5c54c4aa02d2a668bd3d97a1b2a9d412efe284d3",
"version": "2.0",
Expand Down
5 changes: 5 additions & 0 deletions versions/p-/pcl.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "c780fc254eb97b60360f60c43034a625667c6530",
"version": "1.13.0",
"port-version": 3
},
{
"git-tree": "0c53a841b49d311f52e047bc61455479475c446e",
"version": "1.13.0",
Expand Down

0 comments on commit 0df4519

Please sign in to comment.