CMake: Unset DESTDIR when installing non-standalone examples
When QT_INTERNAL_EXAMPLES_INSTALL_PREFIX is set, the build system should ignore the DESTDIR env var when installing examples. Otherwise the examples will still be installed into a location where the Coin agent will archive the files, and thus blow up the package size, especially if each example contains deployed Qt libraries. Backup and temporarily unset the DESTDIR env var while example installation is in progress. Amends 02cb165ef8050230b477358e4136e9f0acd83eb6 Amends 7694b01aafd52b7064161b2f8c9a98cd330d24d3 Task-number: QTBUG-90820 Task-number: QTBUG-96232 Change-Id: Ibe24a88dd672d246b579d815a813dd042f60e6a6 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> (cherry picked from commit 90db9a41566f0fdb26b7a80b68b55ac0360489f0) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
5400025796
commit
db58564f4f
@ -28,6 +28,8 @@ macro(qt_examples_build_begin)
|
||||
qt_internal_find_standalone_parts_config_files()
|
||||
endif()
|
||||
|
||||
string(TOLOWER ${PROJECT_NAME} project_name_lower)
|
||||
|
||||
if(arg_EXTERNAL_BUILD AND QT_BUILD_EXAMPLES_AS_EXTERNAL)
|
||||
# Examples will be built using ExternalProject.
|
||||
# We depend on all plugins built as part of the current repo as well as current repo's
|
||||
@ -50,7 +52,6 @@ macro(qt_examples_build_begin)
|
||||
|
||||
set(QT_IS_EXTERNAL_EXAMPLES_BUILD TRUE)
|
||||
|
||||
string(TOLOWER ${PROJECT_NAME} project_name_lower)
|
||||
if(NOT TARGET examples)
|
||||
if(QT_BUILD_EXAMPLES_BY_DEFAULT)
|
||||
add_custom_target(examples ALL)
|
||||
@ -120,6 +121,28 @@ macro(qt_examples_build_begin)
|
||||
# files are installed into the original install prefix.
|
||||
set(_qt_internal_examples_cmake_install_prefix_backup \"\${CMAKE_INSTALL_PREFIX}\")
|
||||
")
|
||||
|
||||
# Backup the DESTDIR and unset it, so that example installation is not affected by DESTDIR.
|
||||
# This is activated by our CI when QT_INTERNAL_EXAMPLES_INSTALL_PREFIX is set.
|
||||
if(QT_INTERNAL_EXAMPLES_INSTALL_PREFIX)
|
||||
set(_qt_examples_should_unset_destdir TRUE)
|
||||
else()
|
||||
set(_qt_examples_should_unset_destdir FALSE)
|
||||
endif()
|
||||
|
||||
set_property(GLOBAL PROPERTY
|
||||
_qt_examples_should_unset_destdir_${project_name_lower}
|
||||
"${_qt_examples_should_unset_destdir}")
|
||||
if(_qt_examples_should_unset_destdir)
|
||||
install(CODE "
|
||||
# Temporarily unset DESTDIR while examples are being installed.
|
||||
set(_qt_internal_examples_destdir_backup \"\$ENV{DESTDIR}\")
|
||||
unset(ENV{DESTDIR})
|
||||
")
|
||||
endif()
|
||||
|
||||
unset(_qt_examples_should_unset_destdir)
|
||||
unset(project_name_lower)
|
||||
endmacro()
|
||||
|
||||
macro(qt_examples_build_end)
|
||||
@ -145,6 +168,21 @@ set(CMAKE_INSTALL_PREFIX \"\${_qt_internal_examples_cmake_install_prefix_backup}
|
||||
")
|
||||
|
||||
set(CMAKE_UNITY_BUILD ${QT_UNITY_BUILD})
|
||||
|
||||
string(TOLOWER ${PROJECT_NAME} project_name_lower)
|
||||
get_property(_qt_examples_should_unset_destdir
|
||||
GLOBAL PROPERTY _qt_examples_should_unset_destdir_${project_name_lower})
|
||||
|
||||
if(_qt_examples_should_unset_destdir)
|
||||
install(CODE "
|
||||
# Restore the DESTDIR env var after examples have been installed.
|
||||
set(ENV{DESTDIR} \"\${_qt_internal_examples_destdir_backup}\")
|
||||
unset(_qt_internal_examples_destdir_backup)
|
||||
")
|
||||
endif()
|
||||
|
||||
unset(_qt_examples_should_unset_destdir)
|
||||
unset(project_name_lower)
|
||||
endmacro()
|
||||
|
||||
# Allows building an example either as an ExternalProject or in-tree with the Qt build.
|
||||
|
Loading…
x
Reference in New Issue
Block a user