diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2021-09-08 09:30:11 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2021-09-22 18:32:47 +0200 |
commit | fb9cc529201dab24f864ede3e15114845aad0cdb (patch) | |
tree | 25121ba6e2e6191cce9b878cbb5dcf042a919587 /cmake/QtBuildInternals | |
parent | a36a795770d4c4cbab610c5721140023e02b1737 (diff) |
Rework how installation is prevented in non-prefix builds
In non-prefix builds, we want to prevent users from accidentally running
"cmake --install". We did that by replacing cmake_install.cmake with an
empty file.
The responsible target remove_cmake_install is visible in IDEs, appears
in the build output, and the approach is hacky.
It's cleaner and easier to add bail out code at the top of
cmake_install.cmake. This is now done when calling qt_build_repo_begin.
As a bonus, print an informative message on installation.
Change-Id: I022b36289358ba09cac8b79781f44cd7b93113f7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake/QtBuildInternals')
-rw-r--r-- | cmake/QtBuildInternals/QtBuildInternalsConfig.cmake | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake index 4bd0d745cc..bd1aeafc8f 100644 --- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake +++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake @@ -370,6 +370,23 @@ endmacro() macro(qt_build_repo_begin) qt_build_internals_set_up_private_api() + + # Prevent installation in non-prefix builds. + # We need to associate targets with export names, and that is only possible to do with the + # install(TARGETS) command. But in a non-prefix build, we don't want to install anything. + # To make sure that developers don't accidentally run make install, add bail out code to + # cmake_install.cmake. + if(NOT QT_WILL_INSTALL) + # In a top-level build, print a message only in qtbase, which is the first repository. + if(NOT QT_SUPERBUILD OR (PROJECT_NAME STREQUAL "QtBase")) + install(CODE [[message(FATAL_ERROR + "Qt was configured as non-prefix build. " + "Installation is not supported for this arrangement.")]]) + endif() + + install(CODE [[return()]]) + endif() + qt_enable_cmake_languages() # Add global docs targets that will work both for per-repo builds, and super builds. |