Simplify system Qt path

This commit is contained in:
Dale Glass 2021-02-16 11:46:22 +01:00
parent 1e63916940
commit ca489bd420
3 changed files with 33 additions and 39 deletions

View file

@ -101,11 +101,13 @@ include("${CMAKE_BINARY_DIR}/vcpkg.cmake")
if (HIFI_ANDROID) if (HIFI_ANDROID)
set(QT_CMAKE_PREFIX_PATH "$ENV{HIFI_ANDROID_PRECOMPILED}/qt/lib/cmake") set(QT_CMAKE_PREFIX_PATH "$ENV{HIFI_ANDROID_PRECOMPILED}/qt/lib/cmake")
else() else()
if(NOT EXISTS "${CMAKE_BINARY_DIR}/qt.cmake") if (NOT $ENV{VIRCADIA_USE_SYSTEM_QT})
message(FATAL_ERROR "qt configuration missing.") if(NOT EXISTS "${CMAKE_BINARY_DIR}/qt.cmake")
message(FATAL_ERROR "qt configuration missing.")
endif()
include("${CMAKE_BINARY_DIR}/qt.cmake")
endif() endif()
include("${CMAKE_BINARY_DIR}/qt.cmake")
endif() endif()
option(VCPKG_APPLOCAL_DEPS OFF) option(VCPKG_APPLOCAL_DEPS OFF)

View file

@ -34,6 +34,7 @@ endif()
system = platform.system() system = platform.system()
qt_found = False qt_found = False
system_qt = False
# Here we handle the 3 possible cases of dealing with Qt: # Here we handle the 3 possible cases of dealing with Qt:
if os.getenv('VIRCADIA_USE_SYSTEM_QT'): if os.getenv('VIRCADIA_USE_SYSTEM_QT'):
@ -45,25 +46,11 @@ endif()
if system != "Linux": if system != "Linux":
raise Exception("Using the system Qt is only supported on Linux") raise Exception("Using the system Qt is only supported on Linux")
cmake_paths = [ "lib64/cmake", "lib/cmake" ] self.path = None
cmake_path_ok = False self.cmakePath = None
# 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)))
qt_found = True qt_found = True
system_qt = True
print("Using system Qt") print("Using system Qt")
elif os.getenv('VIRCADIA_QT_PATH'): elif os.getenv('VIRCADIA_QT_PATH'):
@ -98,19 +85,21 @@ endif()
qt_found = os.path.isdir(self.fullPath) qt_found = os.path.isdir(self.fullPath)
print("Using a packaged Qt") 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. if not system_qt:
# Perhaps it stops multiple build processes from interferring? if qt_found:
lockDir, lockName = os.path.split(self.path) # Sanity check, ensure we have a good cmake directory
lockName += '.lock' if not os.path.isdir(os.path.join(self.cmakePath, "Qt5")):
if not os.path.isdir(lockDir): raise Exception("Failed to find Qt5 directory under " + self.cmakePath)
os.makedirs(lockDir)
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: if qt_found:
print("Found pre-built Qt5") print("Found pre-built Qt5")

View file

@ -130,23 +130,26 @@ def main():
with timer('NSIS'): with timer('NSIS'):
hifi_utils.downloadAndExtract(assets_url + '/dependencies/NSIS-hifi-plugins-1.0.tgz', "C:/Program Files (x86)") 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 android, install our Qt build
if not args.android: if not args.android:
qt = hifi_qt.QtDownloader(args) qt = hifi_qt.QtDownloader(args)
qtInstallPath = qt.cmakePath qtInstallPath = qt.cmakePath
with hifi_singleton.Singleton(qt.lockFile) as lock:
with timer('Qt'): if qtInstallPath is not None:
qt.installQt() # qtInstallPath is None when we're doing a system Qt build
qt.writeConfig() with hifi_singleton.Singleton(qt.lockFile) as lock:
with timer('Qt'):
qt.installQt()
qt.writeConfig()
pm = hifi_vcpkg.VcpkgRepo(args) pm = hifi_vcpkg.VcpkgRepo(args)
if qtInstallPath != '': if qtInstallPath is not None:
pm.writeVar('QT_CMAKE_PREFIX_PATH', qtInstallPath) pm.writeVar('QT_CMAKE_PREFIX_PATH', qtInstallPath)
# Only allow one instance of the program to run at a time # 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) pm.writeVar('QT_CMAKE_PREFIX_PATH', qtInstallPath)
# Only allow one instance of the program to run at a time # Only allow one instance of the program to run at a time