summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2021-05-23 17:39:28 +0200
committerMichal Klocek <michal.klocek@qt.io>2021-07-16 14:38:14 +0200
commit7a48cf4217faaf3ef89f866ce96ac27111390b58 (patch)
tree3dfa8af78a8bb94b26cb888d02169f4fd754588d /CMakeLists.txt
parenta4f9f0fe950794029766c0e77160219527952160 (diff)
downloadqtwebengine-7a48cf4217faaf3ef89f866ce96ac27111390b58.tar.gz
Add cross compilation support to cmake builds
Add arm cross-compile basic support. CMake does not support host builds. However we do host build with gn and changing that would require an extra effort to keep all necessary changes with Chromium upstream. Therefore let gn to perform the host build for required tools and just feed gn with all the build data. Add new build steps: * install gn into QT_HOST_PATH/libexec. * run hostBuild project to get native architecture and compiler * call PkgConfigHost to pass pkg-config paths to gn * create wrapper script for host pkg-config to escape yocto shell pkg config exports This change also splits gn toolchain into 3 toolchains host,target,v8 Now hostBuild provides host and v8 toolchain in case of cross compile. The build optimizations will follow in another patch. Fix not existing 'boot2qt' condition and enables more test on QEMU. Note this is tested only with yocto based images. Task-number: QTBUG-91760 Change-Id: Ic2bea12229acc71fbd36a848e9ed4fed7e14b485 (cherry picked from commit 3a962d8a2d3b70639a195fe5fd442f6c653bbe8f) Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt38
1 files changed, 36 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f45fa111d..603b58fca 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -63,6 +63,7 @@ add_subdirectory(src/process)
add_subdirectory(src/webenginewidgets)
add_subdirectory(src/webenginequick)
qt_build_repo_end()
+get_install_config(installConfig)
### NINJA
@@ -94,9 +95,10 @@ if(NOT Gn_FOUND)
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DCMAKE_PREFIX_PATH:PATH=<INSTALL_DIR>
-DWEBENGINE_ROOT_BUILD_DIR=${CMAKE_CURRENT_BINARY_DIR}
-)
+ )
endif()
+
### LIBS
# on windows source path can be specified without hard drive letter,
@@ -115,11 +117,12 @@ endif()
list(TRANSFORM featureList PREPEND "-D")
list(APPEND libsCmakeArgs
"-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}"
- "-DWEBENGINE_ROOT_BUILD_PATH=${CMAKE_CURRENT_BINARY_DIR}"
+ "-DWEBENGINE_ROOT_BUILD_DIR=${CMAKE_CURRENT_BINARY_DIR}"
"-DWEBENGINE_ROOT_SOURCE_DIR=${WEBENGINE_ROOT_SOURCE_DIR}"
"-DWEBENGINE_REPO_BUILD=TRUE"
"${featureList}"
)
+
if (CMAKE_C_COMPILER_LAUNCHER)
list(APPEND libsCmakeArgs "-DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER}")
endif()
@@ -127,6 +130,10 @@ if (CMAKE_CXX_COMPILER_LAUNCHER)
list(APPEND libsCmakeArgs "-DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}")
endif()
+if(QT_HOST_PATH)
+ list(APPEND libsCmakeArgs "-DQT_HOST_PATH=${QT_HOST_PATH}")
+endif()
+
if(LINUX)
set(cmd "${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/src")
file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/build.sh CONTENT "ulimit -n 4096 && ${cmd}\n")
@@ -222,3 +229,30 @@ if(NOT QT_FEATURE_framework)
DESTINATION ${CMAKE_INSTALL_PREFIX}
)
endif()
+
+### CROSS BUILD SETUP
+
+# install gn for cross build
+# TODO: is this really needed, should we skip it and just build gn as host build ?
+if(LINUX AND NOT Gn_FOUND OR INSTALL_GN)
+ set(INSTALL_GN 1 CACHE INTERNAL "")
+ install(
+ PROGRAMS ${installDir}/bin/gn
+ CONFIGURATIONS ${installConfig}
+ RUNTIME DESTINATION "${INSTALL_LIBEXECDIR}"
+ )
+endif()
+
+if(CMAKE_CROSSCOMPILING)
+ externalproject_add(hostBuild
+ SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/src/core/configure
+ BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/configure
+ PREFIX cross
+ USES_TERMINAL_BUILD ON
+ CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${QT_HOST_PATH}/lib/cmake/Qt6/qt.toolchain.cmake
+ -DWEBENGINE_ROOT_BUILD_DIR=${CMAKE_CURRENT_BINARY_DIR}
+ -DWEBENGINE_ROOT_SOURCE_DIR=${WEBENGINE_ROOT_SOURCE_DIR}
+ -DGN_TARGET_CPU=${TEST_architecture_arch}
+ )
+ externalproject_add_stepdependencies(qtwebengine install hostBuild)
+endif()