=====================================================================================
CMakeLists.txt 链接Ubuntu下qt5的库
set(CMAKE_C_COMPILER /usr/bin/gcc)
set(CMAKE_CXX_COMPILER /usr/bin/g++)
set(DQT_QMAKE_EXECUTABL /usr/bin/qmake)
set(Qt5Core_DIR /home/xiaoguoguo/Qt5.6.3/5.6.3/gcc_64/lib/cmake/Qt5Core)
find_package(Qt5Core REQUIRED)
target_link_libraries(${PROJECT_NAME} Qt::5Core)
能生成出来Makefile,make之后成功编译。
=====================================================================================
=====================================================================================
CMakeLists.txt 链接buildroot下qt5的库
set(CMAKE_C_COMPILER /home/xiaoguoguo/arm926t/buildroot-2017.11/output/host/bin/arm-926t-linux-gnueabi-gcc)
set(CMAKE_CXX_COMPILER /home/xiaoguoguo/arm926t/buildroot-2017.11/output/host/bin/arm-926t-linux-gnueabi-g++)
set(DQT_QMAKE_EXECUTABL /home/xiaoguoguo/arm926t/buildroot-2017.11/output/host/bin/qmake)
set(Qt5Core_DIR /home/xiaoguoguo/arm926t/buildroot-2017.11/output/build/qt5base-5.9.2/lib/cmake/Qt5Core/)
find_package(Qt5Core REQUIRED)
target_link_libraries(${PROJECT_NAME} Qt5Core)
Makefile生成失败,提示内容如下
CMake Error at /home/xiaoguoguo/arm926t/buildroot-2017.11/output/build/qt5base-5.9.2/lib/cmake/Qt5Core/Qt5CoreConfig.cmake:27 (message):
The imported target "Qt5::Core" references the file
"/home/xiaoguoguo/arm926t/buildroot-2017.11/output/build/qt5base-5.9.2/include/qt5/"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/home/xiaoguoguo/arm926t/buildroot-2017.11/output/build/qt5base-5.9.2/lib/cmake/Qt5Core/Qt5CoreConfig.cmake"
but not all the files it references.
Call Stack (most recent call first):
/home/xiaoguoguo/arm926t/buildroot-2017.11/output/build/qt5base-5.9.2/lib/cmake/Qt5Core/Qt5CoreConfig.cmake:63 (_qt5_Core_check_file_exists)
CMakeLists.txt:12 (find_package)
-- Configuring incomplete, errors occurred!
=====================================================================================
Qt5CoreConfig.cmake:27 (message):
The imported target "Qt5::Core" references the file
根据这个错误提示找到Qt5CoreConfig.cmake:27
25 macro(_qt5_Core_check_file_exists file)
26 if(NOT EXISTS "${file}" )
27 message(FATAL_ERROR "The imported target \"Qt5::Core\" references the file
28 \"${file}\"
然后百度一下第27行,大多数是说该文件的
14 get_filename_component(_qt5Core_install_prefix "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
这一句有问题。
Qt5CoreConfig.cmake从编译完buildroot就没有更改过,该怎么更正呢?
离线
用 qt 的 pro.格式工程不香吗?
有个工程就是cmake个工程,工程好多文件,要把他的工程转成.pro太麻烦了
离线