Commit Graph

10 Commits

Author SHA1 Message Date
Alexandru Croitor
fe40e08da4 CMake: Fix building iOS projects with a single-arch Qt build
Automatically set the CMAKE_OSX_SYSROOT and CMAKE_OSX_ARCHITECTURES
values with the ones Qt was configured with, when configuring a user
project with the Xcode generator and a single arch / sdk Qt build.

This ensures that calling xcodebuild from the command line chooses the
correct architecture and SDK when building the project.

Allow to opt out of this behavior by passing
QT_NO_SET_OSX_ARCHITECTURES and QT_NO_SET_OSX_SYSROOT.

Amends 55a15a1c1b
Amends a6a3b82ffb

Pick-to: 6.2
Task-number: QTBUG-95838
Change-Id: Ifab16e9eee3100a9b80a2a14b3ea29ba8d9aa6fc
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-17 21:30:34 +02:00
Mårten Nordheim
bccfb92507 CMake: output VCPKG_CHAINLOAD_TOOLCHAIN_FILE with cmake paths
Change-Id: Ibde8890c30b9024aca589e892590d071b547c361
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-18 21:15:05 +02:00
Alexandru Croitor
0d8eb8a5ab CMake: Don't build cmake build tests as macOS universal
We want standalone tests added by qt_internal_add_test to be built as
universal executables, so we can build them on an intel machine and
run them on an ARM machine.

But CMake build tests will be built on the final machine that runs the
tests and it might lack a universal SDK. That's why they should be
built only targeting the architecture of the machine they're running
on.

Change the generated qt.tooclhain.cmake file to allow opting in or out
of building projects with the same architectures as Qt was configured
with.

Now standalone tests will be multi-arch, but CMake build tests will be
single-arch.

Amends e379147f95

Task-number: QTBUG-85447
Task-number: QTBUG-87580
Task-number: QTBUG-92933
Change-Id: I41ab047983115f84eb2333cc9ac2d19ca08d621f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-05-10 11:20:44 +02:00
Simo Fält
3969ef40cc Add instructions for Windows 10 on Arm config
Task-number: QTQAINFRA-3966
Change-Id: Ib8ac80a5b8aa5c88d9e5d0eaad9ba550cc2442f8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Fathi Boudra
2021-05-05 16:28:27 +03:00
Alexandru Croitor
e379147f95 CMake: Fix default architecture selection for macOS and iOS
Before this change, we created a CMake toolchain file for iOS and
macOS universal which propagated the initially configured
CMAKE_OSX_ARCHITECTURES values to user projects.

So if Qt was configured with 2 arches, configuring a CMake user
project using the generated toolchain file would also build the
user project targeting those 2 arches.

The reason for this that the same toolchain file is used for
configuring both Qt and users projects and we needed to ensure that
other Qt repos are built with the same set of arches. That
unfortunately led the multiple arches to carry over into user
projects.
This is different from qmake behavior which configured user projects
with 1 arch only.

Instead of the toolchain file explicitly setting
CMAKE_OSX_ARCHITECTURES for all projects, save the initial list of
arches into QT_OSX_ARCHITECTURES.
Then if the toolchain file detects that we're building a Qt repo (by
checking for the presence of QT_REPO_MODULE_VERSION) set
CMAKE_OSX_ARCHITECTURES to QT_OSX_ARCHITECTURES to propagate the
initial list of arches.

For user projects we want to have some sensible defaults.
For macOS projects, leave the decision of the architecture to build
to CMake.
For iOS Xcode projects, leave the decision to Xcode.
For iOS Ninja projects, set the architecture to the first value of the
architectures used when configuring Qt.

As a side note this fixes an issue in our CI where we configured macOS
Qt with 2 architectures and then tried to run CMake build tests for
both architectures on a machine that doesn't have the universal SDK.
This led to build failures.
Because the CMake build tests act as regular user projects, now they
are configured with a single architecture that is automtically
detected by CMake.

Pick-to: 6.1
Task-number: QTBUG-85447
Change-Id: Id1b7e78d7e67c1796efed10751416e5f857c16d2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-04-14 13:38:31 +02:00
Alexandru Croitor
659817e287 CMake: Fix building multi-arch universal macOS Qt
Use the same approach we use for iOS, which is to set multiple
CMAKE_OSX_ARCHITECTURES values and let the clang front end
deal with lipo-ing the final libraries.

