From 62905163bf887c2c2c9ba7edcd64c96d237a6e95 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 6 Mar 2024 17:43:04 +0100 Subject: CMake: Allow building all examples as standalone just like tests Introduce a new libexec/qt-internal-configure-examples script that allows to configure and build "standalone examples" just like "standalone tests". This is a prerequisite for using deployment api in examples for prefix builds, otherwise deployment api gets confused not finding various information that it expects from an installed qt. Because the various conditions in the build system for standalone examples are similar to standalone tests, introduce a new QT_BUILD_STANDALONE_PARTS variable and use that in the conditions. The variable should not be set by the user, and is instead set by the build system whenever QT_BUILD_STANDALONE_TESTS/EXAMPLES is set. Unfortunately due to no common file being available before the first project() call, in qtbase builds, per-repo builds and top-level builds, we need to duplicate the code for setting QT_BUILD_STANDALONE_PARTS for all three cases. Task-number: QTBUG-90820 Task-number: QTBUG-96232 Change-Id: Ia40d03a0e8f5142abe5c7cd4ff3000df4a5f7a8a Reviewed-by: Alexey Edelev Reviewed-by: Qt CI Bot --- libexec/qt-internal-configure-examples.bat.in | 34 +++++++++++++++++++++++++++ libexec/qt-internal-configure-examples.in | 5 ++++ 2 files changed, 39 insertions(+) create mode 100644 libexec/qt-internal-configure-examples.bat.in create mode 100755 libexec/qt-internal-configure-examples.in (limited to 'libexec') diff --git a/libexec/qt-internal-configure-examples.bat.in b/libexec/qt-internal-configure-examples.bat.in new file mode 100644 index 0000000000..6b69910c66 --- /dev/null +++ b/libexec/qt-internal-configure-examples.bat.in @@ -0,0 +1,34 @@ +@echo off +setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS +set script_dir_path=%~dp0 +set script_dir_path=%script_dir_path:~0,-1% + +rem Extracts the source path, make it native, and put it +rem back again. This is a workaround on Windows LLVM/MINGW +rem to help CMake find source files when doing Unity Build. +set args=%* +set source_dir_path= +set native_source_dir_path= +for %%i in (%args%) do ( + if "%%i"=="-S" ( + set found=true + ) else if defined found ( + set source_dir_path=%%i + set native_source_dir_path=%%~dpnxi + set found= + ) +) + +if NOT "%native_source_dir_path%" == "" ( + set args=!args:%source_dir_path%=%native_source_dir_path%! +) + +set cmake_scripts_dir=%script_dir_path% + +set relative_bin_dir=@relative_path_from_libexec_dir_to_bin_dir@ +if NOT "%relative_bin_dir%" == "" ( +set relative_bin_dir="%relative_bin_dir%"\ +) + +call "%script_dir_path%"\%relative_bin_dir%"qt-cmake.bat" ^ + @script_passed_args@ %args% diff --git a/libexec/qt-internal-configure-examples.in b/libexec/qt-internal-configure-examples.in new file mode 100755 index 0000000000..d0bf333ee6 --- /dev/null +++ b/libexec/qt-internal-configure-examples.in @@ -0,0 +1,5 @@ +#!/bin/sh +script_dir_path=`dirname $0` +script_dir_path=`(cd "$script_dir_path"; /bin/pwd)` + +"$script_dir_path/@relative_path_from_libexec_dir_to_bin_dir@/qt-cmake" @script_passed_args@ "$@" -- cgit v1.2.3