How to get cmake to go up one level after setting the Dir

Viewed 1466

I have this CLion-generated cmake text file for test, using CLion as my editor and Qt as my widget set. I got the idea here.

In my CMakeLists.txt, I have this:

cmake_minimum_required(VERSION 3.19)
project(Qt_Test)

set(CMAKE_CXX_STANDARD 20)

# Tell cmake where Qt is located
set(Qt6_DIR "/home/fmc/Qt/6.0.0/gcc_64/lib/cmake/Qt6")

# Tell cmake to find the modules Qt6Core and Qt6widgets
find_package(Qt6 COMPONENTS Core Widgets REQUIRED)

add_executable(Qt_Test main.cpp)    

My problem is that Qt installed the Core and Widgets are installed in /home/fmc/Qt/6.0.0/gcc_64/lib/cmake

With CMake as it is now, I get these errors:

CMake Error at CMakeLists.txt:10 (find_package):
  Found package configuration file:

    /home/fmc/Qt/6.0.0/gcc_64/lib/cmake/Qt6/Qt6Config.cmake

  but it set Qt6_FOUND to FALSE so package "Qt6" is considered to be NOT
  FOUND.  Reason given by package:

  Failed to find Qt component "Core" config file at ""

  Failed to find Qt component "Widgets" config file at ""

Is there a way to directly set the needed /home/fmc/Qt/6.0.0/gcc_64/lib/cmake for the components so as not to interfere with the setting of /home/fmc/Qt/6.0.0/gcc_64/lib/cmake/Qt6 ?

1 Answers

JetBrains had the correct approach to this. Problem solved.

Related