From ca489bd4208e4a2d44b9f1d2624304b43f371c0a Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Tue, 16 Feb 2021 11:46:22 +0100 Subject: [PATCH] Simplify system Qt path --- CMakeLists.txt | 10 ++++++---- hifi_qt.py | 45 +++++++++++++++++---------------------------- prebuild.py | 17 ++++++++++------- 3 files changed, 33 insertions(+), 39 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5993ab8764..cf82dfdfc6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,11 +101,13 @@ include("${CMAKE_BINARY_DIR}/vcpkg.cmake") if (HIFI_ANDROID) set(QT_CMAKE_PREFIX_PATH "$ENV{HIFI_ANDROID_PRECOMPILED}/qt/lib/cmake") -else() - if(NOT EXISTS "${CMAKE_BINARY_DIR}/qt.cmake") - message(FATAL_ERROR "qt configuration missing.") +else() + if (NOT $ENV{VIRCADIA_USE_SYSTEM_QT}) + if(NOT EXISTS "${CMAKE_BINARY_DIR}/qt.cmake") + message(FATAL_ERROR "qt configuration missing.") + endif() + include("${CMAKE_BINARY_DIR}/qt.cmake") endif() - include("${CMAKE_BINARY_DIR}/qt.cmake") endif() option(VCPKG_APPLOCAL_DEPS OFF) diff --git a/hifi_qt.py b/hifi_qt.py index dbff6319ff..d11988ed2e 100644 --- a/hifi_qt.py +++ b/hifi_qt.py @@ -34,6 +34,7 @@ endif() system = platform.system() qt_found = False + system_qt = False # Here we handle the 3 possible cases of dealing with Qt: if os.getenv('VIRCADIA_USE_SYSTEM_QT'): @@ -45,25 +46,11 @@ endif() if system != "Linux": raise Exception("Using the system Qt is only supported on Linux") - cmake_paths = [ "lib64/cmake", "lib/cmake" ] - cmake_path_ok = False - - # This makes the lockFile stuff happy. Needs to be writable. - self.path = tempfile.mkdtemp() - - self.fullPath = '/usr' - - # Find the cmake directory - for cp in cmake_paths: - self.cmakePath = os.path.join(self.fullPath, cp) - if os.path.isdir(self.cmakePath): - cmake_path_ok = True - break - - if not cmake_path_ok: - raise Exception("Failed to find cmake directory. Looked under " + self.fullPath + " in " + (', '.join(cmake_paths))) + self.path = None + self.cmakePath = None qt_found = True + system_qt = True print("Using system Qt") elif os.getenv('VIRCADIA_QT_PATH'): @@ -98,19 +85,21 @@ endif() qt_found = os.path.isdir(self.fullPath) print("Using a packaged Qt") - if qt_found: - # Sanity check, ensure we have a good cmake directory - if not os.path.isdir(os.path.join(self.cmakePath, "Qt5")): - raise Exception("Failed to find Qt5 directory under " + self.cmakePath) - # I'm not sure why this is needed. It's used by hifi_singleton. - # Perhaps it stops multiple build processes from interferring? - lockDir, lockName = os.path.split(self.path) - lockName += '.lock' - if not os.path.isdir(lockDir): - os.makedirs(lockDir) + if not system_qt: + if qt_found: + # Sanity check, ensure we have a good cmake directory + if not os.path.isdir(os.path.join(self.cmakePath, "Qt5")): + raise Exception("Failed to find Qt5 directory under " + self.cmakePath) - self.lockFile = os.path.join(lockDir, lockName) + # I'm not sure why this is needed. It's used by hifi_singleton. + # Perhaps it stops multiple build processes from interferring? + lockDir, lockName = os.path.split(self.path) + lockName += '.lock' + if not os.path.isdir(lockDir): + os.makedirs(lockDir) + + self.lockFile = os.path.join(lockDir, lockName) if qt_found: print("Found pre-built Qt5") diff --git a/prebuild.py b/prebuild.py index d5bed2d813..47ec01f8cc 100644 --- a/prebuild.py +++ b/prebuild.py @@ -130,23 +130,26 @@ def main(): with timer('NSIS'): hifi_utils.downloadAndExtract(assets_url + '/dependencies/NSIS-hifi-plugins-1.0.tgz', "C:/Program Files (x86)") - qtInstallPath = '' + qtInstallPath = None # If not android, install our Qt build if not args.android: qt = hifi_qt.QtDownloader(args) qtInstallPath = qt.cmakePath - with hifi_singleton.Singleton(qt.lockFile) as lock: - with timer('Qt'): - qt.installQt() - qt.writeConfig() + + if qtInstallPath is not None: + # qtInstallPath is None when we're doing a system Qt build + with hifi_singleton.Singleton(qt.lockFile) as lock: + with timer('Qt'): + qt.installQt() + qt.writeConfig() pm = hifi_vcpkg.VcpkgRepo(args) - if qtInstallPath != '': + if qtInstallPath is not None: pm.writeVar('QT_CMAKE_PREFIX_PATH', qtInstallPath) # Only allow one instance of the program to run at a time - if qtInstallPath != '': + if qtInstallPath is not None: pm.writeVar('QT_CMAKE_PREFIX_PATH', qtInstallPath) # Only allow one instance of the program to run at a time