telechips平台交叉编译cmake工程

cmake提供了一个很方便的配置文件xxx.cmake来配置交叉编译环境

对于普通的交叉编译,在.cmake文件中编写大概如下文件

SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_C_COMPILER /opt/fsl-imx-wayland/4.9.88-2.2.0_8qxp_beta2/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc)
SET(CMAKE_CXX_COMPILER /opt/fsl-imx-wayland/4.9.88-2.2.0_8qxp_beta2/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++)
SET(CMAKE_FIND_ROOT_PATH /opt/fsl-imx-wayland/4.9.88-2.2.0_8qxp_beta2/sysroots/cortexa9hf-neon-poky-linux-gnueabi/ /opt/fsl-imx-wayland/4.1.15-2.0.0/sysroots/x86_64-pokysdk-linux/)

SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

但在yocto中提供了一个很强大的配方,该配方会生成配套的.cmake文件,具有更完整更优化的配置

TOOLCHAIN_HOST_TASK += "nativesdk-cmake"

使用该配方生成的.cmake大概如下

set( CMAKE_SYSTEM_NAME Linux )
set( CMAKE_C_FLAGS $ENV{CFLAGS} CACHE STRING "" FORCE )
set( CMAKE_CXX_FLAGS $ENV{CXXFLAGS}  CACHE STRING "" FORCE )
set( CMAKE_ASM_FLAGS ${CMAKE_C_FLAGS} CACHE STRING "" FORCE )
set( CMAKE_LDFLAGS_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE )

set( CMAKE_FIND_ROOT_PATH $ENV{OECORE_TARGET_SYSROOT} $ENV{OECORE_NATIVE_SYSROOT} )
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY )

# Set CMAKE_SYSTEM_PROCESSOR from the sysroot name (assuming processor-distro-os).
if ($ENV{SDKTARGETSYSROOT} MATCHES "/sysroots/([a-zA-Z0-9_-]+)-.+-.+")
  set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_MATCH_1})
endif()

# Include the toolchain configuration subscripts
file( GLOB toolchain_config_files "${CMAKE_TOOLCHAIN_FILE}.d/*.cmake" )
foreach(config ${toolchain_config_files})
    include(${config})
endforeach()

用法非常简单,原文如下

Assuming that you're using the image based SDK, i.e. building it with bitbake <image> -c populate_sdk, adding the following toimage.bb should fix it:
That should give you a OEToolchainConfig.cmake file in the SDK. After sourcing the SDK environment file, cmake will be an alias to cmake -DCMAKE_TOOLCHAIN_FILE=$OECORE_NATIVE_SYSROOT/usr/share/cmake/OEToolchainConfig.cmake to further help your developers.

将该配方放入配置文件local.conf即可,通过如下编译命令将SDK编译出来,telechips平台选择如下,注意不能和qt一起(qtbase和cmake会产生冲突)

timotheus@timotheus-XPS:~/fould/dolphin/Linux_Platform$ source poky/als-build.sh 
Choose MACHINE
  1. tcc8030
select number(1-1) => 1
machine(tcc8030) selected.
Yocto Project common targets are:
    core-image-minimal
    core-image-sato
    meta-toolchain
    adt-installer
    meta-ide-support


Telechips common targets are:
    telechips-ivi-image-minimal
    telechips-ivi-image-gstreamer(minimal + GStreamer)
    telechips-ivi-image-qt(minimal + Qt)
    telechips-ivi-image(minimal + GStreamer + Qt)

    meta-toolchain-telechips(Application Development Toolkit)
    meta-toolchain-telechips-ivi(Application Development Toolkit include GStreamer)
    meta-toolchain-telechips-qt5(Application Development Toolkit include GStreamer and Qt5)


Telechips Automotive Linux Platform targets are:
    automotive-linux-platform-image(telechips-ivi-image + demo applications)

You can also run generated qemu images with a command like 'runqemu qemux86'
 or
You can also run generated Telechips images on Telechips EVM Boards(eg. tcc8030)

timotheus@timotheus-XPS:~/fould/dolphin/Linux_Platform/build/tcc8030$ bitbake -c populate_sdk meta-toolchain-telechips-ivi

选择一个不含Qt的配方,编译出来后,会在SDK里生成一个OEToolchainConfig.cmake文件
这个文件除了可以像原文一样用法之外,还可以在cmake-gui里导入,不过要求cmake-gui 3.x版本
由于OEToolchainConfig.cmake里面全是环境变量,所以不管cmake还是cmake-gui在运行前都得运行环境变量脚本

Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
 $ . /opt/poky-telechips-systemd/nodistro.0/environment-setup-aarch64-telechips-linux

打开cmake-gui,然后选择Specify toolchain file for cross-compiling选项,导入OEToolchainConfig.cmake,编译opengl程序

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值