[glib] Support cross-compiling Objective C code using Meson (#33313)

* Support cross-compiling Objective C code using Meson

The glib port uses Objective C code and the Meson build system.
You'll end up cross compiling glib when compiling for x64 osx
on an arm64 osx machine, or vice versa.

For this to work, an Objective C compiler needs to be set
in the Meson cross file.

vcpkg generates this file based on the
`scripts/buildsystems/meson/meson.template.in` template, and expects
the `MESON_OBJC` CMake variable to be set.

That's the job of `z_vcpkg_meson_set_proglist_variables` in
`scripts/cmake/vcpkg_configure_meson.cmake`.  It will only generate data
for an Objective C compiler if:

- The `Languages` argument includes `OBJC`
- CMake has detected a Objective C compiler, and has set `VCPKG_DETECTED_CMAKE_OBJC_COMPILER`

To make this work, this patch:
- Enables the OBJC and OBJCXX language on Apple platforms
- Updates the call to `vcpkg_configure_meson` in the glib port file
  to include the OBJC OBJCXX languages.

Fixes https://github.com/microsoft/vcpkg/issues/26147
Fixes https://github.com/microsoft/vcpkg/issues/20341
Based on https://github.com/microsoft/vcpkg/pull/26259
Based on 27dee354e4

Tested on an arm64 mac to compile glib for x64 macos

* Update version database
This commit is contained in:
Frederik Carlier 2023-08-25 21:25:28 +02:00 committed by GitHub
parent c747905709
commit ba58a3fdf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 2 deletions

View File

@ -13,6 +13,10 @@ vcpkg_extract_source_archive(SOURCE_PATH
fix-build-race-on-gio.patch # https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3512
)
if(APPLE)
list(APPEND VCPKG_CMAKE_CONFIGURE_OPTIONS "-DVCPKG_ENABLE_OBJC=1")
endif()
vcpkg_list(SET OPTIONS)
if (selinux IN_LIST FEATURES)
if(NOT EXISTS "/usr/include/selinux")
@ -38,6 +42,7 @@ endif()
vcpkg_configure_meson(
SOURCE_PATH "${SOURCE_PATH}"
LANGUAGES C CXX OBJC OBJCXX
ADDITIONAL_BINARIES
${ADDITIONAL_BINARIES}
OPTIONS

View File

@ -1,7 +1,7 @@
{
"name": "glib",
"version": "2.76.3",
"port-version": 2,
"port-version": 3,
"description": "Portable, general-purpose utility library.",
"homepage": "https://developer.gnome.org/glib/",
"license": "LGPL-2.1-or-later",

View File

@ -11,6 +11,9 @@ else()
endif()
set(VCPKG_LANGUAGES "C;CXX" CACHE STRING "Languages to enables for this project")
if(VCPKG_ENABLE_OBJC)
list(APPEND VCPKG_LANGUAGES "OBJC")
endif()
project(get_cmake_vars LANGUAGES ${VCPKG_LANGUAGES})

View File

@ -2910,7 +2910,7 @@
},
"glib": {
"baseline": "2.76.3",
"port-version": 2
"port-version": 3
},
"glibmm": {
"baseline": "2.76.0",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "ac7af1a224e7dfe9c18e629bf8de7798a0cda932",
"version": "2.76.3",
"port-version": 3
},
{
"git-tree": "c4aa04cd3294219ddd4b43c2f02b95c100683156",
"version": "2.76.3",