diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2024-03-18 18:09:23 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2024-03-18 22:34:48 +0100 |
commit | 990b60120e3b72394ba66220d090cf357c34e5d3 (patch) | |
tree | 93daa8c4c420bed9462365c57fec67021a3747a5 | |
parent | 6ee5fcc45637bf45ecd7d5412db8ab58bde7fe39 (diff) |
cmake: Override generator for iOS projects to Xcode in qt-cmake.in
Instead of maintaining a separate qt-cmake.ios.in wrapper script that
can easily diverge from qt-cmake.in
Change-Id: I53f4eac02188be89a4c11b3e71cde04ac2a24b51
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rwxr-xr-x | bin/qt-cmake.in | 2 | ||||
-rwxr-xr-x | bin/qt-cmake.ios.in | 22 | ||||
-rw-r--r-- | cmake/QtWrapperScriptHelpers.cmake | 17 |
3 files changed, 15 insertions, 26 deletions
diff --git a/bin/qt-cmake.in b/bin/qt-cmake.in index f719257f60..14de927c3a 100755 --- a/bin/qt-cmake.in +++ b/bin/qt-cmake.in @@ -13,5 +13,7 @@ fi toolchain_path="$script_dir_path/@__GlobalConfig_relative_path_from_bin_dir_to_cmake_config_dir@/qt.toolchain.cmake" +@extra_qt_cmake_code@ + # Find the qt toolchain relative to the absolute bin dir path where the script is located. exec "$cmake_path" -DCMAKE_TOOLCHAIN_FILE="$toolchain_path" @__qt_cmake_extra@ "$@" diff --git a/bin/qt-cmake.ios.in b/bin/qt-cmake.ios.in deleted file mode 100755 index 260da534d3..0000000000 --- a/bin/qt-cmake.ios.in +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -# The directory of this script is the expanded absolute path of the "$qt_prefix/bin" directory. -script_dir_path=`dirname $0` -script_dir_path=`(cd "$script_dir_path"; /bin/pwd)` - -# Try to use original cmake, otherwise to make it relocatable, use any cmake found in PATH. -original_cmake_path="@CMAKE_COMMAND@" -cmake_path=$original_cmake_path -if ! test -f "$cmake_path"; then - cmake_path="cmake" -fi - -# Find the qt toolchain relative to the absolute bin dir path where the script is located. -toolchain_path="$script_dir_path/@__GlobalConfig_relative_path_from_bin_dir_to_cmake_config_dir@/qt.toolchain.cmake" - -# Specify Xcode as the default generator by assigning it to the CMAKE_GENERATOR env var. -# An explicit -G or -D CMAKE_GENERATOR given on the command line will still take precedence. -export CMAKE_GENERATOR=Xcode - -# Run cmake. -exec "$cmake_path" -DCMAKE_TOOLCHAIN_FILE="$toolchain_path" @__qt_cmake_extra@ "$@" diff --git a/cmake/QtWrapperScriptHelpers.cmake b/cmake/QtWrapperScriptHelpers.cmake index 62d9290ffe..9ba8e4017b 100644 --- a/cmake/QtWrapperScriptHelpers.cmake +++ b/cmake/QtWrapperScriptHelpers.cmake @@ -19,13 +19,18 @@ function(qt_internal_create_wrapper_scripts) set(generate_non_unix TRUE) endif() + set(extra_qt_cmake_code "") if(generate_unix) + if(IOS) - set(infix ".ios") - else() - set(infix "") + set(extra_qt_cmake_code [=[ +# Specify Xcode as the default generator by assigning it to the CMAKE_GENERATOR env var. +# An explicit -G or -D CMAKE_GENERATOR given on the command line will still take precedence. +export CMAKE_GENERATOR=Xcode +]=]) endif() - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/bin/qt-cmake${infix}.in" + + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/bin/qt-cmake.in" "${QT_BUILD_DIR}/${INSTALL_BINDIR}/qt-cmake" @ONLY NEWLINE_STYLE LF) qt_install(PROGRAMS "${QT_BUILD_DIR}/${INSTALL_BINDIR}/qt-cmake" @@ -53,6 +58,10 @@ function(qt_internal_create_wrapper_scripts) qt_install(PROGRAMS "${QT_BUILD_DIR}/${INSTALL_BINDIR}/qt-cmake-create.bat" DESTINATION "${INSTALL_BINDIR}") endif() + + # Reset the contents for the next script. + set(extra_qt_cmake_code "") + # Provide a private convenience wrapper with options that should not be propagated via the # public qt-cmake wrapper e.g. CMAKE_GENERATOR. # These options can not be set in a toolchain file, but only on the command line. |