CedricGuillemet / ImGuizmo

Immediate mode 3D gizmo for scene editing and other controls based on Dear Imgui
MIT License
3.22k stars 907 forks source link

Update in vcpkg #286

Open NikolayKanchevski opened 1 year ago

NikolayKanchevski commented 1 year ago

Hi, thanks for the great framework!

I was just wondering if it would be possible for you to update it in vcpkg, as it is outdated.

Thanks!

crud89 commented 1 year ago

As the readme says:

Latest stable tagged version is 1.83. Current master version is 1.84 WIP.

The last stable version is 1.83, which is also used by the vcpkg port. If you want to use a more recent version, you can easily achieve this on your own using overlay ports. This is actually pretty straightforward. Create a folder somewhere in your repository that stores the overlay, e.g., ./modules/overlay-ports/imguizmo/. Then copy all files from here into this directory. Next open the portfile.cmake and replace the reference revision with the commit id you need. For example, the latest commit to date is fbc3614abcc642de7f3868cc0d68a35503ca9a4e. Also set the SHA512 to 0.

vcpkg_from_github(
    OUT_SOURCE_PATH SOURCE_PATH
    REPO CedricGuillemet/ImGuizmo
    REF fbc3614abcc642de7f3868cc0d68a35503ca9a4e
    SHA512 0
    HEAD_REF master
)

Next, tell vcpkg to pick up the overlay port. Using CMake you can do this using:

SET(VCPKG_OVERLAY_PORTS "${CMAKE_SOURCE_DIR}/modules/overlay-ports/imguizmo/")

This of course assumes, that your top-level CMakeLists.txt is placed in the root directory of the repository and that you are using the vcpkg toolchain file. If you are running vcpkg from command line use --overlay-ports=... instead:

.\vcpkg.exe install imguizmo --overlay-ports=modules/overlay-ports/imguizmo/

Alternatively, you can create a vcpkg-configuration.json file that lists the overlay-ports directory.

Whichever way you decide to go, running this the first time should yield an error, saying that there was a mismatch in the archive hashes. This error also prints the correct archive hash:

[DEBUG] Downloading https://github.com/CedricGuillemet/ImGuizmo/archive/fbc3614abcc642de7f3868cc0d68a35503ca9a4e.tar.gz
CUSTOMBUILD : error : Failed to download from mirror set:
File does not have the expected hash:
             url : [ https://github.com/CedricGuillemet/ImGuizmo/archive/fbc3614abcc642de7f3868cc0d68a35503ca9a4e.tar.gz ]
       File path : [ .\modules\vcpkg\downloads\CedricGuillemet-ImGuizmo-fbc3614abcc642de7f3868cc0d68a35503ca9a4e.tar.gz.10792.part ]
   Expected hash : [ 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ]
     Actual hash : [ c9d57575478590d59d019fb35a6179ff73654c99c3a170849e8197b4be4c478a86aa118764fed96bdb659031a45de8572a7089f0dcff3554f3320d955e14cdf0 ]

Copy this hash into the portfile.cmake file where we earlier placed the 0 and retry. That should do the trick. 🙃