mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2025-12-06 08:46:47 +08:00
Fix compile error for riscv scalar & simplify cmake cross build flow
1. Fix compile error when build riscv without using vector 2. Fix run_qemu.sh misused v=true for USE_RVV=OFF case 3. [cmake] Fix warning by rename TEST to UNIT_TEST Warning log: CMake Warning (dev) at CMakeLists.txt:57 (if): [54/1931] Policy CMP0064 is not set: Support new TEST if() operator. Run "cmake --help-policy CMP0064" for policy details. Use the cmake_policy command to set the policy and suppress this warning. TEST will be interpreted as an operator when the policy is set to NEW. Since the policy is not set the OLD behavior will be used. This warning is for project developers. Use -Wno-dev to suppress it. 4. [cmake] Simplify logic for cross-build Bug: libyuv:956 Change-Id: I120402fc7d6d86403e7d974180b81f4f9c663e36 Signed-off-by: Bruce Lai <bruce.lai@sifive.com> Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/4486239 Reviewed-by: Frank Barchard <fbarchard@chromium.org> Reviewed-by: Mirko Bonadei <mbonadei@chromium.org> Commit-Queue: Frank Barchard <fbarchard@chromium.org>
This commit is contained in:
parent
8811ad8ba1
commit
f4bd840794
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
PROJECT ( YUV C CXX ) # "C" is required even for C++ projects
|
PROJECT ( YUV C CXX ) # "C" is required even for C++ projects
|
||||||
CMAKE_MINIMUM_REQUIRED( VERSION 2.8.12 )
|
CMAKE_MINIMUM_REQUIRED( VERSION 2.8.12 )
|
||||||
OPTION( TEST "Built unit tests" OFF )
|
OPTION( UNIT_TEST "Built unit tests" OFF )
|
||||||
|
|
||||||
SET ( ly_base_dir ${PROJECT_SOURCE_DIR} )
|
SET ( ly_base_dir ${PROJECT_SOURCE_DIR} )
|
||||||
SET ( ly_src_dir ${ly_base_dir}/source )
|
SET ( ly_src_dir ${ly_base_dir}/source )
|
||||||
@ -52,25 +52,23 @@ if (JPEG_FOUND)
|
|||||||
add_definitions( -DHAVE_JPEG )
|
add_definitions( -DHAVE_JPEG )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(TEST)
|
if(UNIT_TEST)
|
||||||
if (NOT CMAKE_CROSSCOMPILING)
|
find_library(GTEST_LIBRARY gtest)
|
||||||
find_library(GTEST_LIBRARY gtest)
|
if(GTEST_LIBRARY STREQUAL "GTEST_LIBRARY-NOTFOUND")
|
||||||
if(GTEST_LIBRARY STREQUAL "GTEST_LIBRARY-NOTFOUND")
|
set(GTEST_SRC_DIR /usr/src/gtest CACHE STRING "Location of gtest sources")
|
||||||
set(GTEST_SRC_DIR /usr/src/gtest CACHE STRING "Location of gtest sources")
|
if (CMAKE_CROSSCOMPILING)
|
||||||
if(EXISTS ${GTEST_SRC_DIR}/src/gtest-all.cc)
|
set(GTEST_SRC_DIR third_party/googletest/src/googletest)
|
||||||
message(STATUS "building gtest from sources in ${GTEST_SRC_DIR}")
|
endif()
|
||||||
set(gtest_sources ${GTEST_SRC_DIR}/src/gtest-all.cc)
|
if(EXISTS ${GTEST_SRC_DIR}/src/gtest-all.cc)
|
||||||
add_library(gtest STATIC ${gtest_sources})
|
message(STATUS "building gtest from sources in ${GTEST_SRC_DIR}")
|
||||||
include_directories(${GTEST_SRC_DIR})
|
set(gtest_sources ${GTEST_SRC_DIR}/src/gtest-all.cc)
|
||||||
include_directories(${GTEST_SRC_DIR}/include)
|
add_library(gtest STATIC ${gtest_sources})
|
||||||
set(GTEST_LIBRARY gtest)
|
include_directories(${GTEST_SRC_DIR})
|
||||||
else()
|
include_directories(${GTEST_SRC_DIR}/include)
|
||||||
message(FATAL_ERROR "TEST is set but unable to find gtest library")
|
set(GTEST_LIBRARY gtest)
|
||||||
endif()
|
else()
|
||||||
|
message(FATAL_ERROR "UNIT_TEST is set but unable to find gtest library")
|
||||||
endif()
|
endif()
|
||||||
else()
|
|
||||||
add_subdirectory(third_party/googletest/src)
|
|
||||||
set(GTEST_LIBRARY gtest)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(libyuv_unittest ${ly_unittest_sources})
|
add_executable(libyuv_unittest ${ly_unittest_sources})
|
||||||
|
|||||||
@ -231,7 +231,7 @@ If you don't have prebuilt clang and riscv64 qemu, run the script to download so
|
|||||||
After running script, clang & qemu are built in `build-toolchain-qemu/riscv-clang/` & `build-toolchain-qemu/riscv-qemu/`.
|
After running script, clang & qemu are built in `build-toolchain-qemu/riscv-clang/` & `build-toolchain-qemu/riscv-qemu/`.
|
||||||
|
|
||||||
### Cross-compile for RISC-V target
|
### Cross-compile for RISC-V target
|
||||||
cmake -B out/Release/ -DTEST=ON \
|
cmake -B out/Release/ -DUNIT_TEST=ON \
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
-DCMAKE_TOOLCHAIN_FILE="./riscv_script/riscv-clang.cmake" \
|
-DCMAKE_TOOLCHAIN_FILE="./riscv_script/riscv-clang.cmake" \
|
||||||
-DTOOLCHAIN_PATH={TOOLCHAIN_PATH} \
|
-DTOOLCHAIN_PATH={TOOLCHAIN_PATH} \
|
||||||
|
|||||||
@ -757,7 +757,7 @@ extern "C" {
|
|||||||
#define HAS_RAWTOYJROW_LASX
|
#define HAS_RAWTOYJROW_LASX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(LIBYUV_DISABLE_RVV) && defined(__riscv)
|
#if !defined(LIBYUV_DISABLE_RVV) && defined(__riscv_vector)
|
||||||
#define HAS_AB64TOARGBROW_RVV
|
#define HAS_AB64TOARGBROW_RVV
|
||||||
#define HAS_AR64TOARGBROW_RVV
|
#define HAS_AR64TOARGBROW_RVV
|
||||||
#define HAS_ARGBTOAB64ROW_RVV
|
#define HAS_ARGBTOAB64ROW_RVV
|
||||||
|
|||||||
@ -9,7 +9,7 @@ QEMU_PREFIX_PATH="${QEMU_PREFIX_PATH:-../../build-toolchain-qemu/riscv-qemu/}"
|
|||||||
if [ "${USE_RVV}" = "ON" ];then
|
if [ "${USE_RVV}" = "ON" ];then
|
||||||
QEMU_OPTION="-cpu rv64,zba=true,zbb=true,zbc=true,zbs=true,v=true,vlen=512,elen=64,vext_spec=v1.0 -L ${TOOLCHAIN_PATH}/sysroot"
|
QEMU_OPTION="-cpu rv64,zba=true,zbb=true,zbc=true,zbs=true,v=true,vlen=512,elen=64,vext_spec=v1.0 -L ${TOOLCHAIN_PATH}/sysroot"
|
||||||
else
|
else
|
||||||
QEMU_OPTION="-cpu rv64,zba=true,zbb=true,zbc=true,zbs=true,v=true -L ${TOOLCHAIN_PATH}/sysroot"
|
QEMU_OPTION="-cpu rv64,zba=true,zbb=true,zbc=true,zbs=true -L ${TOOLCHAIN_PATH}/sysroot"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$QEMU_PREFIX_PATH/bin/qemu-riscv64 $QEMU_OPTION $@
|
$QEMU_PREFIX_PATH/bin/qemu-riscv64 $QEMU_OPTION $@
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include "libyuv/row.h"
|
#include "libyuv/row.h"
|
||||||
|
|
||||||
#if !defined(LIBYUV_DISABLE_RVV) && defined(__riscv)
|
#if !defined(LIBYUV_DISABLE_RVV) && defined(__riscv_vector)
|
||||||
#include <riscv_vector.h>
|
#include <riscv_vector.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -323,4 +323,4 @@ void MergeXRGBRow_RVV(const uint8_t* src_r,
|
|||||||
} // namespace libyuv
|
} // namespace libyuv
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // !defined(LIBYUV_DISABLE_RVV) && defined(__riscv)
|
#endif // !defined(LIBYUV_DISABLE_RVV) && defined(__riscv_vector)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user