diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-06-17 10:53:08 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-07-22 20:52:14 +0000 |
commit | 8899143612d61faa1e41faa4c0c0288b1724ffd0 (patch) | |
tree | 1330ec78b8c8b2cd96699a9247c9a37c9cf0c405 /cmake | |
parent | c65b417ac1c006abe6a0064bbe2740ec017935a4 (diff) |
Improve toolchain generation
Set is_clang and calculate v8-host arch for other
hosts than x64.
Change-Id: I5622839840141ed60328c8bd736e4cada3e0ecee
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
(cherry picked from commit 9196f743cec64840c711d00a8e906b480ba1451e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/Functions.cmake | 88 |
1 files changed, 63 insertions, 25 deletions
diff --git a/cmake/Functions.cmake b/cmake/Functions.cmake index 37d097b6a..3f01646ed 100644 --- a/cmake/Functions.cmake +++ b/cmake/Functions.cmake @@ -362,36 +362,74 @@ function(qt_internal_add_external_project_dependency_to_root_project name) endfunction() function(get_gn_arch result arch) - if("${arch}" STREQUAL "i386") - set(${result} "x86" PARENT_SCOPE) - elseif("${arch}" STREQUAL "x86_64") - set(${result} "x64" PARENT_SCOPE) - elseif("${arch}" STREQUAL "arm") - set(${result} "arm" PARENT_SCOPE) - elseif("${arch}" STREQUAL "arm64") - set(${result} "arm64" PARENT_SCOPE) - elseif("${arch}" STREQUAL "mipsel") - set(${result} "mipsel" PARENT_SCOPE) - elseif("${arch}" STREQUAL "mipsel64") - set(${result} "mips64el" PARENT_SCOPE) - else() - message(DEBUG "Unsupported achitecture: ${arch}") - endif() + if(arch STREQUAL "i386") + set(${result} "x86" PARENT_SCOPE) + elseif(arch STREQUAL "x86_64") + set(${result} "x64" PARENT_SCOPE) + elseif(arch STREQUAL "arm") + set(${result} "arm" PARENT_SCOPE) + elseif(arch STREQUAL "arm64") + set(${result} "arm64" PARENT_SCOPE) + elseif(arch STREQUAL "mipsel") + set(${result} "mipsel" PARENT_SCOPE) + elseif(arch STREQUAL "mipsel64") + set(${result} "mips64el" PARENT_SCOPE) + else() + message(DEBUG "Unsupported architecture: ${arch}") + endif() +endfunction() + +function(get_v8_arch result targetArch hostArch) + set(list32 i386 arm mipsel) + if(hostArch STREQUAL targetArch) + set(${result} "${targetArch}" PARENT_SCOPE) + elseif(targetArch IN_LIST list32) + # 32bit target which needs a 32bit compatible host + if(hostArch STREQUAL "x86_64") + set(${result} "i386" PARENT_SCOPE) + elseif(hostArch STREQUAL "arm64") + set(${result} "arm" PARENT_SCOPE) + elseif(hostArch STREQUAL "mips64") + set(${result} "mipsel" PARENT_SCOPE) + elseif(hostArch STREQUAL "mipsel64") + set(${result} "mipsel" PARENT_SCOPE) + else() + message(DEBUG "Unsupported architecture: ${hostArch}") + endif() + else() + # assume 64bit target which matches 64bit host + set(${result} "${hostArch}" PARENT_SCOPE) + endif() endfunction() -function(get_v8_arch result targetArch) - set(list32 i386 arm mipsel) - if("${targetArch}" IN_LIST list32) - set(${result} "i386" PARENT_SCOPE) - else() - set(${result} "x86_64" PARENT_SCOPE) - endif() +function(get_gn_os result) + if(WIN32) + set(${result} "win" PARENT_SCOPE) + elseif(LINUX) + set(${result} "linux" PARENT_SCOPE) + elseif(MACOS) + set(${result} "mac" PARENT_SCOPE) + elseif(IOS) + set(${result} "ios" PARENT_SCOPE) + else() + message(DEBUG "Unrecognized OS") + endif() +endfunction() + +function(get_gn_is_clang result) + if(CLANG) + set(${result} "true" PARENT_SCOPE) + else() + set(${result} "false" PARENT_SCOPE) + endif() endfunction() -function(configure_gn_toolchain name cpuType v8CpuType toolchainIn toolchainOut) +function(configure_gn_toolchain name binTargetCpu v8TargetCpu toolchainIn toolchainOut) set(GN_TOOLCHAIN ${name}) - get_gn_arch(GN_CPU ${cpuType}) - get_gn_arch(GN_V8_CPU ${v8CpuType}) + get_gn_os(GN_OS) + get_gn_is_clang(GN_IS_CLANG) + get_gn_arch(GN_CPU ${binTargetCpu}) + get_gn_arch(GN_V8_CPU ${v8TargetCpu}) configure_file(${toolchainIn} ${toolchainOut}/BUILD.gn @ONLY) endfunction() |