Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Build Qt project with CMake problem
Qt 6.11 is out! See what's new in the release blog

Build Qt project with CMake problem

Scheduled Pinned Locked Moved Qt Creator and other tools
2 Posts 2 Posters 3.8k Views 2 Watching
  • 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.
  • A Offline
    A Offline
    amigo421
    wrote on last edited by A Former User
    #1

    this is a copy of the question on stackoverflow here

    here is a doc about that, but it doesn't look correct for me ,
    so I've copied cmake instructions into my cmakelists.txt and it doesn't work.
    it's clear why it doesn't work - because there is no one instruction how to search qt:

    I suppose two cases:

    • some additional cmake instructions requires to set
    • some environment variables should be set

    but nothing about that.

    the instruction :

    find_package(Qt5Widgets)
    

    refers to extra cmake script from qt kit , isn't it?
    I see the directory with that name (annd contains *.cmake scripts but another names) but there is no the script with this name

    these are the only .cmake files with qt in names in cmake 3.6 :

    cmake-3.6\Modules\DeployQt4.cmake
    cmake-3.6\Modules\FindosgQt.cmake
    cmake-3.6\Modules\FindQt.cmake
    cmake-3.6\Modules\FindQt3.cmake
    cmake-3.6\Modules\FindQt4.cmake
    cmake-3.6\Modules\Qt4ConfigDependentSettings.cmake
    cmake-3.6\Modules\Qt4Macros.cmake
    cmake-3.6\Modules\UseQt4.cmake
    

    ===================

    C:\dev\tools\CLion.RC\bin\cmake\bin\cmake.exe -DCMAKE_BUILD_TYPE=Debug
    -G "CodeBlocks - MinGW Makefiles" C:\dev\workspace\algolist.v2 CMake Warning at CMakeLists.txt:14 (find_package): By not providing
    "FindQt5Widgets.cmake" in CMAKE_MODULE_PATH this project has asked
    CMake to find a package configuration file provided by "Qt5Widgets",
    but CMake did not find one.

    Could not find a package configuration file provided by "Qt5Widgets"
    with any of the following names:

    Qt5WidgetsConfig.cmake
    qt5widgets-config.cmake
    

    Add the installation prefix of "Qt5Widgets" to CMAKE_PREFIX_PATH or
    set "Qt5Widgets_DIR" to a directory containing one of the above
    files. If "Qt5Widgets" provides a separate development package or
    SDK, be sure it has been installed.

    CMake Error at CMakeLists.txt:20 (target_link_libraries): Cannot
    specify link libraries for target "helloworld" which is not built by
    this project.

    -- Configuring incomplete, errors occurred! See also "C:/dev/workspace/algolist.v2/cmake-build-debug/CMakeFiles/CMakeOutput.log".

    seems it found Qt5Widgets, but absolutely not clear how it does this...
    so it looks for cmake files inside Qt5Widgets folder, in Qt kit.
    I can add this folder to the path but I don't think this is a valid way,
    because there is a lot of subfolders with cmake files


    Qt5.8 beta, built with MinGW, Win10, cmake 3.6

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You need to use CMAKE_PREFIX_PATH

      For example:

      cmake.exe -DCMAKE_PREFIX_PATH="C:/path/to/Qt/5.X/compiler/lib/cmake"
      

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

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