[x265] [PATCH 04/12] AArch64: Refactor cross-compilation options

Hari Limaye hari.limaye at arm.com
Thu May 2 21:19:39 UTC 2024


The existing Cross Compilation toolchains for AArch64 use environment
variables to specify optional features, such as SVE/SVE2, which are then
used to set CMake variables.

Refactor this using CMake options (boolean cache variables), so that
these can be set directly when running CMake to configure the project.
As the options are defined in the top-level CMakeLists file the
duplication between cross-compilation toolchain files is reduced.
---
 build/README.txt                        | 12 ++++++------
 build/aarch64-darwin/crosscompile.cmake |  7 -------
 build/aarch64-linux/crosscompile.cmake  |  7 -------
 source/CMakeLists.txt                   |  4 ++++
 4 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/build/README.txt b/build/README.txt
index 1528e9837..af4abd21c 100644
--- a/build/README.txt
+++ b/build/README.txt
@@ -106,11 +106,11 @@ running CMake to configure the project. For example:

 * cmake -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++

-Moreover, if the target platform supports SVE or SVE2 instruction set, the
-CROSS_COMPILE_SVE or CROSS_COMPILE_SVE2 environment variables should be set
-to true, respectively. For example:
+Moreover, if the target platform supports SVE or SVE2, CROSS_COMPILE_SVE or
+CROSS_COMPILE_SVE2 CMake options should be set to ON, respectively.
+For example, when running CMake to configure the project:

-1. export CROSS_COMPILE_SVE2=true
-2. export CROSS_COMPILE_SVE=true
+1. cmake -DCROSS_COMPILE_SVE=ON  <other configuration options...>
+2. cmake -DCROSS_COMPILE_SVE2=ON <other configuration options...>

-Then, the normal building process can be followed.
+Then, the normal build process can be followed.
diff --git a/build/aarch64-darwin/crosscompile.cmake b/build/aarch64-darwin/crosscompile.cmake
index 289c32bca..6037d5ed6 100644
--- a/build/aarch64-darwin/crosscompile.cmake
+++ b/build/aarch64-darwin/crosscompile.cmake
@@ -18,10 +18,3 @@ endif()
 # specify the target environment
 SET(CMAKE_FIND_ROOT_PATH  /opt/homebrew/bin/)

-# specify whether SVE/SVE2 is supported by the target platform
-if(DEFINED ENV{CROSS_COMPILE_SVE2})
-    set(CROSS_COMPILE_SVE2 1)
-elseif(DEFINED ENV{CROSS_COMPILE_SVE})
-    set(CROSS_COMPILE_SVE 1)
-endif()
-
diff --git a/build/aarch64-linux/crosscompile.cmake b/build/aarch64-linux/crosscompile.cmake
index 932b472c4..caf26af77 100644
--- a/build/aarch64-linux/crosscompile.cmake
+++ b/build/aarch64-linux/crosscompile.cmake
@@ -18,10 +18,3 @@ endif()
 # specify the target environment
 SET(CMAKE_FIND_ROOT_PATH  /usr/aarch64-linux-gnu)

-# specify whether SVE/SVE2 is supported by the target platform
-if(DEFINED ENV{CROSS_COMPILE_SVE2})
-    set(CROSS_COMPILE_SVE2 1)
-elseif(DEFINED ENV{CROSS_COMPILE_SVE})
-    set(CROSS_COMPILE_SVE 1)
-endif()
-
diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index ab5ddfeb7..413311de7 100755
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -88,6 +88,10 @@ elseif(ARM64MATCH GREATER "-1")
     message(STATUS "Detected ARM64 target processor")
     set(ARM64 1)
     add_definitions(-DX265_ARCH_ARM64=1 -DHAVE_NEON)
+
+    # Options for cross compiling AArch64 optional extensions
+    option(CROSS_COMPILE_SVE "Cross Compile for SVE Target" OFF)
+    option(CROSS_COMPILE_SVE2 "Cross Compile for SVE2 Target" OFF)
 else()
     message(STATUS "CMAKE_SYSTEM_PROCESSOR value `${CMAKE_SYSTEM_PROCESSOR}` is unknown")
     message(STATUS "Please add this value near ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE}")
--
2.42.1

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


More information about the x265-devel mailing list