meganz / sdk

MEGA C++ SDK
BSD 2-Clause "Simplified" License
1.33k stars 509 forks source link

Adjust 3rd party build script to support macOS #2534

Closed mega-lia closed 3 years ago

mega-lia commented 3 years ago

Builds off of Matt's work on the build3rdparty tool, adding support for macOS with new features added to address issues that turned up therein. In particular:

New triplet x64-osx-mega

This is borrowed wholesale from @aabellagm -- a custom vcpkg triplet file which is the preferred way to build mac dependencies (and the one assumed by the CMakeLists.txt. Its main feature is to specify dynamic library builds for certain libraries based on licensing issues and/or conformance with the Windows approach. Note that the official vcpkg mac triplet x64-osx builds static, and x64-osx-dynamic is a "community triplet" without official support, so some port require (or may require in the future) patches, see below.

CMake changes

Fixed a bug/corner case in the old implementation of ImportStdVcpkgLibrary where, if the libary was not installed by vcpkg or library.a did not exist, the function would fail silently and attempt to link the system installed version of the library. Failure to find the desired library name is now a fatal error, and the function checks first for static libraries and then dynamic libraries to accommodate dynamic libraries installed by the x64-osx-mega triplet.

Some minor updates/cleanups as well.

Patch files

A port entry library/version may now have library/version:some-patch.patch to indicate a patch that should be applied to the port for library. The file some-patch.patch shall name a patch in cmake/vcpkg_patches, which shall be applicable in the directory vcpkg/ports/library. Currently only one patch is supported with the syntax, and if there are duplicate entries in the preferred ports, e.g.,

library/version:some-patch.patch
...
library/version:another-patch.patch

this is an error. These patches are meant to make simple adjustments to the build/install logic for vcpkg ports; attempting more advanced operations is ill-advised. Patches give us further recourse to avoid introducing ports in vcpkg_extra_ports, but if you need to make a lot of source level changes to a library you should make them that way.

Applications

Platform include/exclude expressions

A port entry may look like

library/version !platform
library/version platform

The !platform means do not build on that platform; without the ! means only on that platform. Currently supported platform are windows, linux, osx.

Applications

pkgconfig suppression

You can now pass --nopkgconfig to build3rdparty to indicate that the port files should not worry about anything to do with pkgconfig. This is accomplished with some CMake trickery that patches vcpkg's script files to replace pkgconfig-related operations with no-ops.

JenkinsMega commented 3 years ago

megasdk-crossAndroid-PRs SUCCEDED (1534) :+1:

JenkinsMega commented 3 years ago

megasdk-crossAndroid-PRs SUCCEDED (1535) :+1:

JenkinsMega commented 3 years ago

megasdk_PR FAILED (3877) :-1:

JenkinsMega commented 3 years ago

megasdk-winx64-PRs SUCCEDED (1359) :+1:

JenkinsMega commented 3 years ago

megasdk_PR FAILED (3878) :-1:

JenkinsMega commented 3 years ago

megasdk-winx64-PRs FAILED (1360) :-1: