Skip to content

Linux ARM64 Support for CMake #2699

@thurask

Description

@thurask

I'm attempting to get MEGASync built from source on Raspberry Pi OS Bookworm ARM64 on a Raspberry Pi 5, as currently configured the build breaks because there is no ARM64 Linux target for CMake inside the SDK. I whipped up a quick CMake triplet file that does build with default options, cmake/vcpkg_overlay_triplets/arm64-linux.cmake:

set(VCPKG_TARGET_ARCHITECTURE arm64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_CMAKE_SYSTEM_NAME Linux)

if(PORT MATCHES "ffmpeg")
    # build this library as dynamic (usually because it is LGPL licensed)
    set(VCPKG_LIBRARY_LINKAGE dynamic)
else()
    # build this library statically (much simpler installation, debugging, etc)
        set(VCPKG_LIBRARY_LINKAGE static)
endif()

As well as the necessary edit to cmake/modules/vcpkg_management.cmake:

--- a/cmake/modules/vcpkg_management.cmake
+++ b/cmake/modules/vcpkg_management.cmake
@@ -28,6 +28,8 @@ macro(process_vcpkg_libraries overlays_path)
         else()
             if (CMAKE_SYSTEM_PROCESSOR MATCHES "armv7l" OR (NOT CMAKE_SYSTEM_PROCESSOR AND HOST_ARCH MATCHES "armv7l"))
                 set(VCPKG_TARGET_TRIPLET "arm-linux")
+            elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" OR (NOT CMAKE_SYSTEM_PROCESSOR AND HOST_ARCH MATCHES "aarch64"))
+                set(VCPKG_TARGET_TRIPLET "arm64-linux")
             else()
                 set(VCPKG_TARGET_TRIPLET "x64-linux-mega")
             endif()

In order for this to build the only deviations from the README instructions are to:

  1. Preface the build command with VCPKG_FORCE_SYSTEM_BINARIES, i.e. VCPKG_FORCE_SYSTEM_BINARIES=1 cmake -DVCPKG_ROOT=vcpkg -DCMAKE_BUILD_TYPE=Release -S sdk -B build_dir
  2. Install additional prerequisites of cmake and ninja-build because of above; I also installed kernel headers just in case.

Without the force system binaries VCPKG complains that it's necessary on ARM and S390 platforms.

Build output attached.
cmake_config.txt
cmake_make.txt

Metadata

Metadata

Assignees

Labels

building-systemRelated to building sytemenhancementNew features or enhancements of existing ones

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions