Restore default installation prefix from Qt 5

Change the default installation prefix to C:/Qt/Qt-${version} on Windows
and /usr/local/Qt-${version} elsewhere.

This is what's expected by users coming from Qt5, and setting the
installation prefix to "/usr/local" manually is easier than setting the
versioned variant "/usr/local/Qt-6.2.0".

[ChangeLog][Build System] The installation prefix now defaults to
/usr/local/Qt-${version} and C:/Qt/Qt-${version} like it did in Qt 5.

Fixes: QTBUG-91632
Pick-to: 6.2
Change-Id: I8ce57b1b18084c705b194c776e038cc807a6ed5e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Joerg Bornemann 2021-07-06 12:41:11 +02:00
parent 4afcac9b7b
commit 46d2ba1ea4

View File

@ -65,13 +65,24 @@ set(CMAKE_LINK_DEPENDS_NO_SHARED ON)
# This detection only happens when building qtbase, and later is propagated via the generated
# QtBuildInternalsExtra.cmake file.
if (PROJECT_NAME STREQUAL "QtBase" AND NOT QT_BUILD_STANDALONE_TESTS)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND FEATURE_developer_build)
# Handle non-prefix builds by setting the CMake install prefix to point to qtbase's build
# dir.
# While building another repo (like qtsvg) the CMAKE_PREFIX_PATH
# should be set on the command line to point to the qtbase build dir.
set(CMAKE_INSTALL_PREFIX ${QtBase_BINARY_DIR} CACHE PATH
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
if(FEATURE_developer_build)
# Handle non-prefix builds by setting the CMake install prefix to point to qtbase's
# build dir. While building another repo (like qtsvg) the CMAKE_PREFIX_PATH should be
# set on the command line to point to the qtbase build dir.
set(__qt_default_prefix "${QtBase_BINARY_DIR}")
else()
if(CMAKE_HOST_WIN32)
set(__qt_default_prefix "C:/Qt/")
else()
set(__qt_default_prefix "/usr/local/")
endif()
string(APPEND __qt_default_prefix
"Qt-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
endif()
set(CMAKE_INSTALL_PREFIX ${__qt_default_prefix} CACHE PATH
"Install path prefix, prepended onto install directories." FORCE)
unset(__qt_default_prefix)
endif()
if(CMAKE_CROSSCOMPILING)
set(__qt_prefix "${CMAKE_STAGING_PREFIX}")