交叉编译

编程入门 行业动态 更新时间:2024-10-26 20:35:43
本文介绍了交叉编译 - 检索目标CPU和版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用cmake交叉编译VxWorks。当我运行cmake的第一次,我必须提供有关编译器,目标操作系统等的信息。

在交叉编译对话框有三个目标系统设置我设置:

  • 操作系统
  • 版本
  • 处理器
  • 虽然我可以使用 CMAKE_SYSTEM_NAME 检索第一个,但我无法获得版本和处理器。 两者都返回一个空字符串。

    这里有一个例子:

    MESSAGE(CMAKE_SYSTEM_PROCESSOR:$ {CMAKE_SYSTEM_PROCESSOR}) MESSAGE(CMAKE_SYSTEM_VERSION:$ {CMAKE_SYSTEM_VERSION})

    输出:

    CMAKE_SYSTEM_PROCESSOR: CMAKE_SYSTEM_VERSION:

    我的Cmake版本是 2.8.10.2 ,目标操作系统是VxWorks事情 - 编译器是WindRiver GNU)。

    如何获得我开始设置的版本和处理器?或者如果我交叉编译到cmake未知的操作系统,这是不可能的。

    (Btw。编译工作正常)解决方案

    到目前为止这看起来是不可能的。

    然而,有一个有效的解决方案,我想这是更好的方法:

    之前:

    我指定了交叉编译设置(编译器和目标系统,见问题), CMake列表中的特定部分(使用 if(VxWorks)检查以确保在使用其他系统时不会执行)。

    现在(解决方案):

    我写了一个工具链文件

    • 我必须写一些额外的文件:
      • 工具链文件
      • VxWorks的平台文件
      • 每个处理器(和处理器类型, Gnu 和 Diab )的其他平台文件

    b $ b

    • 现在,CMake列表更清晰
    • 分隔项目和目标设置
    • 单独的系统和处理器设置 - 容易以非常清晰的方式添加新的处理器,但保留系统设置
    • 我在工具链文件中写入一些设置,并且CMake加载相关的系统/处理器设置
    • ...

    I'm cross-compiling for VxWorks using cmake. When I run cmake the first time I have to provide informations about compiler, target OS etc..

    In the cross-compile dialogue there are three target system settings I set:

  • Operating System
  • Version
  • Processor
  • (followed by compiler etc.)

    While I can retrieve the first one using CMAKE_SYSTEM_NAME, i can't get the version and the processor. Both return an empty string.

    Here's an example:

    MESSAGE("CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}") MESSAGE("CMAKE_SYSTEM_VERSION: ${CMAKE_SYSTEM_VERSION}")

    Output:

    CMAKE_SYSTEM_PROCESSOR: CMAKE_SYSTEM_VERSION:

    My Cmake Version is 2.8.10.2 and target OS is VxWorks (if this matters - compiler are WindRiver GNU).

    How can I get the version and processor I've set in the beginning? Or is this impossible if I cross-compile to an OS that's unknown to cmake?

    (Btw. Compiling works fine)

    解决方案

    It seems this is not possible so far. I'm getting empty strings all the time.

    However, there's a working solution, and i guess it's the better way:

    Before:

    I specified cross-compile settings (Compiler and target system, see question), then it runs over VxWorks specific parts in the CMake list (checked with if( VxWorks ) to ensure it's not executed when other systems are used).

    Now (Solution):

    I wrote a toolchain file and platform files for VxWorks and required processors.

    Cons:

    • I have to write some extra files:
      • Toolchain file
      • Platform file for VxWorks
      • Further Platform files for each Processor (and processor type, Gnu and Diab)

    Pros:

    • CMake list is much cleaner now
    • Separate Project and Target settings
    • Separate System and processor settings - easy to add new Processors in a very clear way but keep System settings
    • I write some settings in the toolchain file and CMake loads related system / processor settings
    • ...

    更多推荐

    交叉编译

    本文发布于:2023-11-05 15:56:55,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1561264.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!