Solved using QSerialPort with CMake
-
Hi,
I am new to Qt and have created my first project using Qt Creator which works just fine, now I would like to take my project outside of Qt Creator and use CMake in the building process. I have successfully build a 'hello world' and simple GUI example but I am getting stuck on my own project since it uses the QSerialPort library which CMake can't seem to find.
My CMakeList.txt
cmake_minimum_required(VERSION 3.5) project (Qt_cmake_test) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) find_package(Qt5 CONFIG REQUIRED Core Widgets Gui PrintSupport SerialPort) set(project_src mainwindow.ui mainwindow.cpp qcustomplot.cpp serial.cpp main.cpp ) add_executable(${PROJECT_NAME} ${project_src}) target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Gui Qt5::Widgets Qt5::PrintSupport Qt5::SerialPort )
when running CMake this produces the following output
CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Qt5/Qt5Config.cmake:28 (find_package): Could not find a package configuration file provided by "Qt5SerialPort" with any of the following names: Qt5SerialPortConfig.cmake qt5serialport-config.cmake Add the installation prefix of "Qt5SerialPort" to CMAKE_PREFIX_PATH or set "Qt5SerialPort_DIR" to a directory containing one of the above files. If "Qt5SerialPort" provides a separate development package or SDK, be sure it has been installed. Call Stack (most recent call first): CMakeLists.txt:8 (find_package) -- Configuring incomplete, errors occurred! See also "/home/willem/Desktop/Qt-serialPlot_cmake/build/CMakeFiles/CMakeOutput.log".
I've already tries to export the path as prompted but this only seems to create a different problem (compatibility issue with /usr/lib/x86_65-linux-gnu/ files). To me the issue seems that CMake cant find QSerialPlot since the support for it lacks in /usr/lib/x86_65-linux-gnu/
Do any of you have any experience with this? or experience on how to convert the library to use with CMake?
-
@willem_vdk this is on Linux, right?
How did you install Qt? Did you install QtSerialPort?
-
Hi @aha_1980 Yes this is on linux (Ubuntu 18.04) I installed QSerialPort through the installation of Qt Creator using the run installer (downloaded from https://www.qt.io/download). QSerialPort seems to work fine when building and running my project from Qt Creator.
-
Aha i solved it thanks to @aha_1980 hint
I needed to install the 'libqt5serialport5-dev' package
Thanks!