From ef2be82c21b0934522ad8e110805b66f5948da1f Mon Sep 17 00:00:00 2001 From: xiphon Date: Tue, 10 Nov 2020 00:05:15 +0000 Subject: [PATCH] cmake: use QT_INSTALL_PREFIX instead of CMAKE_PREFIX_PATH --- CMakeLists.txt | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9edb9c6b..974718bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -229,11 +229,6 @@ if(UNIX) execute_process(COMMAND brew --prefix qt5 OUTPUT_VARIABLE QT5_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) list(APPEND CMAKE_PREFIX_PATH ${QT5_DIR}) endif() - - if(CMAKE_PREFIX_PATH) - include_directories(${CMAKE_PREFIX_PATH}/include) - set(CMAKE_BUILD_RPATH "${CMAKE_PREFIX_PATH}/lib") - endif() endif() find_package(PkgConfig REQUIRED) @@ -265,6 +260,13 @@ else() pkg_check_modules(QT5_PKG_CONFIG REQUIRED ${QT5_LIBRARIES_ABI}) endif() +get_target_property(QMAKE_IMPORTED_LOCATION Qt5::qmake IMPORTED_LOCATION) +get_filename_component(QT_INSTALL_PREFIX "${QMAKE_IMPORTED_LOCATION}/../.." ABSOLUTE) + +if(APPLE AND NOT STATIC) + set(CMAKE_BUILD_RPATH "${QT_INSTALL_PREFIX}/lib") +endif() + if(QT5_PKG_CONFIG_FOUND) set(QT5_PKG_CONFIG "QT5_PKG_CONFIG") if(STATIC) @@ -276,10 +278,10 @@ if(QT5_PKG_CONFIG_FOUND) list(JOIN ${QT5_PKG_CONFIG}_LDFLAGS_OTHER " " ${QT5_PKG_CONFIG}_LDFLAGS_OTHER) endif() # temporal workaround for https://bugreports.qt.io/browse/QTBUG-80922 - STRING(REPLACE "${QT5_PKG_CONFIG_Qt5Core_PREFIX}" "${CMAKE_PREFIX_PATH}" ${QT5_PKG_CONFIG}_LDFLAGS_OTHER "${${QT5_PKG_CONFIG}_LDFLAGS_OTHER}") - STRING(REPLACE "${QT5_PKG_CONFIG_Qt5Core_PREFIX}" "${CMAKE_PREFIX_PATH}" ${QT5_PKG_CONFIG}_LIBRARIES "${${QT5_PKG_CONFIG}_LIBRARIES}") - STRING(REPLACE "${QT5_PKG_CONFIG_Qt5Core_PREFIX}" "${CMAKE_PREFIX_PATH}" ${QT5_PKG_CONFIG}_INCLUDE_DIRS "${${QT5_PKG_CONFIG}_INCLUDE_DIRS}") - STRING(REPLACE "${QT5_PKG_CONFIG_Qt5Core_PREFIX}" "${CMAKE_PREFIX_PATH}" ${QT5_PKG_CONFIG}_LIBRARY_DIRS "${${QT5_PKG_CONFIG}_LIBRARY_DIRS}") + STRING(REPLACE "${QT5_PKG_CONFIG_Qt5Core_PREFIX}" "${QT_INSTALL_PREFIX}" ${QT5_PKG_CONFIG}_LDFLAGS_OTHER "${${QT5_PKG_CONFIG}_LDFLAGS_OTHER}") + STRING(REPLACE "${QT5_PKG_CONFIG_Qt5Core_PREFIX}" "${QT_INSTALL_PREFIX}" ${QT5_PKG_CONFIG}_LIBRARIES "${${QT5_PKG_CONFIG}_LIBRARIES}") + STRING(REPLACE "${QT5_PKG_CONFIG_Qt5Core_PREFIX}" "${QT_INSTALL_PREFIX}" ${QT5_PKG_CONFIG}_INCLUDE_DIRS "${${QT5_PKG_CONFIG}_INCLUDE_DIRS}") + STRING(REPLACE "${QT5_PKG_CONFIG_Qt5Core_PREFIX}" "${QT_INSTALL_PREFIX}" ${QT5_PKG_CONFIG}_LIBRARY_DIRS "${${QT5_PKG_CONFIG}_LIBRARY_DIRS}") endif() set(QT5_LIBRARIES ${${QT5_PKG_CONFIG}_LIBRARIES} ${${QT5_PKG_CONFIG}_LDFLAGS_OTHER})