summaryrefslogtreecommitdiffstats
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-02 12:51:15 +0200
commit3a962d8a2d3b70639a195fe5fd442f6c653bbe8f (patch)
treefc29d1aa945b0ad90c9a558e6e3155f4c35f1f9a /CMakeLists.txt
parent9e8f10247a5c5d433f5f983345f636fbedb26e2d (diff)
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. Pick-to: dev Task-number: QTBUG-91760 Change-Id: Ic2bea12229acc71fbd36a848e9ed4fed7e14b485 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 d5133e4dc..0b55f2435 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -69,6 +69,7 @@ add_subdirectory(src/process)
add_subdirectory(src/webenginewidgets)
add_subdirectory(src/webenginequick)
qt_build_repo_end()
+get_install_config(installConfig)
### NINJA
@@ -100,9 +101,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,
@@ -121,11 +123,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()
@@ -133,6 +136,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")
@@ -228,3 +235,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()