diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-04-28 11:45:44 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-04-30 10:13:18 +0200 |
commit | 39090ea15c41eded8a233ec2633c0c657280297c (patch) | |
tree | 702c51b7ee0d7f5c90c5bd81e628a292279dd482 /cmake | |
parent | d2bb14253cf3fce209eba8f2696e0a9751e62655 (diff) |
CMake: Fix usage of correct install prefix for standalone tests
Previously configuration of standalone tests might have failed
due to CMake trying to create files in the /usr/local default
prefix.
Make sure to use a fake prefix in the binary dir instead,
unless another prefix is explicitly specified.
Change-Id: Icfcb32285aa5596abf1a918396b26673880a8d27
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/QtBuildInternals/QtBuildInternalsConfig.cmake | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake index 5966695da4..1743f1fc02 100644 --- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake +++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake @@ -267,8 +267,21 @@ function(qt_restore_backed_up_install_prefix) # Restore the CMAKE_INSTALL_PREFIX that was set before loading BuildInternals. # Useful for standalone tests, we don't want to accidentally install a test into the Qt prefix. get_property(helpstring CACHE CMAKE_INSTALL_PREFIX PROPERTY HELPSTRING) - set(CMAKE_INSTALL_PREFIX "${QT_BACKUP_CMAKE_INSTALL_PREFIX_BEFORE_EXTRA_INCLUDE}" - CACHE STRING "${helpstring}" FORCE) + + # If CMAKE_INSTALL_PREFIX was default initialized, that means it points to something + # like /usr/local which we don't want. Why? When metatype json files are created + # during standalone tests configuration, the folder creation might fail due to missing + # permissions in the /usr/local (which is the wrong place anyway). + # Instead specify a dummy install prefix in the current build dir. + # If the prefix was specified by the user at the command line, honor it, hoping that the + # user knows what they are doing. + if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(new_install_prefix "${CMAKE_BINARY_DIR}/standalone_tests_fake_install_prefix") + else() + set(new_install_prefix "${QT_BACKUP_CMAKE_INSTALL_PREFIX_BEFORE_EXTRA_INCLUDE}") + endif() + + set(CMAKE_INSTALL_PREFIX "${new_install_prefix}" CACHE STRING "${helpstring}" FORCE) endfunction() macro(qt_examples_build_begin) |