mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-08-03 11:27:33 -04:00
ci(macos): use vcpkg (#3977)
This commit is contained in:
commit
9565affa64
@ -42,6 +42,8 @@ runs:
|
||||
- name: Setup macOS dependencies
|
||||
if: ${{ runner.os == 'macOS' }}
|
||||
uses: ./.github/actions/setup-dependencies/macos
|
||||
with:
|
||||
build-type: ${{ inputs.build-type }}
|
||||
|
||||
- name: Setup Windows dependencies
|
||||
if: ${{ runner.os == 'Windows' }}
|
||||
|
@ -1,5 +1,11 @@
|
||||
name: Setup macOS dependencies
|
||||
|
||||
inputs:
|
||||
build-type:
|
||||
description: Type for the build
|
||||
required: true
|
||||
default: Debug
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
|
||||
@ -14,3 +20,29 @@ runs:
|
||||
shell: bash
|
||||
run: |
|
||||
echo "JAVA_HOME=$(/usr/libexec/java_home -v 17)" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Setup vcpkg cache
|
||||
if: ${{ inputs.build-type == 'Debug' }}
|
||||
shell: bash
|
||||
env:
|
||||
USERNAME: ${{ github.repository_owner }}
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
FEED_URL: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
|
||||
run: |
|
||||
mono `vcpkg fetch nuget | tail -n 1` \
|
||||
sources add \
|
||||
-Source "$FEED_URL" \
|
||||
-StorePasswordInClearText \
|
||||
-Name GitHubPackages \
|
||||
-UserName "$USERNAME" \
|
||||
-Password "$GITHUB_TOKEN"
|
||||
mono `vcpkg fetch nuget | tail -n 1` \
|
||||
setapikey "$GITHUB_TOKEN" \
|
||||
-Source "$FEED_URL"
|
||||
echo "VCPKG_BINARY_SOURCES=clear;nuget,$FEED_URL,readwrite" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Setup vcpkg environment
|
||||
if: ${{ inputs.build-type == 'Debug' }}
|
||||
shell: bash
|
||||
run: |
|
||||
echo "CMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" >> "$GITHUB_ENV"
|
||||
|
@ -30,6 +30,7 @@ runs:
|
||||
shell: pwsh
|
||||
env:
|
||||
USERNAME: ${{ github.repository_owner }}
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
FEED_URL: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
|
||||
run: |
|
||||
.$(vcpkg fetch nuget) `
|
||||
@ -42,7 +43,7 @@ runs:
|
||||
.$(vcpkg fetch nuget) `
|
||||
setapikey "$env:GITHUB_TOKEN" `
|
||||
-Source "$env:FEED_URL"
|
||||
Write-Output "VCPKG_BINARY_SOURCES=clear;nuget,$env:FEED_URL,readwrite" >> "$GITHUB_ENV"
|
||||
"VCPKG_BINARY_SOURCES=clear;nuget,$env:FEED_URL,readwrite" | Out-File -Append $env:GITHUB_ENV
|
||||
|
||||
- name: Setup vcpkg environment (MSVC)
|
||||
if: ${{ inputs.msystem == '' }}
|
||||
|
23
COPYING.md
23
COPYING.md
@ -412,3 +412,26 @@
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
- The Software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the Software or the use or other dealings in the Software.
|
||||
|
||||
## vcpkg (`cmake/vcpkg-ports`)
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
software and associated documentation files (the "Software"), to deal in the Software
|
||||
without restriction, including without limitation the rights to use, copy, modify,
|
||||
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies
|
||||
or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
@ -22,7 +22,8 @@
|
||||
"macos_base"
|
||||
],
|
||||
"cacheVariables": {
|
||||
"CMAKE_OSX_ARCHITECTURES": "x86_64;arm64"
|
||||
"CMAKE_OSX_ARCHITECTURES": "x86_64;arm64",
|
||||
"VCPKG_TARGET_TRIPLET": "universal-osx"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
3
cmake/vcpkg-ports/vcpkg-tool-meson/README.md
Normal file
3
cmake/vcpkg-ports/vcpkg-tool-meson/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
The only difference between this and the upstream vcpkg port is the addition of `universal-osx.patch`. It's very annoying we need to bundle this entire tree to do that.
|
||||
|
||||
-@getchoo
|
13
cmake/vcpkg-ports/vcpkg-tool-meson/adjust-args.patch
Normal file
13
cmake/vcpkg-ports/vcpkg-tool-meson/adjust-args.patch
Normal file
@ -0,0 +1,13 @@
|
||||
diff --git a/mesonbuild/cmake/toolchain.py b/mesonbuild/cmake/toolchain.py
|
||||
index 11a00be5d..89ae490ff 100644
|
||||
--- a/mesonbuild/cmake/toolchain.py
|
||||
+++ b/mesonbuild/cmake/toolchain.py
|
||||
@@ -202,7 +202,7 @@ class CMakeToolchain:
|
||||
@staticmethod
|
||||
def is_cmdline_option(compiler: 'Compiler', arg: str) -> bool:
|
||||
if compiler.get_argument_syntax() == 'msvc':
|
||||
- return arg.startswith('/')
|
||||
+ return arg.startswith(('/','-'))
|
||||
else:
|
||||
if os.path.basename(compiler.get_exe()) == 'zig' and arg in {'ar', 'cc', 'c++', 'dlltool', 'lib', 'ranlib', 'objcopy', 'rc'}:
|
||||
return True
|
45
cmake/vcpkg-ports/vcpkg-tool-meson/adjust-python-dep.patch
Normal file
45
cmake/vcpkg-ports/vcpkg-tool-meson/adjust-python-dep.patch
Normal file
@ -0,0 +1,45 @@
|
||||
diff --git a/mesonbuild/dependencies/python.py b/mesonbuild/dependencies/python.py
|
||||
index 883a29a..d9a82af 100644
|
||||
--- a/mesonbuild/dependencies/python.py
|
||||
+++ b/mesonbuild/dependencies/python.py
|
||||
@@ -232,8 +232,10 @@ class _PythonDependencyBase(_Base):
|
||||
else:
|
||||
if self.is_freethreaded:
|
||||
libpath = Path('libs') / f'python{vernum}t.lib'
|
||||
+ libpath = Path('libs') / f'..' / f'..' / f'..' / f'lib' / f'python{vernum}t.lib'
|
||||
else:
|
||||
libpath = Path('libs') / f'python{vernum}.lib'
|
||||
+ libpath = Path('libs') / f'..' / f'..' / f'..' / f'lib' / f'python{vernum}.lib'
|
||||
# For a debug build, pyconfig.h may force linking with
|
||||
# pythonX_d.lib (see meson#10776). This cannot be avoided
|
||||
# and won't work unless we also have a debug build of
|
||||
@@ -250,6 +252,8 @@ class _PythonDependencyBase(_Base):
|
||||
vscrt = self.env.coredata.optstore.get_value('b_vscrt')
|
||||
if vscrt in {'mdd', 'mtd', 'from_buildtype', 'static_from_buildtype'}:
|
||||
vscrt_debug = True
|
||||
+ if is_debug_build:
|
||||
+ libpath = Path('libs') / f'..' / f'..' / f'..' / f'debug/lib' / f'python{vernum}_d.lib'
|
||||
if is_debug_build and vscrt_debug and not self.variables.get('Py_DEBUG'):
|
||||
mlog.warning(textwrap.dedent('''\
|
||||
Using a debug build type with MSVC or an MSVC-compatible compiler
|
||||
@@ -350,9 +354,10 @@ class PythonSystemDependency(SystemDependency, _PythonDependencyBase):
|
||||
self.is_found = True
|
||||
|
||||
# compile args
|
||||
+ verdot = self.variables.get('py_version_short')
|
||||
inc_paths = mesonlib.OrderedSet([
|
||||
self.variables.get('INCLUDEPY'),
|
||||
- self.paths.get('include'),
|
||||
+ self.paths.get('include') + f'/../../../include/python${verdot}',
|
||||
self.paths.get('platinclude')])
|
||||
|
||||
self.compile_args += ['-I' + path for path in inc_paths if path]
|
||||
@@ -416,7 +421,7 @@ def python_factory(env: 'Environment', for_machine: 'MachineChoice',
|
||||
candidates.append(functools.partial(wrap_in_pythons_pc_dir, pkg_name, env, kwargs, installation))
|
||||
# We only need to check both, if a python install has a LIBPC. It might point to the wrong location,
|
||||
# e.g. relocated / cross compilation, but the presence of LIBPC indicates we should definitely look for something.
|
||||
- if pkg_libdir is not None:
|
||||
+ if True or pkg_libdir is not None:
|
||||
candidates.append(functools.partial(PythonPkgConfigDependency, pkg_name, env, kwargs, installation))
|
||||
else:
|
||||
candidates.append(functools.partial(PkgConfigDependency, 'python3', env, kwargs))
|
@ -0,0 +1,52 @@
|
||||
From a16ec8b0fb6d7035b669a13edd4d97ff0c307a0b Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Martin=20D=C3=B8rum?= <martid0311@gmail.com>
|
||||
Date: Fri, 2 May 2025 10:56:28 +0200
|
||||
Subject: [PATCH] cpp: fix _LIBCPP_ENABLE_ASSERTIONS warning
|
||||
|
||||
libc++ deprecated _LIBCPP_ENABLE_ASSERTIONS from version 18.
|
||||
However, the libc++ shipped with Apple Clang backported that
|
||||
deprecation in version 17 already,
|
||||
which is the version which Apple currently ships for macOS.
|
||||
This PR changes the _LIBCPP_ENABLE_ASSERTIONS deprecation check
|
||||
to use version ">=17" on Apple Clang.
|
||||
---
|
||||
mesonbuild/compilers/cpp.py | 12 ++++++++++--
|
||||
1 file changed, 10 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py
|
||||
index 01b9bb9fa34f..f7dc150e8608 100644
|
||||
--- a/mesonbuild/compilers/cpp.py
|
||||
+++ b/mesonbuild/compilers/cpp.py
|
||||
@@ -311,6 +311,9 @@ def get_option_link_args(self, target: 'BuildTarget', env: 'Environment', subpro
|
||||
return libs
|
||||
return []
|
||||
|
||||
+ def is_libcpp_enable_assertions_deprecated(self) -> bool:
|
||||
+ return version_compare(self.version, ">=18")
|
||||
+
|
||||
def get_assert_args(self, disable: bool, env: 'Environment') -> T.List[str]:
|
||||
if disable:
|
||||
return ['-DNDEBUG']
|
||||
@@ -323,7 +326,7 @@ def get_assert_args(self, disable: bool, env: 'Environment') -> T.List[str]:
|
||||
if self.language_stdlib_provider(env) == 'stdc++':
|
||||
return ['-D_GLIBCXX_ASSERTIONS=1']
|
||||
else:
|
||||
- if version_compare(self.version, '>=18'):
|
||||
+ if self.is_libcpp_enable_assertions_deprecated():
|
||||
return ['-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST']
|
||||
elif version_compare(self.version, '>=15'):
|
||||
return ['-D_LIBCPP_ENABLE_ASSERTIONS=1']
|
||||
@@ -343,7 +346,12 @@ class ArmLtdClangCPPCompiler(ClangCPPCompiler):
|
||||
|
||||
|
||||
class AppleClangCPPCompiler(AppleCompilerMixin, AppleCPPStdsMixin, ClangCPPCompiler):
|
||||
- pass
|
||||
+ def is_libcpp_enable_assertions_deprecated(self) -> bool:
|
||||
+ # Upstream libc++ deprecated _LIBCPP_ENABLE_ASSERTIONS
|
||||
+ # in favor of _LIBCPP_HARDENING_MODE from version 18 onwards,
|
||||
+ # but Apple Clang 17's libc++ has back-ported that change.
|
||||
+ # See: https://github.com/mesonbuild/meson/issues/14440
|
||||
+ return version_compare(self.version, ">=17")
|
||||
|
||||
|
||||
class EmscriptenCPPCompiler(EmscriptenMixin, ClangCPPCompiler):
|
5
cmake/vcpkg-ports/vcpkg-tool-meson/install.cmake
Normal file
5
cmake/vcpkg-ports/vcpkg-tool-meson/install.cmake
Normal file
@ -0,0 +1,5 @@
|
||||
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/meson")
|
||||
file(INSTALL "${SOURCE_PATH}/meson.py"
|
||||
"${SOURCE_PATH}/mesonbuild"
|
||||
DESTINATION "${CURRENT_PACKAGES_DIR}/tools/meson"
|
||||
)
|
13
cmake/vcpkg-ports/vcpkg-tool-meson/meson-intl.patch
Normal file
13
cmake/vcpkg-ports/vcpkg-tool-meson/meson-intl.patch
Normal file
@ -0,0 +1,13 @@
|
||||
diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py
|
||||
--- a/mesonbuild/dependencies/misc.py
|
||||
+++ b/mesonbuild/dependencies/misc.py
|
||||
@@ -593,7 +593,8 @@ iconv_factory = DependencyFactory(
|
||||
|
||||
packages['intl'] = intl_factory = DependencyFactory(
|
||||
'intl',
|
||||
+ [DependencyMethods.BUILTIN, DependencyMethods.SYSTEM, DependencyMethods.CMAKE],
|
||||
+ cmake_name='Intl',
|
||||
- [DependencyMethods.BUILTIN, DependencyMethods.SYSTEM],
|
||||
builtin_class=IntlBuiltinDependency,
|
||||
system_class=IntlSystemDependency,
|
||||
)
|
43
cmake/vcpkg-ports/vcpkg-tool-meson/meson.template.in
Normal file
43
cmake/vcpkg-ports/vcpkg-tool-meson/meson.template.in
Normal file
@ -0,0 +1,43 @@
|
||||
[binaries]
|
||||
cmake = ['@CMAKE_COMMAND@']
|
||||
ninja = ['@NINJA@']
|
||||
pkg-config = ['@PKGCONFIG@']
|
||||
@MESON_MT@
|
||||
@MESON_AR@
|
||||
@MESON_RC@
|
||||
@MESON_C@
|
||||
@MESON_C_LD@
|
||||
@MESON_CXX@
|
||||
@MESON_CXX_LD@
|
||||
@MESON_OBJC@
|
||||
@MESON_OBJC_LD@
|
||||
@MESON_OBJCPP@
|
||||
@MESON_OBJCPP_LD@
|
||||
@MESON_FC@
|
||||
@MESON_FC_LD@
|
||||
@MESON_WINDRES@
|
||||
@MESON_ADDITIONAL_BINARIES@
|
||||
[properties]
|
||||
cmake_toolchain_file = '@SCRIPTS@/buildsystems/vcpkg.cmake'
|
||||
@MESON_ADDITIONAL_PROPERTIES@
|
||||
[cmake]
|
||||
CMAKE_BUILD_TYPE = '@MESON_CMAKE_BUILD_TYPE@'
|
||||
VCPKG_TARGET_TRIPLET = '@TARGET_TRIPLET@'
|
||||
VCPKG_HOST_TRIPLET = '@_HOST_TRIPLET@'
|
||||
VCPKG_CHAINLOAD_TOOLCHAIN_FILE = '@VCPKG_CHAINLOAD_TOOLCHAIN_FILE@'
|
||||
VCPKG_CRT_LINKAGE = '@VCPKG_CRT_LINKAGE@'
|
||||
_VCPKG_INSTALLED_DIR = '@_VCPKG_INSTALLED_DIR@'
|
||||
@MESON_HOST_MACHINE@
|
||||
@MESON_BUILD_MACHINE@
|
||||
[built-in options]
|
||||
default_library = '@MESON_DEFAULT_LIBRARY@'
|
||||
werror = false
|
||||
@MESON_CFLAGS@
|
||||
@MESON_CXXFLAGS@
|
||||
@MESON_FCFLAGS@
|
||||
@MESON_OBJCFLAGS@
|
||||
@MESON_OBJCPPFLAGS@
|
||||
# b_vscrt
|
||||
@MESON_VSCRT_LINKAGE@
|
||||
# c_winlibs/cpp_winlibs
|
||||
@MESON_WINLIBS@
|
45
cmake/vcpkg-ports/vcpkg-tool-meson/portfile.cmake
Normal file
45
cmake/vcpkg-ports/vcpkg-tool-meson/portfile.cmake
Normal file
@ -0,0 +1,45 @@
|
||||
# This port represents a dependency on the Meson build system.
|
||||
# In the future, it is expected that this port acquires and installs Meson.
|
||||
# Currently is used in ports that call vcpkg_find_acquire_program(MESON) in order to force rebuilds.
|
||||
|
||||
set(VCPKG_POLICY_CMAKE_HELPER_PORT enabled)
|
||||
|
||||
set(patches
|
||||
meson-intl.patch
|
||||
adjust-python-dep.patch
|
||||
adjust-args.patch
|
||||
remove-freebsd-pcfile-specialization.patch
|
||||
fix-libcpp-enable-assertions.patch # https://github.com/mesonbuild/meson/pull/14548, Remove in 1.8.3
|
||||
universal-osx.patch # NOTE(@getchoo): THIS IS THE ONLY CHANGE NEEDED FOR PRISM
|
||||
)
|
||||
set(scripts
|
||||
vcpkg-port-config.cmake
|
||||
vcpkg_configure_meson.cmake
|
||||
vcpkg_install_meson.cmake
|
||||
meson.template.in
|
||||
)
|
||||
set(to_hash
|
||||
"${CMAKE_CURRENT_LIST_DIR}/vcpkg.json"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/portfile.cmake"
|
||||
)
|
||||
foreach(file IN LISTS patches scripts)
|
||||
set(filepath "${CMAKE_CURRENT_LIST_DIR}/${file}")
|
||||
list(APPEND to_hash "${filepath}")
|
||||
file(COPY "${filepath}" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
|
||||
endforeach()
|
||||
|
||||
set(meson_path_hash "")
|
||||
foreach(filepath IN LISTS to_hash)
|
||||
file(SHA1 "${filepath}" to_append)
|
||||
string(APPEND meson_path_hash "${to_append}")
|
||||
endforeach()
|
||||
string(SHA512 meson_path_hash "${meson_path_hash}")
|
||||
|
||||
string(SUBSTRING "${meson_path_hash}" 0 6 MESON_SHORT_HASH)
|
||||
list(TRANSFORM patches REPLACE [[^(..*)$]] [["${CMAKE_CURRENT_LIST_DIR}/\0"]])
|
||||
list(JOIN patches "\n " PATCHES)
|
||||
configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-port-config.cmake" "${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-port-config.cmake" @ONLY)
|
||||
|
||||
vcpkg_install_copyright(FILE_LIST "${VCPKG_ROOT_DIR}/LICENSE.txt")
|
||||
|
||||
include("${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-port-config.cmake")
|
@ -0,0 +1,23 @@
|
||||
diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py
|
||||
index cc0450a52..13501466d 100644
|
||||
--- a/mesonbuild/modules/pkgconfig.py
|
||||
+++ b/mesonbuild/modules/pkgconfig.py
|
||||
@@ -701,16 +701,8 @@ class PkgConfigModule(NewExtensionModule):
|
||||
pcfile = filebase + '.pc'
|
||||
pkgroot = pkgroot_name = kwargs['install_dir'] or default_install_dir
|
||||
if pkgroot is None:
|
||||
- m = state.environment.machines.host
|
||||
- if m.is_freebsd():
|
||||
- pkgroot = os.path.join(_as_str(state.environment.coredata.optstore.get_value_for(OptionKey('prefix'))), 'libdata', 'pkgconfig')
|
||||
- pkgroot_name = os.path.join('{prefix}', 'libdata', 'pkgconfig')
|
||||
- elif m.is_haiku():
|
||||
- pkgroot = os.path.join(_as_str(state.environment.coredata.optstore.get_value_for(OptionKey('prefix'))), 'develop', 'lib', 'pkgconfig')
|
||||
- pkgroot_name = os.path.join('{prefix}', 'develop', 'lib', 'pkgconfig')
|
||||
- else:
|
||||
- pkgroot = os.path.join(_as_str(state.environment.coredata.optstore.get_value_for(OptionKey('libdir'))), 'pkgconfig')
|
||||
- pkgroot_name = os.path.join('{libdir}', 'pkgconfig')
|
||||
+ pkgroot = os.path.join(_as_str(state.environment.coredata.optstore.get_value_for(OptionKey('libdir'))), 'pkgconfig')
|
||||
+ pkgroot_name = os.path.join('{libdir}', 'pkgconfig')
|
||||
relocatable = state.get_option('pkgconfig.relocatable')
|
||||
self._generate_pkgconfig_file(state, deps, subdirs, name, description, url,
|
||||
version, pcfile, conflicts, variables,
|
16
cmake/vcpkg-ports/vcpkg-tool-meson/universal-osx.patch
Normal file
16
cmake/vcpkg-ports/vcpkg-tool-meson/universal-osx.patch
Normal file
@ -0,0 +1,16 @@
|
||||
diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py
|
||||
index f57957f0b..a72e72a0b 100644
|
||||
--- a/mesonbuild/compilers/detect.py
|
||||
+++ b/mesonbuild/compilers/detect.py
|
||||
@@ -1472,6 +1472,11 @@ def _get_clang_compiler_defines(compiler: T.List[str], lang: str) -> T.Dict[str,
|
||||
"""
|
||||
from .mixins.clang import clang_lang_map
|
||||
|
||||
+ # Filter out `-arch` flags passed to the compiler for Universal Binaries
|
||||
+ # https://github.com/mesonbuild/meson/issues/5290
|
||||
+ # https://github.com/mesonbuild/meson/issues/8206
|
||||
+ compiler = [arg for i, arg in enumerate(compiler) if not (i > 0 and compiler[i - 1] == "-arch") and not arg == "-arch"]
|
||||
+
|
||||
def _try_obtain_compiler_defines(args: T.List[str]) -> str:
|
||||
mlog.debug(f'Running command: {join_args(args)}')
|
||||
p, output, error = Popen_safe(compiler + args, write='', stdin=subprocess.PIPE)
|
62
cmake/vcpkg-ports/vcpkg-tool-meson/vcpkg-port-config.cmake
Normal file
62
cmake/vcpkg-ports/vcpkg-tool-meson/vcpkg-port-config.cmake
Normal file
@ -0,0 +1,62 @@
|
||||
include("${CURRENT_HOST_INSTALLED_DIR}/share/vcpkg-cmake-get-vars/vcpkg-port-config.cmake")
|
||||
# Overwrite builtin scripts
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_configure_meson.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_install_meson.cmake")
|
||||
|
||||
set(meson_short_hash @MESON_SHORT_HASH@)
|
||||
|
||||
# Setup meson:
|
||||
set(program MESON)
|
||||
set(program_version @VERSION@)
|
||||
set(program_name meson)
|
||||
set(search_names meson meson.py)
|
||||
set(ref "${program_version}")
|
||||
set(path_to_search "${DOWNLOADS}/tools/meson-${program_version}-${meson_short_hash}")
|
||||
set(download_urls "https://github.com/mesonbuild/meson/archive/${ref}.tar.gz")
|
||||
set(download_filename "meson-${ref}.tar.gz")
|
||||
set(download_sha512 bd2e65f0863d9cb974e659ff502d773e937b8a60aaddfd7d81e34cd2c296c8e82bf214d790ac089ba441543059dfc2677ba95ed51f676df9da420859f404a907)
|
||||
|
||||
find_program(SCRIPT_MESON NAMES ${search_names} PATHS "${path_to_search}" NO_DEFAULT_PATH) # NO_DEFAULT_PATH due top patching
|
||||
|
||||
if(NOT SCRIPT_MESON)
|
||||
vcpkg_download_distfile(archive_path
|
||||
URLS ${download_urls}
|
||||
SHA512 "${download_sha512}"
|
||||
FILENAME "${download_filename}"
|
||||
)
|
||||
file(REMOVE_RECURSE "${path_to_search}")
|
||||
file(REMOVE_RECURSE "${path_to_search}-tmp")
|
||||
file(MAKE_DIRECTORY "${path_to_search}-tmp")
|
||||
file(ARCHIVE_EXTRACT INPUT "${archive_path}"
|
||||
DESTINATION "${path_to_search}-tmp"
|
||||
#PATTERNS "**/mesonbuild/*" "**/*.py"
|
||||
)
|
||||
z_vcpkg_apply_patches(
|
||||
SOURCE_PATH "${path_to_search}-tmp/meson-${ref}"
|
||||
PATCHES
|
||||
@PATCHES@
|
||||
)
|
||||
file(MAKE_DIRECTORY "${path_to_search}")
|
||||
file(RENAME "${path_to_search}-tmp/meson-${ref}/meson.py" "${path_to_search}/meson.py")
|
||||
file(RENAME "${path_to_search}-tmp/meson-${ref}/mesonbuild" "${path_to_search}/mesonbuild")
|
||||
file(REMOVE_RECURSE "${path_to_search}-tmp")
|
||||
set(SCRIPT_MESON "${path_to_search}/meson.py")
|
||||
endif()
|
||||
|
||||
# Check required python version
|
||||
vcpkg_find_acquire_program(PYTHON3)
|
||||
vcpkg_execute_in_download_mode(
|
||||
COMMAND "${PYTHON3}" --version
|
||||
OUTPUT_VARIABLE version_contents
|
||||
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}"
|
||||
)
|
||||
string(REGEX MATCH [[[0-9]+\.[0-9]+\.[0-9]+]] python_ver "${version_contents}")
|
||||
|
||||
set(min_required 3.7)
|
||||
if(python_ver VERSION_LESS "${min_required}")
|
||||
message(FATAL_ERROR "Found Python version '${python_ver} at ${PYTHON3}' is insufficient for meson. meson requires at least version '${min_required}'")
|
||||
else()
|
||||
message(STATUS "Found Python version '${python_ver} at ${PYTHON3}'")
|
||||
endif()
|
||||
|
||||
message(STATUS "Using meson: ${SCRIPT_MESON}")
|
11
cmake/vcpkg-ports/vcpkg-tool-meson/vcpkg.json
Normal file
11
cmake/vcpkg-ports/vcpkg-tool-meson/vcpkg.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "vcpkg-tool-meson",
|
||||
"version": "1.8.2",
|
||||
"description": "Meson build system",
|
||||
"homepage": "https://github.com/mesonbuild/meson",
|
||||
"license": "Apache-2.0",
|
||||
"supports": "native",
|
||||
"dependencies": [
|
||||
"vcpkg-cmake-get-vars"
|
||||
]
|
||||
}
|
480
cmake/vcpkg-ports/vcpkg-tool-meson/vcpkg_configure_meson.cmake
Normal file
480
cmake/vcpkg-ports/vcpkg-tool-meson/vcpkg_configure_meson.cmake
Normal file
@ -0,0 +1,480 @@
|
||||
function(z_vcpkg_meson_set_proglist_variables config_type)
|
||||
if(VCPKG_TARGET_IS_WINDOWS)
|
||||
set(proglist MT AR)
|
||||
else()
|
||||
set(proglist AR RANLIB STRIP NM OBJDUMP DLLTOOL MT)
|
||||
endif()
|
||||
foreach(prog IN LISTS proglist)
|
||||
if(VCPKG_DETECTED_CMAKE_${prog})
|
||||
if(meson_${prog})
|
||||
string(TOUPPER "MESON_${meson_${prog}}" var_to_set)
|
||||
set("${var_to_set}" "${meson_${prog}} = ['${VCPKG_DETECTED_CMAKE_${prog}}']" PARENT_SCOPE)
|
||||
elseif(${prog} STREQUAL AR AND VCPKG_COMBINED_STATIC_LINKER_FLAGS_${config_type})
|
||||
# Probably need to move AR somewhere else
|
||||
string(TOLOWER "${prog}" proglower)
|
||||
z_vcpkg_meson_convert_compiler_flags_to_list(ar_flags "${VCPKG_COMBINED_STATIC_LINKER_FLAGS_${config_type}}")
|
||||
list(PREPEND ar_flags "${VCPKG_DETECTED_CMAKE_${prog}}")
|
||||
z_vcpkg_meson_convert_list_to_python_array(ar_flags ${ar_flags})
|
||||
set("MESON_AR" "${proglower} = ${ar_flags}" PARENT_SCOPE)
|
||||
else()
|
||||
string(TOUPPER "MESON_${prog}" var_to_set)
|
||||
string(TOLOWER "${prog}" proglower)
|
||||
set("${var_to_set}" "${proglower} = ['${VCPKG_DETECTED_CMAKE_${prog}}']" PARENT_SCOPE)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
set(compilers "${arg_LANGUAGES}")
|
||||
if(VCPKG_TARGET_IS_WINDOWS)
|
||||
list(APPEND compilers RC)
|
||||
endif()
|
||||
set(meson_RC windres)
|
||||
set(meson_Fortran fortran)
|
||||
set(meson_CXX cpp)
|
||||
foreach(prog IN LISTS compilers)
|
||||
if(VCPKG_DETECTED_CMAKE_${prog}_COMPILER)
|
||||
string(TOUPPER "MESON_${prog}" var_to_set)
|
||||
if(meson_${prog})
|
||||
if(VCPKG_COMBINED_${prog}_FLAGS_${config_type})
|
||||
# Need compiler flags in prog vars for sanity check.
|
||||
z_vcpkg_meson_convert_compiler_flags_to_list(${prog}flags "${VCPKG_COMBINED_${prog}_FLAGS_${config_type}}")
|
||||
endif()
|
||||
list(PREPEND ${prog}flags "${VCPKG_DETECTED_CMAKE_${prog}_COMPILER}")
|
||||
list(FILTER ${prog}flags EXCLUDE REGEX "(-|/)nologo") # Breaks compiler detection otherwise
|
||||
z_vcpkg_meson_convert_list_to_python_array(${prog}flags ${${prog}flags})
|
||||
set("${var_to_set}" "${meson_${prog}} = ${${prog}flags}" PARENT_SCOPE)
|
||||
if (DEFINED VCPKG_DETECTED_CMAKE_${prog}_COMPILER_ID
|
||||
AND NOT VCPKG_DETECTED_CMAKE_${prog}_COMPILER_ID MATCHES "^(GNU|Intel)$"
|
||||
AND VCPKG_DETECTED_CMAKE_LINKER)
|
||||
string(TOUPPER "MESON_${prog}_LD" var_to_set)
|
||||
set(${var_to_set} "${meson_${prog}}_ld = ['${VCPKG_DETECTED_CMAKE_LINKER}']" PARENT_SCOPE)
|
||||
endif()
|
||||
else()
|
||||
if(VCPKG_COMBINED_${prog}_FLAGS_${config_type})
|
||||
# Need compiler flags in prog vars for sanity check.
|
||||
z_vcpkg_meson_convert_compiler_flags_to_list(${prog}flags "${VCPKG_COMBINED_${prog}_FLAGS_${config_type}}")
|
||||
endif()
|
||||
list(PREPEND ${prog}flags "${VCPKG_DETECTED_CMAKE_${prog}_COMPILER}")
|
||||
list(FILTER ${prog}flags EXCLUDE REGEX "(-|/)nologo") # Breaks compiler detection otherwise
|
||||
z_vcpkg_meson_convert_list_to_python_array(${prog}flags ${${prog}flags})
|
||||
string(TOLOWER "${prog}" proglower)
|
||||
set("${var_to_set}" "${proglower} = ${${prog}flags}" PARENT_SCOPE)
|
||||
if (DEFINED VCPKG_DETECTED_CMAKE_${prog}_COMPILER_ID
|
||||
AND NOT VCPKG_DETECTED_CMAKE_${prog}_COMPILER_ID MATCHES "^(GNU|Intel)$"
|
||||
AND VCPKG_DETECTED_CMAKE_LINKER)
|
||||
string(TOUPPER "MESON_${prog}_LD" var_to_set)
|
||||
set(${var_to_set} "${proglower}_ld = ['${VCPKG_DETECTED_CMAKE_LINKER}']" PARENT_SCOPE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
function(z_vcpkg_meson_convert_compiler_flags_to_list out_var compiler_flags)
|
||||
separate_arguments(cmake_list NATIVE_COMMAND "${compiler_flags}")
|
||||
list(TRANSFORM cmake_list REPLACE ";" [[\\;]])
|
||||
set("${out_var}" "${cmake_list}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(z_vcpkg_meson_convert_list_to_python_array out_var)
|
||||
z_vcpkg_function_arguments(flag_list 1)
|
||||
vcpkg_list(REMOVE_ITEM flag_list "") # remove empty elements if any
|
||||
vcpkg_list(JOIN flag_list "', '" flag_list)
|
||||
set("${out_var}" "['${flag_list}']" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Generates the required compiler properties for meson
|
||||
function(z_vcpkg_meson_set_flags_variables config_type)
|
||||
if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
|
||||
set(libpath_flag /LIBPATH:)
|
||||
else()
|
||||
set(libpath_flag -L)
|
||||
endif()
|
||||
if(config_type STREQUAL "DEBUG")
|
||||
set(path_suffix "/debug")
|
||||
else()
|
||||
set(path_suffix "")
|
||||
endif()
|
||||
|
||||
set(includepath "-I${CURRENT_INSTALLED_DIR}/include")
|
||||
set(libpath "${libpath_flag}${CURRENT_INSTALLED_DIR}${path_suffix}/lib")
|
||||
|
||||
foreach(lang IN LISTS arg_LANGUAGES)
|
||||
z_vcpkg_meson_convert_compiler_flags_to_list(${lang}flags "${VCPKG_COMBINED_${lang}_FLAGS_${config_type}}")
|
||||
if(lang MATCHES "^(C|CXX)$")
|
||||
vcpkg_list(APPEND ${lang}flags "${includepath}")
|
||||
endif()
|
||||
z_vcpkg_meson_convert_list_to_python_array(${lang}flags ${${lang}flags})
|
||||
set(lang_mapping "${lang}")
|
||||
if(lang STREQUAL "Fortran")
|
||||
set(lang_mapping "FC")
|
||||
endif()
|
||||
string(TOLOWER "${lang_mapping}" langlower)
|
||||
if(lang STREQUAL "CXX")
|
||||
set(langlower cpp)
|
||||
endif()
|
||||
set(MESON_${lang_mapping}FLAGS "${langlower}_args = ${${lang}flags}\n")
|
||||
set(linker_flags "${VCPKG_COMBINED_SHARED_LINKER_FLAGS_${config_type}}")
|
||||
z_vcpkg_meson_convert_compiler_flags_to_list(linker_flags "${linker_flags}")
|
||||
vcpkg_list(APPEND linker_flags "${libpath}")
|
||||
z_vcpkg_meson_convert_list_to_python_array(linker_flags ${linker_flags})
|
||||
string(APPEND MESON_${lang_mapping}FLAGS "${langlower}_link_args = ${linker_flags}\n")
|
||||
set(MESON_${lang_mapping}FLAGS "${MESON_${lang_mapping}FLAGS}" PARENT_SCOPE)
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
function(z_vcpkg_get_build_and_host_system build_system host_system is_cross) #https://mesonbuild.com/Cross-compilation.html
|
||||
set(build_unknown FALSE)
|
||||
if(CMAKE_HOST_WIN32)
|
||||
if(DEFINED ENV{PROCESSOR_ARCHITEW6432})
|
||||
set(build_arch $ENV{PROCESSOR_ARCHITEW6432})
|
||||
else()
|
||||
set(build_arch $ENV{PROCESSOR_ARCHITECTURE})
|
||||
endif()
|
||||
if(build_arch MATCHES "(amd|AMD)64")
|
||||
set(build_cpu_fam x86_64)
|
||||
set(build_cpu x86_64)
|
||||
elseif(build_arch MATCHES "(x|X)86")
|
||||
set(build_cpu_fam x86)
|
||||
set(build_cpu i686)
|
||||
elseif(build_arch MATCHES "^(ARM|arm)64$")
|
||||
set(build_cpu_fam aarch64)
|
||||
set(build_cpu armv8)
|
||||
elseif(build_arch MATCHES "^(ARM|arm)$")
|
||||
set(build_cpu_fam arm)
|
||||
set(build_cpu armv7hl)
|
||||
else()
|
||||
if(NOT DEFINED VCPKG_MESON_CROSS_FILE OR NOT DEFINED VCPKG_MESON_NATIVE_FILE)
|
||||
message(WARNING "Unsupported build architecture ${build_arch}! Please set VCPKG_MESON_(CROSS|NATIVE)_FILE to a meson file containing the build_machine entry!")
|
||||
endif()
|
||||
set(build_unknown TRUE)
|
||||
endif()
|
||||
elseif(CMAKE_HOST_UNIX)
|
||||
# at this stage, CMAKE_HOST_SYSTEM_PROCESSOR is not defined
|
||||
execute_process(
|
||||
COMMAND uname -m
|
||||
OUTPUT_VARIABLE MACHINE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
COMMAND_ERROR_IS_FATAL ANY)
|
||||
|
||||
# Show real machine architecture to visually understand whether we are in a native Apple Silicon terminal or running under Rosetta emulation
|
||||
debug_message("Machine: ${MACHINE}")
|
||||
|
||||
if(MACHINE MATCHES "arm64|aarch64")
|
||||
set(build_cpu_fam aarch64)
|
||||
set(build_cpu armv8)
|
||||
elseif(MACHINE MATCHES "armv7h?l")
|
||||
set(build_cpu_fam arm)
|
||||
set(build_cpu ${MACHINE})
|
||||
elseif(MACHINE MATCHES "x86_64|amd64")
|
||||
set(build_cpu_fam x86_64)
|
||||
set(build_cpu x86_64)
|
||||
elseif(MACHINE MATCHES "x86|i686")
|
||||
set(build_cpu_fam x86)
|
||||
set(build_cpu i686)
|
||||
elseif(MACHINE MATCHES "i386")
|
||||
set(build_cpu_fam x86)
|
||||
set(build_cpu i386)
|
||||
elseif(MACHINE MATCHES "loongarch64")
|
||||
set(build_cpu_fam loongarch64)
|
||||
set(build_cpu loongarch64)
|
||||
else()
|
||||
# https://github.com/mesonbuild/meson/blob/master/docs/markdown/Reference-tables.md#cpu-families
|
||||
if(NOT DEFINED VCPKG_MESON_CROSS_FILE OR NOT DEFINED VCPKG_MESON_NATIVE_FILE)
|
||||
message(WARNING "Unhandled machine: ${MACHINE}! Please set VCPKG_MESON_(CROSS|NATIVE)_FILE to a meson file containing the build_machine entry!")
|
||||
endif()
|
||||
set(build_unknown TRUE)
|
||||
endif()
|
||||
else()
|
||||
if(NOT DEFINED VCPKG_MESON_CROSS_FILE OR NOT DEFINED VCPKG_MESON_NATIVE_FILE)
|
||||
message(WARNING "Failed to detect the build architecture! Please set VCPKG_MESON_(CROSS|NATIVE)_FILE to a meson file containing the build_machine entry!")
|
||||
endif()
|
||||
set(build_unknown TRUE)
|
||||
endif()
|
||||
|
||||
set(build "[build_machine]\n") # Machine the build is performed on
|
||||
string(APPEND build "endian = 'little'\n")
|
||||
if(CMAKE_HOST_WIN32)
|
||||
string(APPEND build "system = 'windows'\n")
|
||||
elseif(CMAKE_HOST_APPLE)
|
||||
string(APPEND build "system = 'darwin'\n")
|
||||
elseif(CYGWIN)
|
||||
string(APPEND build "system = 'cygwin'\n")
|
||||
elseif(CMAKE_HOST_UNIX)
|
||||
string(APPEND build "system = 'linux'\n")
|
||||
else()
|
||||
set(build_unknown TRUE)
|
||||
endif()
|
||||
|
||||
if(DEFINED build_cpu_fam)
|
||||
string(APPEND build "cpu_family = '${build_cpu_fam}'\n")
|
||||
endif()
|
||||
if(DEFINED build_cpu)
|
||||
string(APPEND build "cpu = '${build_cpu}'")
|
||||
endif()
|
||||
if(NOT build_unknown)
|
||||
set(${build_system} "${build}" PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
set(host_unkown FALSE)
|
||||
if(VCPKG_TARGET_ARCHITECTURE MATCHES "(amd|AMD|x|X)64")
|
||||
set(host_cpu_fam x86_64)
|
||||
set(host_cpu x86_64)
|
||||
elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "(x|X)86")
|
||||
set(host_cpu_fam x86)
|
||||
set(host_cpu i686)
|
||||
elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "^(ARM|arm)64$")
|
||||
set(host_cpu_fam aarch64)
|
||||
set(host_cpu armv8)
|
||||
elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "^(ARM|arm)$")
|
||||
set(host_cpu_fam arm)
|
||||
set(host_cpu armv7hl)
|
||||
elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "loongarch64")
|
||||
set(host_cpu_fam loongarch64)
|
||||
set(host_cpu loongarch64)
|
||||
elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "wasm32")
|
||||
set(host_cpu_fam wasm32)
|
||||
set(host_cpu wasm32)
|
||||
else()
|
||||
if(NOT DEFINED VCPKG_MESON_CROSS_FILE OR NOT DEFINED VCPKG_MESON_NATIVE_FILE)
|
||||
message(WARNING "Unsupported target architecture ${VCPKG_TARGET_ARCHITECTURE}! Please set VCPKG_MESON_(CROSS|NATIVE)_FILE to a meson file containing the host_machine entry!" )
|
||||
endif()
|
||||
set(host_unkown TRUE)
|
||||
endif()
|
||||
|
||||
set(host "[host_machine]\n") # host=target in vcpkg.
|
||||
string(APPEND host "endian = 'little'\n")
|
||||
if(NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_TARGET_IS_MINGW OR VCPKG_TARGET_IS_UWP)
|
||||
set(meson_system_name "windows")
|
||||
else()
|
||||
string(TOLOWER "${VCPKG_CMAKE_SYSTEM_NAME}" meson_system_name)
|
||||
endif()
|
||||
string(APPEND host "system = '${meson_system_name}'\n")
|
||||
string(APPEND host "cpu_family = '${host_cpu_fam}'\n")
|
||||
string(APPEND host "cpu = '${host_cpu}'")
|
||||
if(NOT host_unkown)
|
||||
set(${host_system} "${host}" PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
if(NOT build_cpu_fam MATCHES "${host_cpu_fam}"
|
||||
OR VCPKG_TARGET_IS_ANDROID OR VCPKG_TARGET_IS_IOS OR VCPKG_TARGET_IS_UWP
|
||||
OR (VCPKG_TARGET_IS_MINGW AND NOT CMAKE_HOST_WIN32))
|
||||
set(${is_cross} TRUE PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(z_vcpkg_meson_setup_extra_windows_variables config_type)
|
||||
## b_vscrt
|
||||
if(VCPKG_CRT_LINKAGE STREQUAL "static")
|
||||
set(crt_type "mt")
|
||||
else()
|
||||
set(crt_type "md")
|
||||
endif()
|
||||
if(config_type STREQUAL "DEBUG")
|
||||
set(crt_type "${crt_type}d")
|
||||
endif()
|
||||
set(MESON_VSCRT_LINKAGE "b_vscrt = '${crt_type}'" PARENT_SCOPE)
|
||||
## winlibs
|
||||
separate_arguments(c_winlibs NATIVE_COMMAND "${VCPKG_DETECTED_CMAKE_C_STANDARD_LIBRARIES}")
|
||||
separate_arguments(cpp_winlibs NATIVE_COMMAND "${VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIES}")
|
||||
z_vcpkg_meson_convert_list_to_python_array(c_winlibs ${c_winlibs})
|
||||
z_vcpkg_meson_convert_list_to_python_array(cpp_winlibs ${cpp_winlibs})
|
||||
set(MESON_WINLIBS "c_winlibs = ${c_winlibs}\n")
|
||||
string(APPEND MESON_WINLIBS "cpp_winlibs = ${cpp_winlibs}")
|
||||
set(MESON_WINLIBS "${MESON_WINLIBS}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(z_vcpkg_meson_setup_variables config_type)
|
||||
set(meson_var_list VSCRT_LINKAGE WINLIBS MT AR RC C C_LD CXX CXX_LD OBJC OBJC_LD OBJCXX OBJCXX_LD FC FC_LD WINDRES CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS FCFLAGS SHARED_LINKER_FLAGS)
|
||||
foreach(var IN LISTS meson_var_list)
|
||||
set(MESON_${var} "")
|
||||
endforeach()
|
||||
|
||||
if(VCPKG_TARGET_IS_WINDOWS)
|
||||
z_vcpkg_meson_setup_extra_windows_variables("${config_type}")
|
||||
endif()
|
||||
|
||||
z_vcpkg_meson_set_proglist_variables("${config_type}")
|
||||
z_vcpkg_meson_set_flags_variables("${config_type}")
|
||||
|
||||
foreach(var IN LISTS meson_var_list)
|
||||
set(MESON_${var} "${MESON_${var}}" PARENT_SCOPE)
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
function(vcpkg_generate_meson_cmd_args)
|
||||
cmake_parse_arguments(PARSE_ARGV 0 arg
|
||||
""
|
||||
"OUTPUT;CONFIG"
|
||||
"OPTIONS;LANGUAGES;ADDITIONAL_BINARIES;ADDITIONAL_PROPERTIES"
|
||||
)
|
||||
|
||||
if(NOT arg_LANGUAGES)
|
||||
set(arg_LANGUAGES C CXX)
|
||||
endif()
|
||||
|
||||
vcpkg_list(JOIN arg_ADDITIONAL_BINARIES "\n" MESON_ADDITIONAL_BINARIES)
|
||||
vcpkg_list(JOIN arg_ADDITIONAL_PROPERTIES "\n" MESON_ADDITIONAL_PROPERTIES)
|
||||
|
||||
set(buildtype "${arg_CONFIG}")
|
||||
|
||||
if(NOT VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
|
||||
z_vcpkg_select_default_vcpkg_chainload_toolchain()
|
||||
endif()
|
||||
vcpkg_list(APPEND VCPKG_CMAKE_CONFIGURE_OPTIONS "-DVCPKG_LANGUAGES=${arg_LANGUAGES}")
|
||||
vcpkg_cmake_get_vars(cmake_vars_file)
|
||||
debug_message("Including cmake vars from: ${cmake_vars_file}")
|
||||
include("${cmake_vars_file}")
|
||||
|
||||
vcpkg_list(APPEND arg_OPTIONS --backend ninja --wrap-mode nodownload -Doptimization=plain)
|
||||
|
||||
z_vcpkg_get_build_and_host_system(MESON_HOST_MACHINE MESON_BUILD_MACHINE IS_CROSS)
|
||||
|
||||
if(arg_CONFIG STREQUAL "DEBUG")
|
||||
set(suffix "dbg")
|
||||
else()
|
||||
string(SUBSTRING "${arg_CONFIG}" 0 3 suffix)
|
||||
string(TOLOWER "${suffix}" suffix)
|
||||
endif()
|
||||
set(meson_input_file_${buildtype} "${CURRENT_BUILDTREES_DIR}/meson-${TARGET_TRIPLET}-${suffix}.log")
|
||||
|
||||
if(IS_CROSS)
|
||||
# VCPKG_CROSSCOMPILING is not used since it regresses a lot of ports in x64-windows-x triplets
|
||||
# For consistency this should proably be changed in the future?
|
||||
vcpkg_list(APPEND arg_OPTIONS --native "${SCRIPTS}/buildsystems/meson/none.txt")
|
||||
vcpkg_list(APPEND arg_OPTIONS --cross "${meson_input_file_${buildtype}}")
|
||||
else()
|
||||
vcpkg_list(APPEND arg_OPTIONS --native "${meson_input_file_${buildtype}}")
|
||||
endif()
|
||||
|
||||
# User provided cross/native files
|
||||
if(VCPKG_MESON_NATIVE_FILE)
|
||||
vcpkg_list(APPEND arg_OPTIONS --native "${VCPKG_MESON_NATIVE_FILE}")
|
||||
endif()
|
||||
if(VCPKG_MESON_NATIVE_FILE_${buildtype})
|
||||
vcpkg_list(APPEND arg_OPTIONS --native "${VCPKG_MESON_NATIVE_FILE_${buildtype}}")
|
||||
endif()
|
||||
if(VCPKG_MESON_CROSS_FILE)
|
||||
vcpkg_list(APPEND arg_OPTIONS --cross "${VCPKG_MESON_CROSS_FILE}")
|
||||
endif()
|
||||
if(VCPKG_MESON_CROSS_FILE_${buildtype})
|
||||
vcpkg_list(APPEND arg_OPTIONS --cross "${VCPKG_MESON_CROSS_FILE_${buildtype}}")
|
||||
endif()
|
||||
|
||||
vcpkg_list(APPEND arg_OPTIONS --libdir lib) # else meson install into an architecture describing folder
|
||||
vcpkg_list(APPEND arg_OPTIONS --pkgconfig.relocatable)
|
||||
|
||||
if(arg_CONFIG STREQUAL "RELEASE")
|
||||
vcpkg_list(APPEND arg_OPTIONS -Ddebug=false --prefix "${CURRENT_PACKAGES_DIR}")
|
||||
vcpkg_list(APPEND arg_OPTIONS "--pkg-config-path;['${CURRENT_INSTALLED_DIR}/lib/pkgconfig','${CURRENT_INSTALLED_DIR}/share/pkgconfig']")
|
||||
if(VCPKG_TARGET_IS_WINDOWS)
|
||||
vcpkg_list(APPEND arg_OPTIONS "-Dcmake_prefix_path=['${CURRENT_INSTALLED_DIR}','${CURRENT_INSTALLED_DIR}/debug','${CURRENT_INSTALLED_DIR}/share']")
|
||||
else()
|
||||
vcpkg_list(APPEND arg_OPTIONS "-Dcmake_prefix_path=['${CURRENT_INSTALLED_DIR}','${CURRENT_INSTALLED_DIR}/debug']")
|
||||
endif()
|
||||
elseif(arg_CONFIG STREQUAL "DEBUG")
|
||||
vcpkg_list(APPEND arg_OPTIONS -Ddebug=true --prefix "${CURRENT_PACKAGES_DIR}/debug" --includedir ../include)
|
||||
vcpkg_list(APPEND arg_OPTIONS "--pkg-config-path;['${CURRENT_INSTALLED_DIR}/debug/lib/pkgconfig','${CURRENT_INSTALLED_DIR}/share/pkgconfig']")
|
||||
if(VCPKG_TARGET_IS_WINDOWS)
|
||||
vcpkg_list(APPEND arg_OPTIONS "-Dcmake_prefix_path=['${CURRENT_INSTALLED_DIR}/debug','${CURRENT_INSTALLED_DIR}','${CURRENT_INSTALLED_DIR}/share']")
|
||||
else()
|
||||
vcpkg_list(APPEND arg_OPTIONS "-Dcmake_prefix_path=['${CURRENT_INSTALLED_DIR}/debug','${CURRENT_INSTALLED_DIR}']")
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown configuration. Only DEBUG and RELEASE are valid values.")
|
||||
endif()
|
||||
|
||||
# Allow overrides / additional configuration variables from triplets
|
||||
if(DEFINED VCPKG_MESON_CONFIGURE_OPTIONS)
|
||||
vcpkg_list(APPEND arg_OPTIONS ${VCPKG_MESON_CONFIGURE_OPTIONS})
|
||||
endif()
|
||||
if(DEFINED VCPKG_MESON_CONFIGURE_OPTIONS_${buildtype})
|
||||
vcpkg_list(APPEND arg_OPTIONS ${VCPKG_MESON_CONFIGURE_OPTIONS_${buildtype}})
|
||||
endif()
|
||||
|
||||
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
|
||||
set(MESON_DEFAULT_LIBRARY shared)
|
||||
else()
|
||||
set(MESON_DEFAULT_LIBRARY static)
|
||||
endif()
|
||||
set(MESON_CMAKE_BUILD_TYPE "${cmake_build_type_${buildtype}}")
|
||||
z_vcpkg_meson_setup_variables(${buildtype})
|
||||
configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/meson.template.in" "${meson_input_file_${buildtype}}" @ONLY)
|
||||
set("${arg_OUTPUT}" ${arg_OPTIONS} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(vcpkg_configure_meson)
|
||||
# parse parameters such that semicolons in options arguments to COMMAND don't get erased
|
||||
cmake_parse_arguments(PARSE_ARGV 0 arg
|
||||
"NO_PKG_CONFIG"
|
||||
"SOURCE_PATH"
|
||||
"OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE;LANGUAGES;ADDITIONAL_BINARIES;ADDITIONAL_NATIVE_BINARIES;ADDITIONAL_CROSS_BINARIES;ADDITIONAL_PROPERTIES"
|
||||
)
|
||||
|
||||
if(DEFINED arg_ADDITIONAL_NATIVE_BINARIES OR DEFINED arg_ADDITIONAL_CROSS_BINARIES)
|
||||
message(WARNING "Options ADDITIONAL_(NATIVE|CROSS)_BINARIES have been deprecated. Only use ADDITIONAL_BINARIES!")
|
||||
endif()
|
||||
vcpkg_list(APPEND arg_ADDITIONAL_BINARIES ${arg_ADDITIONAL_NATIVE_BINARIES} ${arg_ADDITIONAL_CROSS_BINARIES})
|
||||
vcpkg_list(REMOVE_DUPLICATES arg_ADDITIONAL_BINARIES)
|
||||
|
||||
file(REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel")
|
||||
file(REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg")
|
||||
|
||||
vcpkg_find_acquire_program(MESON)
|
||||
|
||||
get_filename_component(CMAKE_PATH "${CMAKE_COMMAND}" DIRECTORY)
|
||||
vcpkg_add_to_path("${CMAKE_PATH}") # Make CMake invokeable for Meson
|
||||
|
||||
vcpkg_find_acquire_program(NINJA)
|
||||
|
||||
if(NOT arg_NO_PKG_CONFIG)
|
||||
vcpkg_find_acquire_program(PKGCONFIG)
|
||||
set(ENV{PKG_CONFIG} "${PKGCONFIG}")
|
||||
endif()
|
||||
|
||||
vcpkg_find_acquire_program(PYTHON3)
|
||||
get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY)
|
||||
vcpkg_add_to_path(PREPEND "${PYTHON3_DIR}")
|
||||
|
||||
set(buildtypes "")
|
||||
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
|
||||
set(buildname "DEBUG")
|
||||
set(cmake_build_type_${buildname} "Debug")
|
||||
vcpkg_list(APPEND buildtypes "${buildname}")
|
||||
set(path_suffix_${buildname} "debug/")
|
||||
set(suffix_${buildname} "dbg")
|
||||
endif()
|
||||
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
|
||||
set(buildname "RELEASE")
|
||||
set(cmake_build_type_${buildname} "Release")
|
||||
vcpkg_list(APPEND buildtypes "${buildname}")
|
||||
set(path_suffix_${buildname} "")
|
||||
set(suffix_${buildname} "rel")
|
||||
endif()
|
||||
|
||||
# configure build
|
||||
foreach(buildtype IN LISTS buildtypes)
|
||||
message(STATUS "Configuring ${TARGET_TRIPLET}-${suffix_${buildtype}}")
|
||||
file(MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${suffix_${buildtype}}")
|
||||
|
||||
vcpkg_generate_meson_cmd_args(
|
||||
OUTPUT cmd_args
|
||||
CONFIG ${buildtype}
|
||||
LANGUAGES ${arg_LANGUAGES}
|
||||
OPTIONS ${arg_OPTIONS} ${arg_OPTIONS_${buildtype}}
|
||||
ADDITIONAL_BINARIES ${arg_ADDITIONAL_BINARIES}
|
||||
ADDITIONAL_PROPERTIES ${arg_ADDITIONAL_PROPERTIES}
|
||||
)
|
||||
|
||||
vcpkg_execute_required_process(
|
||||
COMMAND ${MESON} setup ${cmd_args} ${arg_SOURCE_PATH}
|
||||
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${suffix_${buildtype}}"
|
||||
LOGNAME config-${TARGET_TRIPLET}-${suffix_${buildtype}}
|
||||
SAVE_LOG_FILES
|
||||
meson-logs/meson-log.txt
|
||||
meson-info/intro-dependencies.json
|
||||
meson-logs/install-log.txt
|
||||
)
|
||||
|
||||
message(STATUS "Configuring ${TARGET_TRIPLET}-${suffix_${buildtype}} done")
|
||||
endforeach()
|
||||
endfunction()
|
71
cmake/vcpkg-ports/vcpkg-tool-meson/vcpkg_install_meson.cmake
Normal file
71
cmake/vcpkg-ports/vcpkg-tool-meson/vcpkg_install_meson.cmake
Normal file
@ -0,0 +1,71 @@
|
||||
function(vcpkg_install_meson)
|
||||
cmake_parse_arguments(PARSE_ARGV 0 arg "ADD_BIN_TO_PATH" "" "")
|
||||
|
||||
vcpkg_find_acquire_program(NINJA)
|
||||
unset(ENV{DESTDIR}) # installation directory was already specified with '--prefix' option
|
||||
|
||||
if(VCPKG_TARGET_IS_OSX)
|
||||
vcpkg_backup_env_variables(VARS SDKROOT MACOSX_DEPLOYMENT_TARGET)
|
||||
set(ENV{SDKROOT} "${VCPKG_DETECTED_CMAKE_OSX_SYSROOT}")
|
||||
set(ENV{MACOSX_DEPLOYMENT_TARGET} "${VCPKG_DETECTED_CMAKE_OSX_DEPLOYMENT_TARGET}")
|
||||
endif()
|
||||
|
||||
foreach(buildtype IN ITEMS "debug" "release")
|
||||
if(DEFINED VCPKG_BUILD_TYPE AND NOT VCPKG_BUILD_TYPE STREQUAL buildtype)
|
||||
continue()
|
||||
endif()
|
||||
|
||||
if(buildtype STREQUAL "debug")
|
||||
set(short_buildtype "dbg")
|
||||
else()
|
||||
set(short_buildtype "rel")
|
||||
endif()
|
||||
|
||||
message(STATUS "Package ${TARGET_TRIPLET}-${short_buildtype}")
|
||||
if(arg_ADD_BIN_TO_PATH)
|
||||
vcpkg_backup_env_variables(VARS PATH)
|
||||
if(buildtype STREQUAL "debug")
|
||||
vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}/debug/bin")
|
||||
else()
|
||||
vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}/bin")
|
||||
endif()
|
||||
endif()
|
||||
vcpkg_execute_required_process(
|
||||
COMMAND "${NINJA}" install -v
|
||||
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${short_buildtype}"
|
||||
LOGNAME package-${TARGET_TRIPLET}-${short_buildtype}
|
||||
)
|
||||
if(arg_ADD_BIN_TO_PATH)
|
||||
vcpkg_restore_env_variables(VARS PATH)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
vcpkg_list(SET renamed_libs)
|
||||
if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_LIBRARY_LINKAGE STREQUAL static AND NOT VCPKG_TARGET_IS_MINGW)
|
||||
# Meson names all static libraries lib<name>.a which basically breaks the world
|
||||
file(GLOB_RECURSE gen_libraries "${CURRENT_PACKAGES_DIR}*/**/lib*.a")
|
||||
foreach(gen_library IN LISTS gen_libraries)
|
||||
get_filename_component(libdir "${gen_library}" DIRECTORY)
|
||||
get_filename_component(libname "${gen_library}" NAME)
|
||||
string(REGEX REPLACE ".a$" ".lib" fixed_librawname "${libname}")
|
||||
string(REGEX REPLACE "^lib" "" fixed_librawname "${fixed_librawname}")
|
||||
file(RENAME "${gen_library}" "${libdir}/${fixed_librawname}")
|
||||
# For cmake fixes.
|
||||
string(REGEX REPLACE ".a$" "" origin_librawname "${libname}")
|
||||
string(REGEX REPLACE ".lib$" "" fixed_librawname "${fixed_librawname}")
|
||||
vcpkg_list(APPEND renamed_libs ${fixed_librawname})
|
||||
set(${librawname}_old ${origin_librawname})
|
||||
set(${librawname}_new ${fixed_librawname})
|
||||
endforeach()
|
||||
file(GLOB_RECURSE cmake_files "${CURRENT_PACKAGES_DIR}*/*.cmake")
|
||||
foreach(cmake_file IN LISTS cmake_files)
|
||||
foreach(current_lib IN LISTS renamed_libs)
|
||||
vcpkg_replace_string("${cmake_file}" "${${current_lib}_old}" "${${current_lib}_new}" IGNORE_UNCHANGED)
|
||||
endforeach()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(VCPKG_TARGET_IS_OSX)
|
||||
vcpkg_restore_env_variables(VARS SDKROOT MACOSX_DEPLOYMENT_TARGET)
|
||||
endif()
|
||||
endfunction()
|
8
cmake/vcpkg-triplets/universal-osx.cmake
Normal file
8
cmake/vcpkg-triplets/universal-osx.cmake
Normal file
@ -0,0 +1,8 @@
|
||||
# See https://github.com/microsoft/vcpkg/discussions/19454
|
||||
# NOTE: Try to keep in sync with default arm64-osx definition
|
||||
set(VCPKG_TARGET_ARCHITECTURE x64)
|
||||
set(VCPKG_CRT_LINKAGE dynamic)
|
||||
set(VCPKG_LIBRARY_LINKAGE static)
|
||||
|
||||
set(VCPKG_CMAKE_SYSTEM_NAME Darwin)
|
||||
set(VCPKG_OSX_ARCHITECTURES "arm64;x86_64")
|
@ -10,5 +10,11 @@
|
||||
"location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip",
|
||||
"name": "microsoft"
|
||||
}
|
||||
],
|
||||
"overlay-ports": [
|
||||
"./cmake/vcpkg-ports"
|
||||
],
|
||||
"overlay-triplets": [
|
||||
"./cmake/vcpkg-triplets"
|
||||
]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user