From 5f13fb683b9b648db557c3e4e88835c917d90b57 Mon Sep 17 00:00:00 2001 From: YobeZhou Date: Mon, 13 Jan 2025 12:45:16 +0800 Subject: [PATCH] feat(cmake): add user cross compile setup --- README.md | 10 +++++++++- user_cross_compile_setup.cmake | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 user_cross_compile_setup.cmake diff --git a/README.md b/README.md index e46deec..a673f45 100644 --- a/README.md +++ b/README.md @@ -59,13 +59,21 @@ To use wayland, adjust `lv_conf.h` as follows: #define LV_USE_WAYLAND 1 ``` - ### cmake +1. gcc compiler: + ``` cmake -B build -S . make -C build -j ``` +2. Cross compiler: + +``` +vim ./user_cross_compile_setup.cmake +cmake -DCMAKE_TOOLCHAIN_FILE=./user_cross_compile_setup.cmake -B build -S . +make -C build -j +``` ### Makefile diff --git a/user_cross_compile_setup.cmake b/user_cross_compile_setup.cmake new file mode 100644 index 0000000..ba42189 --- /dev/null +++ b/user_cross_compile_setup.cmake @@ -0,0 +1,15 @@ +# Usage: +# cmake -DCMAKE_TOOLCHAIN_FILE=./user_cross_compile_setup.cmake -B build -S . +# make -C build -j + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR arm) + +set(tools /home/ubuntu/Your_SDK/prebuilt/rootfsbuilt/arm/toolchain-glibc-gcc/toolchain) +set(CMAKE_C_COMPILER ${tools}/bin/arm-openwrt-linux-gnueabi-gcc) +set(CMAKE_CXX_COMPILER ${tools}/bin/arm-openwrt-linux-gnueabi-g++) + +# If necessary, set STAGING_DIR +# if not work, please try(in shell command): export STAGING_DIR=/home/ubuntu/Your_SDK/out/xxx/openwrt/staging_dir/target +#set(ENV{STAGING_DIR} "/home/ubuntu/Your_SDK/out/xxx/openwrt/staging_dir/target") +