Qt6 - cmake
-
Hello,
Switching from Qt5 (qmake) to Qt6 (cmake), did a fresh install (removed Qt5).
Creating a simple command line app
Fails to accurately create a simple command line app
The issue appears to be in CMakeLists.txt
Change:
find_package(Qt5Core)
to:
find_package(Qt6Core)I have googled my eyes out and have tried about everything I can think of...why is the CMakeLists still trying to use Qt5?
Error in Qt Creator (Qt6 on mac):
Running /Users/bryancairns/Qt/Tools/CMake/CMake.app/Contents/bin/cmake -S /Users/bryancairns/Documents/code/untitled5 -B /Users/bryancairns/Documents/code/build-untitled5-Desktop_Qt_6_0_0_clang_64bit-Debug in /Users/bryancairns/Documents/code/build-untitled5-Desktop_Qt_6_0_0_clang_64bit-Debug.
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/bryancairns/Documents/code/build-untitled5-Desktop_Qt_6_0_0_clang_64bit-Debug
Elapsed time: 00:00.
Running /Users/bryancairns/Qt/Tools/CMake/CMake.app/Contents/bin/cmake -S /Users/bryancairns/Documents/code/untitled6 -B /private/var/folders/q4/tqq65c7n635cxzfqchgbb86m0000gn/T/QtCreator-ksEaMJ/qtc-cmake-yiLmvJQC -GNinja -DCMAKE_BUILD_TYPE:String=Debug -DCMAKE_CXX_COMPILER:STRING=/usr/bin/clang++ -DCMAKE_C_COMPILER:STRING=/usr/bin/clang -DCMAKE_PREFIX_PATH:STRING=/Users/bryancairns/Qt/6.0.0/clang_64 -DQT_QMAKE_EXECUTABLE:STRING=/Users/bryancairns/Qt/6.0.0/clang_64/bin/qmake -DCMAKE_PREFIX_PATH:INTERNAL=/Users/bryancairns/Qt/6.0.0/clang_64 in /private/var/folders/q4/tqq65c7n635cxzfqchgbb86m0000gn/T/QtCreator-ksEaMJ/qtc-cmake-yiLmvJQC.
-- The CXX compiler identification is AppleClang 12.0.0.12000032
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning at CMakeLists.txt:14 (find_package):
By not providing "FindQt5Core.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Qt5Core", but
CMake did not find one.Could not find a package configuration file provided by "Qt5Core" with any
of the following names:Qt5CoreConfig.cmake qt5core-config.cmake
Add the installation prefix of "Qt5Core" to CMAKE_PREFIX_PATH or set
"Qt5Core_DIR" to a directory containing one of the above files. If
"Qt5Core" provides a separate development package or SDK, be sure it has
been installed.-- Configuring done
CMake Warning (dev) in CMakeLists.txt:
AUTOGEN: No valid Qt version found for target untitled6. AUTOMOC, AUTOUIC
and AUTORCC disabled. Consider adding:find_package(Qt<QTVERSION> COMPONENTS Widgets)
to your CMakeLists.txt file.
This warning is for project developers. Use -Wno-dev to suppress it.CMake Error at CMakeLists.txt:16 (add_executable):
Target "untitled6" links to target "Qt::Core" but the target was not found.
Perhaps a find_package() call is missing for an IMPORTED target, or an
ALIAS target is missing?-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:QT_QMAKE_EXECUTABLE
CMake Generate step failed. Build files cannot be regenerated correctly.
CMake process exited with exit code 1.
Elapsed time: 00:00. -
Hi,
How did you install Qt 5 ?
How did you install Qt 6 ?
Do you have any custom software installed that makes use of Qt ? -
@SGaist Appreciate the response
Qt5 was installed using the online installer and qmake
Qt6 was installed using the online installer a cmakeThe Kit when installing Qt6 informed me i needed to upgrade cmake, I switched it to default to the cmake that came with Qt6.
Im sure there are tons of programs on the box that use Qt, Im the only person using QtCreator to build software on the box.
What ever is generating the CMakeLists.txt does not seem to detecting the version correctly.
-
Good, do you have any other Qt installed through e.g. macports or brew ?
Could you test on the command line to see if you have the same issue ? I am just wondering whether Qt Creator may have some leftover settings interfering.
-
Ok, which Qt 6 release did you install exactly ?
-
The plot thickens...
I just switched to my linux machine and name issue
find_package(Qt5Core)Mac -
I had removed Qt and did a fresh install.
Newest Qt 6.0Linux -
Have Qt 5.12. and and 15.5.0
Ran the maintenance tool, updated all existing
Reran - installed Qt 6.0
Same issues on the linux box -
@rootshell said in Qt6 - cmake:
CMakeLists.txt
Can you share your CMakeLists.txt file?
Are you sure you point to the correct source directory in the cmake command? -
I just tested using
cmake -DCMAKE_PREFIX_PATH=~/Qt/6.0.0/gcc_64/lib/cmake ..
using one of Qt's example copied in a random folder and it worked properly nothing searched from Qt 5. -
@SGaist - I am having a very similar issue. Trying to port Qt5 to Qt6. on ubuntu 22.04.
I had previously installed Qt5 packages with apt install - I removed all of those with apt remove. I installed Qt6.7.2 with the online installer into directory ~/Qt6. Now cmake find_package() succeeds when I set CMAKE_PREFIX_PATH to ~/Qt6/6.7.2/gcc_64/lib/cmake/:find_package( Qt6 COMPONENTS Gui Widgets Quick REQUIRED)
But cmake fails on the target with:
CMake Warning (dev) in src/qt-test2/CMakeLists.txt: AUTOGEN: No valid Qt version found for target qt-test. AUTOMOC, AUTOUIC and AUTORCC disabled. Consider adding: find_package(Qt5 COMPONENTS Widgets) to your CMakeLists.txt file.
What am I doing wrong?
-
-
@Christian-Ehrlicher - Not intending to hijack anything - this thread is very relevant to my current issue.