diff options
author | Michal Klocek <michal.klocek@qt.io> | 2022-04-20 08:48:02 +0200 |
---|---|---|
committer | Michal Klocek <michal.klocek@qt.io> | 2022-04-30 18:08:52 +0000 |
commit | ba74eaba11b2df9d6c2b23f7595e7bb1a03e911e (patch) | |
tree | e5dba781d76a41e4c8340e6813383aaa1d0f4dab /cmake | |
parent | 692e2295b5676652ff0d405fd9b916cbd428dad3 (diff) |
Support cross-compilation on macOS
So far we only supported a cross-compiling with universal builds,
however qmake also supports 'regular' cross compilation (by setting
'-device-option'). This is semi-supported with qt-cmake as we need to
provide additional configure defines like:
* CMAKE_OSX_ARCHITECTURES=arm64
* CMAKE_SYSTEM_NAME=Darwin
* CMAKE_OSX_DEPLOYMENT_TARGET=10.14
It might seem to be a far fetched issue, however in case of webengine
doing the cross compilation for only one architecture allows to save
compile times when testing only arm64 builds.
Note we do not need to create gn toolchains for that case, however
unlike universal builds it requires host qt build for tools.
Pick-to: 6.3 6.2
Change-Id: Ica8470fdd4cad4866c1470e0403ffd019eaf39a6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/Functions.cmake | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/cmake/Functions.cmake b/cmake/Functions.cmake index cc6f609f6..44313d8cf 100644 --- a/cmake/Functions.cmake +++ b/cmake/Functions.cmake @@ -1033,18 +1033,26 @@ endfunction() function(get_configs result) if(QT_GENERATOR_IS_MULTI_CONFIG) - set(${result} ${CMAKE_CONFIGURATION_TYPES} PARENT_SCOPE) + set(${result} ${CMAKE_CONFIGURATION_TYPES}) else() - set(${result} ${CMAKE_BUILD_TYPE} PARENT_SCOPE) + set(${result} ${CMAKE_BUILD_TYPE}) + endif() + if(NOT ${result}) + message(FATAL_ERROR "No valid configurations found !") endif() + set(${result} ${${result}} PARENT_SCOPE) endfunction() function(get_architectures result) - if(QT_IS_MACOS_UNIVERSAL OR IOS) - set(${result} ${CMAKE_OSX_ARCHITECTURES} PARENT_SCOPE) + if(CMAKE_OSX_ARCHITECTURES) + set(${result} ${CMAKE_OSX_ARCHITECTURES}) else() - set(${result} ${CMAKE_SYSTEM_PROCESSOR} PARENT_SCOPE) + set(${result} ${CMAKE_SYSTEM_PROCESSOR}) endif() + if(NOT ${result}) + message(FATAL_ERROR "No valid architectures found. In case of cross-compiling make sure you have CMAKE_SYSTEM_PROCESSOR in your toolchain file.") + endif() + set(${result} ${${result}} PARENT_SCOPE) endfunction() function(add_gn_build_aritfacts_to_target cmakeTarget ninjaTarget module buildDir completeStatic) @@ -1053,14 +1061,9 @@ function(add_gn_build_aritfacts_to_target cmakeTarget ninjaTarget module buildDi # the minimum cmake we support get_configs(configs) get_architectures(archs) - if(NOT configs) - message(FATAL_ERROR "No valid configurations found !") - endif() - if(NOT archs) - message(FATAL_ERROR "No valid architectures found. In case of cross-compiling make sure you have CMAKE_SYSTEM_PROCESSOR in your toolchain file.") - endif() foreach(config ${configs}) foreach(arch ${archs}) + set(target ${ninjaTarget}_${config}_${arch}) add_ninja_target(${target} ${cmakeTarget} ${ninjaTarget} ${config} ${arch} ${buildDir}) add_ninja_command( @@ -1080,15 +1083,14 @@ function(add_gn_build_aritfacts_to_target cmakeTarget ninjaTarget module buildDi else() extend_cmake_target(${target} ${buildDir}/${config}/${arch} ${completeStatic}) endif() + unset(target) endforeach() + list(GET archs 0 arch) + set(target ${ninjaTarget}_${config}_${arch}) if(QT_IS_MACOS_UNIVERSAL) - set(arch ${CMAKE_SYSTEM_PROCESSOR}) - set(target ${ninjaTarget}_${config}_${arch}) add_lipo_command(${target} ${buildDir}/${config}) endif() if(IOS) - list(GET archs 0 arch) - set(target ${ninjaTarget}_${config}_${arch}) add_ios_lipo_command(${target} ${buildDir}/${config}) endif() endforeach() |