CMake: An -extprefix -developer-build should install by default

Previously if
 -extprefix /tmp/sysroot (CMAKE_STAGING_PREFIX)
 -developer-build (FEATURE_developer_build)
were specified, but
  -prefix (CMAKE_INSTALL_PREFIX)
was not,
the build system would set the CMAKE_INSTALL_PREFIX to the
qtbase build dir.

Then, if targeting desktop, this would be considered a non-prefix
build (ninja install would refuse to work), whereas in a cross-build
it would be considered an installable build.

In both cases though, the rpath of installed binaries would point to
the qtbase build dir (because CMAKE_INSTALL_PREFIX would be set to the
qtbase build dir).

This is quite confusing behavior, in more than one way.

Change the build system to consider that an explicit -extprefix should
cause Qt to always be installed, even if -developer-build is
specified.

This means the installed rpaths and on-device install prefix
(CMAKE_INSTALL_PREFIX) will now use the default computed install
prefix, e.g. /usr/local/Qt

It also means that to get a non-installable developer + custom staging
and install (on-device) prefix build, users will have to be explicit
and set all the options
 -extprefix ~/qt/qtbase_build_dir
 -prefix /usr
 -developer-build

Pick-to: 6.2 6.3
Change-Id: Ib560452a4b4778860e0fd7666c76f8a6745773ee
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Alexandru Croitor 2022-04-13 15:07:46 +02:00
parent f3483e6b96
commit 5059f7adc2

View File

@ -110,7 +110,8 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_LINK_DEPENDS_NO_SHARED ON) set(CMAKE_LINK_DEPENDS_NO_SHARED ON)
# Detect non-prefix builds: either when the qtbase install prefix is set to the binary dir # Detect non-prefix builds: either when the qtbase install prefix is set to the binary dir
# or when a developer build is explicitly enabled and no install prefix is specified. # or when a developer build is explicitly enabled and no install prefix (or staging prefix)
# is specified.
# This detection only happens when building qtbase, and later is propagated via the generated # This detection only happens when building qtbase, and later is propagated via the generated
# QtBuildInternalsExtra.cmake file. # QtBuildInternalsExtra.cmake file.
if (PROJECT_NAME STREQUAL "QtBase" AND NOT QT_BUILD_STANDALONE_TESTS) if (PROJECT_NAME STREQUAL "QtBase" AND NOT QT_BUILD_STANDALONE_TESTS)
@ -118,8 +119,12 @@ if (PROJECT_NAME STREQUAL "QtBase" AND NOT QT_BUILD_STANDALONE_TESTS)
# Handle both FEATURE_ and QT_FEATURE_ cases when they are specified on the command line # Handle both FEATURE_ and QT_FEATURE_ cases when they are specified on the command line
# explicitly. It's possible for one to be set, but not the other, because # explicitly. It's possible for one to be set, but not the other, because
# qtbase/configure.cmake is not processed by this point. # qtbase/configure.cmake is not processed by this point.
if(FEATURE_developer_build OR QT_FEATURE_developer_build if((FEATURE_developer_build
OR FEATURE_no_prefix OR QT_FEATURE_no_prefix) OR QT_FEATURE_developer_build
OR FEATURE_no_prefix
OR QT_FEATURE_no_prefix
)
AND NOT CMAKE_STAGING_PREFIX)
# Handle non-prefix builds by setting the CMake install prefix to point to qtbase's # 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 # 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 on the command line to point to the qtbase build dir.