diff --git a/cmake/QtProcessConfigureArgs.cmake b/cmake/QtProcessConfigureArgs.cmake index 1940b250fdb..986c50cc06f 100644 --- a/cmake/QtProcessConfigureArgs.cmake +++ b/cmake/QtProcessConfigureArgs.cmake @@ -600,6 +600,10 @@ while(1) if(arg MATCHES "^--?enable-(.*)") set(opt "${CMAKE_MATCH_1}") set(val "yes") + # Handle -no-prefix so it's not interpreted as the negation of -prefix + elseif(arg MATCHES "-(no-prefix)") + set(opt "${CMAKE_MATCH_1}") + set(val "") elseif(arg MATCHES "^--?(disable|no)-(.*)") set(opt "${CMAKE_MATCH_2}") set(val "no") @@ -902,6 +906,10 @@ foreach(input ${config_inputs}) push("-DINPUT_${cmake_input}=${INPUT_${input}}") endforeach() +if(DEFINED INPUT_no-prefix AND DEFINED INPUT_prefix) + qtConfAddError("Can't specify both -prefix and -no-prefix options at the same time.") +endif() + if(NOT generator AND auto_detect_generator) find_program(ninja ninja) if(ninja) diff --git a/cmake/QtSetup.cmake b/cmake/QtSetup.cmake index 83f07cf98b5..e886428508a 100644 --- a/cmake/QtSetup.cmake +++ b/cmake/QtSetup.cmake @@ -11,6 +11,13 @@ if(NOT FEATURE_developer_build AND INPUT_developer_build set(FEATURE_developer_build ON) endif() +# Pre-calculate the no_prefix feature if it's set by configure via INPUT_no_prefix. +# This needs to be done before qtbase/configure.cmake is processed. +if(NOT FEATURE_no_prefix AND INPUT_no_prefix + AND NOT "${INPUT_no_prefix}" STREQUAL "undefined") + set(FEATURE_no_prefix ON) +endif() + set(_default_build_type "Release") if(FEATURE_developer_build) set(_default_build_type "Debug") @@ -95,7 +102,11 @@ set(CMAKE_LINK_DEPENDS_NO_SHARED ON) # QtBuildInternalsExtra.cmake file. if (PROJECT_NAME STREQUAL "QtBase" AND NOT QT_BUILD_STANDALONE_TESTS) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - if(FEATURE_developer_build) + # 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 + # qtbase/configure.cmake is not processed by this point. + if(FEATURE_developer_build OR QT_FEATURE_developer_build + OR FEATURE_no_prefix OR QT_FEATURE_no_prefix) # 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. diff --git a/cmake/configure-cmake-mapping.md b/cmake/configure-cmake-mapping.md index 01f7d5f164a..6874b909b39 100644 --- a/cmake/configure-cmake-mapping.md +++ b/cmake/configure-cmake-mapping.md @@ -3,6 +3,8 @@ The following table describes the mapping of configure options to CMake argument | configure | cmake | Notes | |---------------------------------------|---------------------------------------------------|-----------------------------------------------------------------| | -prefix /opt/qt6 | -DCMAKE_INSTALL_PREFIX=/opt/qta6 | | +| -no-prefix (only available in Qt6) | -DCMAKE_INSTALL_PREFIX=$PWD (with bash) | In Qt5 this was done by specifying -prefix $PWD | +| or -DFEATURE_no_prefix=ON | | | -extprefix /opt/qt6 | -DCMAKE_STAGING_PREFIX=/opt/qt6 | | | -bindir