For now, Qt can be configured to build universal macOS libraries by
passing 2 architectures to CMake, either via:

  -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"

or

  -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"

Currently we recommend specifying the intel x86_64 arch as the first
one, to get an intel slice configuration that is comparable to a
non-universal intel build.
Specifying the arm64 slice first could pessimize optimizations and
reduce the feature set for the intel slice due to the limitation
that we run configure tests only once.

The first specified architecture is the one used to do all the
configure tests.

It 'mostly' defines the common feature set of both architecture
slices, with the excepion of some special handling for sse2 and
neon instructions.

In the future we might want to run at least the Qt architecture config
test for all specified architectures, so that we can extract all the
supported sub-arches and instruction sets in a reliable way.

For now, we use the same sse2 hack as for iOS simulator_and_device
builds, otherwise QtGui fails to link due to missing
qt_memfill32_sse2 and other symbols.

The hack is somewhat augmented to ensure that reconfiguration
still succeeds (same issue happened with iOS). Previously the sse2
feature condition was broken due to force setting the feature
to be ON. Now the condition also checks for a special
QT_FORCE_FEATURE_sse2 variable which we set internally.

Note that we shouldn't build for arm64e, because the binaries
get killed when running on AS with the following message:

  kernel: exec_mach_imgact: not running binary built against
  preview arm64e ABI.

Aslo, by default, we disable the arm64 slice for qt sql plugins,
mostly because the CI provisioned sql libraries that we depend on only
contain x86_64 slices, and trying to build the sql plugins for both
slices will fail with linker errors.
This behavior can be disabled for all targets marked by
qt_internal_force_macos_intel_arch, by setting the
QT_FORCE_MACOS_ALL_ARCHES CMake option to ON.
To disble it per-target one can set
QT_FORCE_MACOS_ALL_ARCHES_${target} to ON.

Task-number: QTBUG-85447
Change-Id: Iccb5dfcc1a21a8a8292bd3817df0ea46c3445f75
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-04-01 18:14:59 +02:00
Alexey Edelev
56bdef9437 CMake: Use host variables instead of hardcoded directories
'QT_HOST_PATH' indicates that we use crosscompilation toolchain
to build project. In this case 'Qt6Config.cmake' loads
'Qt6HostInfoConfig.cmake' from host QT_HOST_PATH, that defines
correct paths to host tools.

Replace hardcoded paths for host tools by paths recorded
in Qt6HostInfoConfig.cmake.

Correct conditions for QT_HOST_PATH, evaluate it explicitly as
string, but not as boolean expression.

Fixes: QTBUG-86557
Pick-to: 6.0
Change-Id: Ib52bbd32478051d019a932dcb1f735e2d4aacfbf
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-12-21 13:41:13 +01:00
Joerg Bornemann
ca59c20939 CMake: Fix usage of cache variables in qt.toolchain.cmake
We have some cache variables that are used in our qt.toolchain.cmake
toolchain file, for example QT_CHAINLOAD_TOOLCHAIN_FILE. When CMake
runs a configure test with try_compile, our toolchain file is included
again, but only a restricted set of variables is available.

Add the variables that are used in our internal toolchain file to
CMAKE_TRY_COMPILE_PLATFORM_VARIABLES. This makes them visible for
try_compile calls operating on source files.

Also pass the variables via the environment to support try_compile
calls that operate on whole projects.

Fixes: QTBUG-87873
Change-Id: Iebca9e23686bec5072194b15482e1782b9367a0e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-05 13:04:56 +01:00
Assam Boudjelthia
f8a83fc5c0 CMake: allow using ANDORID_NDK_ROOT for user projects
Allow CMake for Android to use ANDROID_NDK_ROOT to deduce the path for
QT_CHAINLOAD_TOOLCHAIN_FILE instead of the user providing it manually.

Change-Id: Ida728011d5ca8d5a723d341ea77b173e8f105f8c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-27 13:49:39 +02:00
Alexandru Croitor
acf9b3a68b CMake: Split QtBaseGlobalTargets.cmake into multiple files
And wrap the various behaviors into separate functions.

Change-Id: If940351af34e445de050f2b46301de7080b1555b
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-10-12 13:36:01 +02:00