mysql交叉编译 cmake_在交叉编译中CMake CMAKE_AUTOMOC(CMake CMAKE_AUTOMOC in cross compilation)...

在尝试使用CMake进行mysql交叉编译时,遇到CMAKE_AUTOMOC设置为ON但仍然使用目标系统moc的问题。尽管设置了CMAKE_FIND_ROOT_PATH_MODE_PROGRAM为NEVER,期望使用主机系统的moc,但实际CMake仍从目标系统根文件系统寻找moc。尝试修改QT_MOC_EXECUTABLE变量也未成功。生成的AutogenInfo.cmake文件中的AM_QT_MOC_EXECUTABLE变量指向错误路径。编辑后发现,即使手动修正该变量,文件仍生成错误路径。
摘要由CSDN通过智能技术生成

I've following issue. I'm tring to use native mechanism build in CMake for cross compilation. I prepared following toolchain.cmake file:

set(CMAKE_SYSTEM_NAME Linux)

set(CMAKE_SYSTEM_PROCESSOR arm)

set(CMAKE_SYSROOT /tmp/filesystem)

set(tools /opt/gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux/bin/arm-linux-gnueabihf)

set(CMAKE_C_COMPILER ${tools}-gcc)

set(CMAKE_CXX_COMPILER ${tools}-g++)

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)

and in target CMakeList.txt is use:

set(CMAKE_AUTOMOC ON)

I expect that when I use CMAKE_FIND_ROOT_PATH_MODE_PROGRAM set to NEVER the CMake, according to documentation, will use moc from HOST:

If set to NEVER, then the roots in CMAKE_FIND_ROOT_PATH will be ignored and only the host system root will be used.

However it still try to use moc from TARGET arm image rootfs.

I try to refind the moc executable like in first answer from this post: How to include a certain Qt installation using CMake? but with no luck.

I also try to set the QT_MOC_EXECUTABLE variable to proper path from HOST rootfs instead of TARGET one but also with no luck there. I event think that this variable isn't use by CMake when CMAKE_AUTOMOC is set to ON since after forcing change this cached variable cmake still use moc from TARGET rootfs.

Any ideas how to resolve this issue?

# EDIT 1

I found that the automoc generates such file in build folder:

CMakeFiles/*target_name*_automoc.dir/AutogenInfo.cmake

And in my case such variable is set to wrong path:

set(AM_QT_MOC_EXECUTABLE "/tmp/filesystem/usr/lib/arm-linux-gnueabihf/qt5/bin/moc")

should be:

set(AM_QT_MOC_EXECUTABLE "/usr/bin/moc")

I set AM_QT_MOC_EXECUTABLE to correct value in main CMakeList.txt but still after mentioned file is generated with wrong path from TARGET rootfs.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值