Skip to content

Adapt vcpkg patches and update vcpkg port to 4.5 #1882

@kelteseth

Description

@kelteseth

Godot version

4.5

godot-cpp version

4.5

System information

Windows 11

Issue description

Currently, the vcpkg version of godot-cpp is at 4.4. With a custom install step that is needed by vcpkg. We should integrate these changes into godot-cpp directly. I'm currently working on porting our custom godot-cpp-vcpkg fork to 4.5 and I'm facing some challanges since there have been some changes regarding CMake generator expression. I would like to update the vcpkg port, but I need some feedback first:

The current 4.4 patch alters several files, but I have moved the install code into a dedicated file and included it at the end of the main CMakeLists.txt via include("cmake/install.cmake") to make it easier to read.

My install.cmake now uses generator expressions

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

# Install the godot-cpp target
install(TARGETS godot-cpp
    EXPORT unofficial-godot-cpp-config
    ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
    LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
    RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
)

install(
    DIRECTORY
        "${CMAKE_CURRENT_SOURCE_DIR}/include/"
        "${CMAKE_CURRENT_BINARY_DIR}/gen/include/"
    DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)

install(FILES "${GODOTCPP_GDEXTENSION_DIR}/gdextension_interface.h"
    DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)

install(
    EXPORT unofficial-godot-cpp-config
    NAMESPACE unofficial::
    DESTINATION "${CMAKE_INSTALL_DATADIR}/unofficial-godot-cpp"
)

write_basic_package_version_file(
    "${CMAKE_CURRENT_BINARY_DIR}/unofficial-godot-cpp-config-version.cmake"
    VERSION "${PROJECT_VERSION}"
    COMPATIBILITY SameMinorVersion
)

install(
    FILES "${CMAKE_CURRENT_BINARY_DIR}/unofficial-godot-cpp-config-version.cmake"
    DESTINATION "${CMAKE_INSTALL_DATADIR}/unofficial-godot-cpp"
)

The current 4.4 Portfile does not explicitly set GODOTCPP_TARGET, so I added:

vcpkg_cmake_configure(
    SOURCE_PATH "${SOURCE_PATH}"
    OPTIONS
        "-DPython3_EXECUTABLE=${PYTHON3}"
    OPTIONS_DEBUG
        -DGODOTCPP_TARGET=template_debug
    OPTIONS_RELEASE
        -DGODOTCPP_TARGET=template_release
)

Not setting this resulted in 2 issues:

  1. File name was debug instead of release:vcpkg-src\buildtrees\godot-cpp\x64-windows-rel\bin\libgodot-cpp.windows.template_debug.x86_64.lib
  2. File size was different, that is an indicator that DEBUG_METHODS_ENABLED where enabled even if they should not be.
Image

I faced similar issues like github.com/godotengine/godot/issues/64897 where my extension worked fine in debug but crashed on exit in release (Note we use Godot as embedded Library, so there are also some differences there).

Steps to reproduce

Minimal reproduction project

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions