问题描述
我使用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 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: (followed by compiler etc.) While I can retrieve the first one using Here's an example: Output: 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: I specified cross-compile settings (Compiler and target system, see question), then it runs over VxWorks specific parts in the CMake list (checked with I wrote a toolchain file and platform files for VxWorks and required processors. Cons: Pros: 这篇关于交叉编译 - 检索目标CPU和版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
CMAKE_SYSTEM_NAME
, i can't get the version and the processor.Both return an empty string.MESSAGE("CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
MESSAGE("CMAKE_SYSTEM_VERSION: ${CMAKE_SYSTEM_VERSION}")
CMAKE_SYSTEM_PROCESSOR:
CMAKE_SYSTEM_VERSION:
Before:
if( VxWorks )
to ensure it's not executed when other systems are used).Now (Solution):