Add vcpkg support for easier dependency management - #7386
Conversation
|
Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes. |
This PR adds native vcpkg support to Open3D, enabling easier builds with
vcpkg-managed dependencies.
Changes:
- Add vcpkg toolchain auto-detection in CMakeLists.txt
- Auto-enable USE_SYSTEM_* options when vcpkg is detected
- Fix find_package() for vcpkg compatibility:
- jsoncpp: Add JsonCpp::JsonCpp target (vcpkg naming)
- curl: Use find_package(CURL) instead of pkg-config
- zeromq: Use find_package(ZeroMQ) instead of pkg-config
- minizip: Use find_package(unofficial-minizip) instead of pkg-config
- Fix CURL_STATICLIB redefinition warning in Download.cpp
- Add vcpkg.json manifest for dependency specification
- Fix typo: USE_USE_SYSTEM_ZEROMQ -> USE_SYSTEM_ZEROMQ
All changes are backwards compatible - non-vcpkg builds work as before.
Usage with vcpkg:
cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake \
-DBUILD_PYTHON_MODULE=OFF -DBUILD_GUI=OFF ..
77549fa to
07abfbb
Compare
There was a problem hiding this comment.
🟡 Not ready to approve
Download.cpp still unconditionally defines CURL_STATICLIB, which can break vcpkg/system builds that link against a shared/DLL libcurl (common on Windows).
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
This PR introduces Phase 1 “native vcpkg support” in Open3D’s CMake build by detecting the vcpkg toolchain, preferring system/vcpkg-provided dependencies, and updating dependency discovery to be compatible with common vcpkg CMake target names.
Changes:
- Add vcpkg toolchain detection in
CMakeLists.txtand automatically enable manyUSE_SYSTEM_*dependency options when vcpkg is detected. - Improve
find_package()compatibility for vcpkg (JsonCpp target naming; preferfind_package(CURL),find_package(ZeroMQ), andfind_package(unofficial-minizip)with pkg-config fallbacks). - Add a
vcpkg.jsonmanifest and record the change inCHANGELOG.md.
File summaries
| File | Description |
|---|---|
vcpkg.json |
Adds a vcpkg manifest declaring Open3D dependencies and optional feature flags. |
cpp/open3d/utility/Download.cpp |
Wraps CURL_STATICLIB definition to avoid macro redefinition warnings. |
CMakeLists.txt |
Detects vcpkg toolchain and forces many USE_SYSTEM_* options ON in vcpkg mode. |
CHANGELOG.md |
Adds a changelog entry for vcpkg support. |
3rdparty/find_dependencies.cmake |
Adjusts dependency discovery to prefer vcpkg-friendly find_package() targets with fallbacks. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
Manifest mode from vcpkg.json broke ad-hoc glslang installs on Windows CI; use classic mode for that step. Define CURL_STATICLIB only for bundled static libcurl so vcpkg shared curl builds stay correct. Co-authored-by: Cursor <cursoragent@cursor.com>
Set USE_SYSTEM_* cache defaults before option() without FORCE so users can override with -DUSE_SYSTEM_<PKG>=OFF. Use vcpkg embree port 4.x instead of embree3. Co-authored-by: Cursor <cursoragent@cursor.com>
This PR adds native vcpkg support to Open3D, enabling easier builds with vcpkg-managed dependencies.
Note: This is Phase 1 of vcpkg support - upstream changes to Open3D's build system. Phase 2 (creating the actual vcpkg port in microsoft/vcpkg) will follow after this PR is merged.
Changes
All changes are backwards compatible - non-vcpkg builds work as before.
Roadmap for Full vcpkg Support
Note: CUDA is supported in Phase 1 - just install CUDA Toolkit separately and use
-DBUILD_CUDA_MODULE=ONType
Motivation and Context
vcpkg is a popular C++ package manager used by many developers, but Open3D has lacked native vcpkg support since 2019 (#767). Previous attempts (microsoft/vcpkg#17423) failed due to pkg-config path issues and missing CMake target compatibility.
This PR enables Open3D to build seamlessly with vcpkg-managed dependencies by:
Checklist:
python util/check_style.py --applyto apply Open3D code styleto my code.
updated accordingly.
results (e.g. screenshots or numbers) here.
Description
Changes Made
CMakeLists.txt3rdparty/find_dependencies.cmake3rdparty/stdgpu/stdgpu.cmakecpp/open3d/utility/Download.cppvcpkg.jsonTest Results
Successfully built on Ubuntu 22.04 with vcpkg:
Current Scope (Phase 1)
Dependencies from vcpkg (verified working)
assimp, curl, eigen3, fmt, glew, glfw3, jpeg, jsoncpp, msgpack, nanoflann, openssl, png, qhull, tbb, tinyobjloader, zeromq, cppzmq, minizip
Backwards Compatibility
All changes include fallbacks - non-vcpkg builds work exactly as before.
Next Steps After This PR