summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2022-03-28 16:59:20 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-03-29 15:37:08 +0000
commit1a4de6437b4e60b462b429b188d0ffd61d9739a2 (patch)
tree3bb32ae75ea1263f8b0b2f2278631a61571252bb /cmake
parentb466c7ab14fe9931faaec9c18e0041751e69c24d (diff)
CMake: Fix picking of the binary_for_strip project location
Fix binary_for_strip project not being found when the following conditions were met: - building a repo other than qtbase - qtbase sources are not available on the machine (usually happens in CI where only the current repo sources are available). The issue was that QT_CMAKE_DIR would always be defined, regardless of which repo was being built and the system would incorrectly assume the location of the project files. The fix is to always pick up the sources from qtbase's source dir if they are available (this time done with an appropriate check), otherwise use the installed files. Note that the behavior of always using the qtbase sources if available is not exactly the best, but it is a more general issue that affects other code too. In the name of consistency, make it so for the binary_for_strip project as well, but add TODOs in code to address the situation in a separate change. Amends 39f657032b5e65bfcb93472201f6607c0388ba37 Fixes: QTBUG-102064 Task-number: QTBUG-88090 Task-number: QTBUG-101653 Change-Id: I0649f945e9ff0ab1f597c51bb5ab389fa665c021 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 939a8281e66226cfdd175e03cd92818639d31765) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtBuildInternals/QtBuildInternalsConfig.cmake3
-rw-r--r--cmake/QtSeparateDebugInfo.cmake61
2 files changed, 44 insertions, 20 deletions
diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
index a6891241e7..e05d922b16 100644
--- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
+++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
@@ -74,6 +74,9 @@ macro(qt_set_up_build_internals_paths)
# building qtdeclarative, rather than having to build qtbase first (which will copy
# QtBuild.cmake to the build dir). This is similar to qmake non-prefix builds, where the
# source qtbase/mkspecs directory is used.
+ # TODO: Clean this up, together with qt_internal_try_compile_binary_for_strip to only use the
+ # the qtbase sources when building qtbase. And perhaps also when doing a non-prefix
+ # developer-build.
if(EXISTS "${QT_SOURCE_TREE}/cmake")
list(PREPEND CMAKE_MODULE_PATH "${QT_SOURCE_TREE}/cmake")
endif()
diff --git a/cmake/QtSeparateDebugInfo.cmake b/cmake/QtSeparateDebugInfo.cmake
index 2d4811b18d..0ac111a68e 100644
--- a/cmake/QtSeparateDebugInfo.cmake
+++ b/cmake/QtSeparateDebugInfo.cmake
@@ -6,21 +6,31 @@ endif()
# Builds a shared library which will have strip run on it.
function(qt_internal_try_compile_binary_for_strip binary_out_var)
- # Need to find the config.tests files depending on which repo we are building.
- if(EXISTS "${QT_CMAKE_DIR}")
- # building qtbase
- set(basedir "${QT_CMAKE_DIR}/..")
- else()
- # building other repo
- set(basedir "${_qt_cmake_dir}/${QT_CMAKE_EXPORT_NAMESPACE}")
- endif()
+ # Need to find the config.tests files depending whether the qtbase sources are available.
+ # This mirrors the logic in qt_set_up_build_internals_paths.
+ # TODO: Clean this up, together with qt_set_up_build_internals_paths to only use the
+ # the qtbase sources when building qtbase. And perhaps also when doing a non-prefix
+ # developer-build.
set(config_test_dir "config.tests/binary_for_strip")
- set(src_dir "${basedir}/${config_test_dir}")
+ set(qtbase_config_test_dir "${QT_SOURCE_TREE}/${config_test_dir}")
+ set(installed_config_test_dir
+ "${_qt_cmake_dir}/${QT_CMAKE_EXPORT_NAMESPACE}/${config_test_dir}")
+
+ # qtbase sources available, always use them, regardless of prefix or non-prefix builds.
+ if(EXISTS "${qtbase_config_test_dir}")
+ set(src_dir "${qtbase_config_test_dir}")
+
+ # qtbase sources unavailable, use installed files.
+ elseif(EXISTS "${installed_config_test_dir}")
+ set(src_dir "${installed_config_test_dir}")
+ else()
+ message(FATAL_ERROR "Can't find binary_for_strip config test project.")
+ endif()
# Make sure the built project files are not installed when doing an in-source build (like it
# happens in Qt's CI) by choosing a build dir that does not coincide with the installed
- # source dir.
+ # source dir. Otherwise the config test binaries will be packaged up, which we don't want.
set(binary_dir "${CMAKE_CURRENT_BINARY_DIR}/${config_test_dir}_built")
set(flags "")
@@ -137,18 +147,29 @@ function(qt_internal_generate_binary_strip_wrapper)
set(script_name "qt-internal-strip")
- if(EXISTS "${QT_CMAKE_DIR}")
- # qtbase build-tree case
- set(wrapper_in_basedir "${QT_CMAKE_DIR}/..")
- else()
- # other repo case
- set(wrapper_in_basedir "${_qt_cmake_dir}/${QT_CMAKE_EXPORT_NAMESPACE}")
- endif()
-
# the libexec literal is used on purpose for the source, so the file is found
# on Windows hosts.
- set(wrapper_in
- "${wrapper_in_basedir}/libexec/${script_name}${wrapper_extension}.in")
+ set(wrapper_rel_path "libexec/${script_name}${wrapper_extension}.in")
+
+ # Need to find the libexec input file depending whether the qtbase sources are available.
+ # This mirrors the logic in qt_set_up_build_internals_paths.
+ # TODO: Clean this up, together with qt_set_up_build_internals_paths to only use the
+ # the qtbase sources when building qtbase. And perhaps also when doing a non-prefix
+ # developer-build.
+ set(qtbase_wrapper_in_path "${QT_SOURCE_TREE}/${wrapper_rel_path}")
+ set(installed_wrapper_in_path
+ "${_qt_cmake_dir}/${QT_CMAKE_EXPORT_NAMESPACE}/${wrapper_rel_path}")
+
+ # qtbase sources available, always use them, regardless of prefix or non-prefix builds.
+ if(EXISTS "${qtbase_wrapper_in_path}")
+ set(wrapper_in "${qtbase_wrapper_in_path}")
+
+ # qtbase sources unavailable, use installed files.
+ elseif(EXISTS "${installed_wrapper_in_path}")
+ set(wrapper_in "${installed_wrapper_in_path}")
+ else()
+ message(FATAL_ERROR "Can't find ${script_name}${wrapper_extension}.in file.")
+ endif()
set(wrapper_out "${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/${script_name}${wrapper_extension}")