Install Qt5.10.1 from Qt website cannot use cmake



  • I had a question regarding the latest Qt download (open source).
    I am running Ubuntu 14.04 64bit and downloaded the Qt5.10.1 installer from Qt for Linux. I installed Qt5.10.1 and tools in /opt/Qt. I was able to compile and run the Qt helloworld program from QtCreator. However, I would like to setup the Qt5.10.1 on CLion with CMake. Unfortunately, CMake within CLion is unable to find the new Qt5.10.1 installation. I believe that the problem is that my installation of Qt5.10.1 from the Qt installer (on the Qt website download) did not include the CMake configuration files such as, Qt5WidgetsConfig.cmake, which I have only for my old Qt5 versions and consequently, cmake cannot build my CLion projects with Qt5.10.1.
    Could anyone kindly guide me as how to get cmake to find and work with my Qt5.10.1 installation? I'm sure I'm missing something obvious but I have not been able to find the answer. Do I need to compile and install Qt5.10.1 from source to obtain the xxxConfig.cmake files?
    Thanks!
    Phil


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    From the command line it would be something like:

    mkdir build
    pushd build
    cmake -DCMAKE_PREFIX_PATH=/Path/to/Qt/version/compiler/lib/cmake/ /path/to/cmake_project/
    cmake build
    popd
    

    I don't know CLion, but I'm guessing that you should be able to pass additional parameters to cmake when using it.

    Hope it helps



  • PLEASE DISREGARD my post here. Sorry to waste your time but I just found the solution. I just needed to upgrade my cmake to 3.x.
    Thanks much,
    Phil


  • Lifetime Qt Champion

    Thanks for sharing your findings !

    Since you have it working now, please mark the thread as solved using the "Topic Tool" button so that other forum users may know a solution has been found :)



  • As I said previously, Please make sure you have a new version of cmake to keep from running into build problems!
    And I needed to direct cmake in CLion to the proper directories to search for the Qt5.10.1 package as well as specifying the 5.10.1 package to avoid catching the old Qt5.2 package I also have as my system Qt. My cmake file is below:
    ####################################
    cmake_minimum_required(VERSION 3.10)
    project(sql)

    set(CMAKE_CXX_STANDARD 17)
    set(CMAKE_PREFIX_PATH /opt/Qt/5.10.1/gcc_64/lib/cmake)

    change /opt/Qt/5.10.1/gcc_64/lib/cmake to your installation directory for cmake config files for your Qt installation

    set(CMAKE_AUTOMOC ON)

    find_package( Qt5Core 5.10.1 REQUIRED )

    be sure to include the 5.x (5.10.1 in my case) version number so you build using the intended Qt version!

    find_package(Qt5Widgets 5.10.1 REQUIRED)
    find_package( Qt5Gui 5.10.1 REQUIRED )
    find_package( Qt5Sql 5.10.1 REQUIRED )

    make sure you do find_package on ALL the Qt modules you'll need for your particular build

    add_executable(sql main.cpp sqlsetup.h)
    target_link_libraries(sql Qt5::Widgets Qt5::Gui Qt5::Core Qt5::Sql)
    ####################################

    Hope this helps anyone else who ran into this!
    Thanks,
    Phil


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.