godotengine / godotengine/godot-cpp

Adapt vcpkg patches and update vcpkg port to 4.5

Open
#1,882 17 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
2.7k
Forks
809
Avg merge
1d 3h
Merged PRs (30d)
8

Description

### Godot version

4.5

### godot-cpp version

4.5

### System information

Windows 11

### Issue description

Currently, the [vcpkg version of godot-cpp](https://github.com/microsoft/vcpkg/tree/master/ports/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](https://github.com/microsoft/vcpkg/blob/master/ports/godot-cpp/packagable.patch#L9) 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
``` cmake
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](https://github.com/microsoft/vcpkg/blob/master/ports/godot-cpp/portfile.cmake) does not explicitly set `GODOTCPP_TARGET`, so I added:

``` CMake
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](http://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

-

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.