Skip to content

Commit bb2c08c

Browse files
committed
CMake: fix Qt5 find in MacOS
1 parent 81f072b commit bb2c08c

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

CMakeLists.txt

+8-20
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,15 @@ if (BUILD_GSTREAMER_PLUGIN)
4343
find_package (Qt4)
4444
include (${QT_USE_FILE})
4545
else()
46-
if (APPLE)
47-
# We need to find the path of the Qt libs and cmake config installed by brew,
48-
# e.g. /usr/local/Cellar/qt/5.13.1/lib/cmake/Qt5Core
49-
execute_process(COMMAND /usr/local/opt/qt/bin/qtpaths --install-prefix
50-
OUTPUT_VARIABLE qt_install_path
51-
OUTPUT_STRIP_TRAILING_WHITESPACE)
52-
message(STATUS "QT install path: ${qt_install_path}")
53-
find_package(Qt5Core
54-
CONFIG
55-
PATHS "${qt_install_path}/lib/cmake/Qt5Core"
56-
NO_DEFAULT_PATH
57-
REQUIRED)
58-
find_package(Qt5Widgets
59-
CONFIG
60-
PATHS ${qt_install_path}/lib/cmake/Qt5Widgets
61-
NO_DEFAULT_PATH
62-
REQUIRED)
63-
else()
64-
find_package(Qt5Core REQUIRED)
65-
find_package(Qt5Widgets REQUIRED)
46+
# In order to find Qt5 in macOS, the Qt5 path needs to be added to the CMake prefix path.
47+
if(APPLE)
48+
execute_process(COMMAND brew --prefix qt5
49+
ERROR_QUIET
50+
OUTPUT_VARIABLE QT5_PREFIX_PATH
51+
)
52+
list(APPEND CMAKE_PREFIX_PATH "${QT5_PREFIX_PATH}")
6653
endif()
54+
find_package(Qt5 COMPONENTS Core Widgets REQUIRED)
6755
endif()
6856
endif()
6957
endif()

0 commit comments

Comments
 (0)