使用cmake构建QTCharts [英] building QTCharts by using cmake

查看:832
本文介绍了使用cmake构建QTCharts的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在研究在Linux平台上使用Qt5Charts的项目。默认情况下,系统中存在qt5.5。我已经在主目录中安装了qt5.8。



要使用cmake构建项目,请执行以下操作。我的Cmakefile看起来像这样

  find_package(Qt5Widgets)
set(CMAKE_AUTOMOC ON)
if(Qt5Widgets_FOUND )
设置(QT_INCLUDE_DIR
$ {Qt5Widgets_INCLUDE_DIRS}

include_directories($ {QT_INCLUDE_DIR})
设置(LIBS $ {LIBS} $ {Qt5Widgets_LIBRARIES}) $ b endif()

find_package(Qt5Charts)
if(Qt5Charts_FOUND)
set(QT_INCLUDE_DIR
$ {Qt5Charts_INCLUDE_DIRS}

include_directories ($ {QT_INCLUDE_DIR})
set(LIBS $ {LIBS} $ {Qt5Charts_LIBRARIES})
endif()

但是cmake无法找到Qt5Charts,因为它仅在Qt5.8中可用。已成功找到Qt5Widgets,因为它在Qt5.5中也可用。



对于Qt5Charts它说


找不到由提供的软件包配置文件具有以下任何名称的
的 Qt5Charts:Qt5ChartsConfig.cmake
qt5charts-config.cmake


是有没有一种方法让我告诉cmake寻找Qt5.8而不是Qt5.5的软件包?还是可以指定要查找的默认路径?


Qt / 5.8 / gcc_64 / lib / cmake是cmakeFiles的位置对于5.8
/ usr / lib / x86_64-linux-gnu / cmake for 5.5



解决方案

如果您使用 apt-get yum dnf安装了Qt 或任何其他软件包管理器,则需要分别安装图表。我在Qt 5.8的Fedora中也遇到了同样的情况。安装 qt5-qtcharts-devel 解决了此问题。

  sudo dnf对于基于Debian的发行版和其他发行版,安装qt5-qtcharts-devel 

软件包名称可能不同。 / p>

但是在我的Mac中,我使用 brew 安装了qt5,在那里安装了包括图表在内的所有内容


I'm currently working on a project where Qt5Charts is used in a linux platform. By default there was qt5.5 in the system. I have installed qt5.8 in my home directory.

To build the project I'm using cmake. My Cmakefile looks something like this

find_package(Qt5Widgets)
set(CMAKE_AUTOMOC ON)
    if(Qt5Widgets_FOUND)
        set( QT_INCLUDE_DIR
            ${Qt5Widgets_INCLUDE_DIRS}
        )
        include_directories( ${QT_INCLUDE_DIR} )
        set (LIBS ${LIBS} ${Qt5Widgets_LIBRARIES} )
    endif()

find_package(Qt5Charts)
    if(Qt5Charts_FOUND)
        set( QT_INCLUDE_DIR
            ${Qt5Charts_INCLUDE_DIRS}
        )
        include_directories( ${QT_INCLUDE_DIR} )
        set (LIBS ${LIBS} ${Qt5Charts_LIBRARIES} )
    endif() 

But the cmake is not been able to find Qt5Charts as it is only available in Qt5.8. The Qt5Widgets is successfully found as it is available in Qt5.5 also.

For Qt5Charts it says

Could not find a package configuration file provided by "Qt5Charts" with any of the following names: Qt5ChartsConfig.cmake qt5charts-config.cmake

Is there a way that I tell cmake to look for packages of Qt5.8 instead of Qt5.5? Or is there a way to specify the default path to look for?

Qt/5.8/gcc_64/lib/cmake is the location of cmakeFiles for 5.8 /usr/lib/x86_64-linux-gnu/cmake for 5.5

解决方案

If you have installed Qt with apt-get or yum or dnf or any other package manager, you need to install Charts separately. I was experiencing the same in Fedora with Qt 5.8. Installation of qt5-qtcharts-devel solved the issue.

sudo dnf install qt5-qtcharts-devel

for debian based distributions and other distributions the package name may be different.

However In my Mac I've installed qt5 using brew there it installed everything including charts.

这篇关于使用cmake构建QTCharts的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