Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. using QSerialPort with CMake
Forum Updated to NodeBB v4.3 + New Features

using QSerialPort with CMake

Scheduled Pinned Locked Moved Solved Installation and Deployment
4 Posts 2 Posters 10.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    willem_vdk
    wrote on last edited by
    #1

    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?

    aha_1980A 1 Reply Last reply
    0
    • W willem_vdk

      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?

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @willem_vdk this is on Linux, right?

      How did you install Qt? Did you install QtSerialPort?

      Qt has to stay free or it will die.

      W 1 Reply Last reply
      0
      • aha_1980A aha_1980

        @willem_vdk this is on Linux, right?

        How did you install Qt? Did you install QtSerialPort?

        W Offline
        W Offline
        willem_vdk
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • W Offline
          W Offline
          willem_vdk
          wrote on last edited by
          #4

          Aha i solved it thanks to @aha_1980 hint
          I needed to install the 'libqt5serialport5-dev' package
          Thanks!

          1 Reply Last reply
          2

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved