Qt5 CMake cross compile
cmake_minimum_required(VERSION 2.8) if (${ARM}) set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_PROCESSOR arm) set(CMAKE_STAGING_PREFIX $ENV{HOME}/dev/kndos/rootfs) set(CMAKE_SYSROOT ${CMAKE_STAGING_PREFIX}) set(CMAKE_FIND_ROOT_PATH /usr/lib/arm-linux-gnueabihf ${CMAKE_STAGING_PREFIX}) set(CMAKE_LIBRARY_ARCHITECTURE arm-linux-gnueabihf) set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc) set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) endif () project(tqml) set(CMAKE_CXX_STANDARD 14) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) find_package(Qt5 COMPONENTS Widgets Qml Quick REQUIRED) if (${CMAKE_CROSSCOMPILING}) set(HOST_QT_BIN /usr/lib/x86_64-linux-gnu/qt5/bin) set_target_properties(Qt5::uic PROPERTIES IMPORTED_LOCATION ${HOST_QT_BIN}/uic) set_target_properties(Qt5::moc PROPERTIES IMPORTED_LOCATION ${HOST_QT_BIN}/moc) set_target_properties(Qt5::rcc PROPERTIES IMPORTED_LOCATION ${HOST_QT_BIN}/rcc) endif () add_executable(${PROJECT_NAME} main.cpp main.qml main.qrc) target_link_libraries(${PROJECT_NAME} Qt5::Widgets Qt5::Qml Qt5::Quick)
其实只需要注意一个问题即可,其他的都有上位机相同,CMAKE_FIND_ROOT_PATH_MODE_PROGRAM虽然设置成了NEVER,但是并不会改变Qt5::uic/moc/rcc的查找方式,需要覆盖下,使用上位机的uic/moc/rcc
注:我的rootfs就是使用debian-bootstrap构造的rootfs
------------------------------------------------------------
本文由WindTaiL在cnblogs中发布,转载请注明出处
本文由WindTaiL在cnblogs中发布,转载请注明出处