Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. CMake error with msvc in CLion

CMake error with msvc in CLion

Scheduled Pinned Locked Moved Solved Qt 6
11 Posts 4 Posters 6.9k 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.
  • A Offline
    A Offline
    akshaybabloo
    wrote on 20 Dec 2020, 21:34 last edited by
    #1

    I am trying to run cmake on CLion and I get the following error

    CMake Error at CMakeLists.txt:36 (find_package):
      Could not find a configuration file for package "QT" that is compatible
      with requested version "".
    
      The following configuration files were considered but not accepted:
    
        C:/Qt/6.0.0/msvc2019_64/lib/cmake/Qt6/Qt6Config.cmake, version: 6.0.0 (64bit)
    
    

    This is working fine on macOS though. I tried setting QT_DIR and Qt6_DIR but I still get that same error.

    CMakeList.txt:

    cmake_minimum_required(VERSION 3.5)

set(VERSION 0.0.1)

project(CSVExplorer VERSION ${VERSION} LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if ($ENV{CLION_IDE})
    set(QT_VERSION_MAJOR 6)

    if (APPLE)
        set(CMAKE_PREFIX_PATH $ENV{HOME}/Qt/6.0.0/clang_64)
    elseif (WIN32)
        set(CMAKE_PREFIX_PATH C:\\Qt\\6.0.0\\msvc2019_64)
        #        set(QT_DIR C:\\Qt\\6.0.0\\msvc2019_64\\lib\\cmake\\Qt6)
        #        set(Qt6_DIR C:\\Qt\\6.0.0\\msvc2019_64\\lib\\cmake\\Qt6)
    endif ()
endif ()

if (APPLE)
    set(MACOSX_BUNDLE_ICON_FILE csvexplorer.icns)
    # And the following tells CMake where to find and install the file itself.
    set(app_icon_macos "resources/images/csvexplorer.icns")
    set_source_files_properties(${app_icon_macos} PROPERTIES
            MACOSX_PACKAGE_LOCATION "Resources")
endif ()

find_package(QT NAMES Qt6 COMPONENTS Widgets REQUIRED)
find_package(QT NAMES Qt6 COMPONENTS Sql REQUIRED)
find_package(QT NAMES Qt6 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Sql REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)

add_executable(CSVExplorer
        MACOSX_BUNDLE
        main.cpp
        welsomescreen.cpp welsomescreen.h welcomescreen.ui

        aboutwindow.cpp aboutwindow.h aboutwindow.ui

        resources.qrc style.qrc migrations.qrc
        ${app_icon_macos}
        file.cpp file.h)


target_link_libraries(CSVExplorer
        PRIVATE
        Qt${QT_VERSION_MAJOR}::Widgets
        Qt${QT_VERSION_MAJOR}::Sql
        Qt${QT_VERSION_MAJOR}::Core)

    
    1 Reply Last reply
    0
    • A akshaybabloo
      17 Jan 2021, 03:23

      @zhangyiant How would you change that?

      Z Offline
      Z Offline
      zhangyiant
      wrote on 19 Jan 2021, 07:00 last edited by
      #10

      @akshaybabloo File->Settings->Build,Execution,Deployment->Toolchains

      Select "Visual Studio", and you can see “Architecture" configuration.

      My CLion is version 2020.3.1.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 21 Dec 2020, 19:50 last edited by
        #2

        Hi,

        Your CMAKE_PREFIX_PATH should point to the "Qt/6.0.0/clang_64/lib/cmake" subdir.

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

        A 1 Reply Last reply 21 Dec 2020, 19:51
        1
        • S SGaist
          21 Dec 2020, 19:50

          Hi,

          Your CMAKE_PREFIX_PATH should point to the "Qt/6.0.0/clang_64/lib/cmake" subdir.

          A Offline
          A Offline
          akshaybabloo
          wrote on 21 Dec 2020, 19:51 last edited by
          #3

          @SGaist Apple is working fine actually. It's the MSVC part that is not working

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 21 Dec 2020, 20:04 last edited by
            #4

            What do you get if you use a simple:

            find_package(Qt6 COMPONENTS Widgets)
            

            ?

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

            A 1 Reply Last reply 21 Dec 2020, 20:16
            0
            • S SGaist
              21 Dec 2020, 20:04

              What do you get if you use a simple:

              find_package(Qt6 COMPONENTS Widgets)
              

              ?

              A Offline
              A Offline
              akshaybabloo
              wrote on 21 Dec 2020, 20:16 last edited by
              #5

              @SGaist Tried it. Still same error

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 21 Dec 2020, 20:27 last edited by
                #6

                Does it work with Qt Creator ?

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

                A 1 Reply Last reply 17 Jan 2021, 03:25
                0
                • Z Offline
                  Z Offline
                  zhangyiant
                  wrote on 14 Jan 2021, 08:25 last edited by
                  #7

                  I found CLion by default uses x86 as the Architecture for VS in the toolchains setting.

                  I changed it to amd64, it works on my machine.

                  You can try it.

                  A R 2 Replies Last reply 17 Jan 2021, 03:23
                  6
                  • Z zhangyiant
                    14 Jan 2021, 08:25

                    I found CLion by default uses x86 as the Architecture for VS in the toolchains setting.

                    I changed it to amd64, it works on my machine.

                    You can try it.

                    A Offline
                    A Offline
                    akshaybabloo
                    wrote on 17 Jan 2021, 03:23 last edited by
                    #8

                    @zhangyiant How would you change that?

                    Z 1 Reply Last reply 19 Jan 2021, 07:00
                    0
                    • S SGaist
                      21 Dec 2020, 20:27

                      Does it work with Qt Creator ?

                      A Offline
                      A Offline
                      akshaybabloo
                      wrote on 17 Jan 2021, 03:25 last edited by
                      #9

                      @SGaist Yes, it did

                      1 Reply Last reply
                      0
                      • A akshaybabloo
                        17 Jan 2021, 03:23

                        @zhangyiant How would you change that?

                        Z Offline
                        Z Offline
                        zhangyiant
                        wrote on 19 Jan 2021, 07:00 last edited by
                        #10

                        @akshaybabloo File->Settings->Build,Execution,Deployment->Toolchains

                        Select "Visual Studio", and you can see “Architecture" configuration.

                        My CLion is version 2020.3.1.

                        1 Reply Last reply
                        0
                        • Z zhangyiant
                          14 Jan 2021, 08:25

                          I found CLion by default uses x86 as the Architecture for VS in the toolchains setting.

                          I changed it to amd64, it works on my machine.

                          You can try it.

                          R Offline
                          R Offline
                          ruddy
                          wrote on 23 Jan 2021, 06:18 last edited by
                          #11

                          @zhangyiant Thank you very much, I had such a problem too, it worked for me too.

                          1 Reply Last reply
                          1
                          • X xiaoyifang referenced this topic on 20 Mar 2023, 13:26

                          • Login

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