Compiling on Mac M1 - cmake problem
-
Hi,
I am trying to port my application to Mac. I downloaded Qt 6.3.0 through the online installer. In may make file I have the following:
set(Qt6_DIR /opt/Qt/6.3.0/macos/lib/cmake/Qt6) find_package(Qt6 REQUIRED Quick Core Gui Svg Qml Widgets QuickControls2 Test )
When running cmake I get the following problems:
CMake Warning at /opt/Qt/6.3.0/macos/lib/cmake/Qt6/Qt6Config.cmake:213 (find_package): Found package configuration file: /opt/Qt/6.3.0/macos/lib/cmake/Qt6Core/Qt6CoreConfig.cmake but it set Qt6Core_FOUND to FALSE so package "Qt6Core" is considered to be NOT FOUND. Reason given by package: Target "Qt6::Core" was not found. Call Stack (most recent call first): extern/SortFilterProxyModel/CMakeLists.txt:5 (find_package) -- Could NOT find Qt6QmlTools (missing: Qt6QmlTools_DIR) CMake Warning at /opt/Qt/6.3.0/macos/lib/cmake/Qt6/Qt6Config.cmake:213 (find_package): Found package configuration file: /opt/Qt/6.3.0/macos/lib/cmake/Qt6Qml/Qt6QmlConfig.cmake but it set Qt6Qml_FOUND to FALSE so package "Qt6Qml" is considered to be NOT FOUND. Reason given by package: Target "Qt6::Qml" was not found. Call Stack (most recent call first): extern/SortFilterProxyModel/CMakeLists.txt:5 (find_package) -- Could NOT find Qt6Core5Compat (missing: Qt6Core5Compat_DIR) CMake Error at extern/SortFilterProxyModel/CMakeLists.txt:5 (find_package): Found package configuration file: /opt/Qt/6.3.0/macos/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". Expected Config file at "/opt/Qt/6.3.0/macos/lib/cmake/Qt6Core/Qt6CoreConfig.cmake" exists Failed to find Qt component "Qml". Expected Config file at "/opt/Qt/6.3.0/macos/lib/cmake/Qt6Qml/Qt6QmlConfig.cmake" exists Failed to find Qt component "Core5Compat". Expected Config file at "/opt/Qt/6.3.0/macos/lib/cmake/Qt6Core5Compat/Qt6Core5CompatConfig.cmake" does NOT exist
What is going wrong?
-
How did you pass the Qt installation to CMake?
If you passed e.g.
/opt/Qt/6.3.0/macos/lib/cmake/Qt6
, try passing/opt/Qt/6.3.0/macos
instead. -
This did not change anything.
Regarding the last error message: The online installer allows to select Qt5 Compatibility module serperatly under 6.3.1. So under 6.3.1 this problem does not occur. However, the root of the problem seems to be
CMake Warning at /opt/Qt/6.3.0/macos/lib/cmake/Qt6/Qt6Config.cmake:213 (find_package): Found package configuration file: /opt/Qt/6.3.0/macos/lib/cmake/Qt6Core/Qt6CoreConfig.cmake but it set Qt6Core_FOUND to FALSE so package "Qt6Core" is considered to be NOT FOUND. Reason given by package: Target "Qt6::Core" was not found.
This is what I don't understand. It means it found the right Qt6CoreConfig.cmake file, but because of "Target Qt6::Core was not found" it does not want to set it to true
-
This is what I don't understand. It means it found the right Qt6CoreConfig.cmake file, but because of "Target Qt6::Core was not found" it does not want to set it to true
The exact logic Qt6 and Qt6Core interacts is a bit convoluted. You can see what exactly is going on with the
--trace
command. My best guess is that something goes wrong inQt6CoreDependencies.cmake
.Anyhow, the canonical way to set up Qt6 with CMake is not
Qt6_DIR
, but adding/opt/Qt/6.3.0/macos
toCMAKE_PREFIX_PATH
- either the environment variable, or the CMake cache variable. Does that fix your issue?