diff options
author | Michal Klocek <michal.klocek@qt.io> | 2021-05-23 17:39:28 +0200 |
---|---|---|
committer | Michal Klocek <michal.klocek@qt.io> | 2021-07-02 12:51:15 +0200 |
commit | 3a962d8a2d3b70639a195fe5fd442f6c653bbe8f (patch) | |
tree | fc29d1aa945b0ad90c9a558e6e3155f4c35f1f9a /cmake/FindPkgConfigHost.cmake | |
parent | 9e8f10247a5c5d433f5f983345f636fbedb26e2d (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 'cmake/FindPkgConfigHost.cmake')
-rw-r--r-- | cmake/FindPkgConfigHost.cmake | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/cmake/FindPkgConfigHost.cmake b/cmake/FindPkgConfigHost.cmake new file mode 100644 index 000000000..de0216384 --- /dev/null +++ b/cmake/FindPkgConfigHost.cmake @@ -0,0 +1,40 @@ +# this is just simply pkg config wrapper to pass executable path to gn + +if(CMAKE_CROSSCOMPILING) + # find pkg-config, use PKG_CONFIG_HOST if set + if((NOT PKG_CONFIG_HOST_EXECUTABLE) AND (NOT "$ENV{PKG_CONFIG_HOST}" STREQUAL "")) + set(PKG_CONFIG_HOST_EXECUTABLE "$ENV{PKG_CONFIG_HOST}" CACHE FILEPATH "pkg-config host executable") + endif() + + find_program(PKG_CONFIG_HOST_EXECUTABLE NAMES "pkg-config" DOC "pkg-config executable" + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_FIND_ROOT_PATH + ) + + if(PKG_CONFIG_HOST_EXECUTABLE) + mark_as_advanced(PKG_CONFIG_HOST_EXECUTABLE) + execute_process(COMMAND ${PKG_CONFIG_HOST_EXECUTABLE} --version + OUTPUT_VARIABLE PKG_CONFIG_HOST_VERSION_STRING + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET) + endif () + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(PkgConfigHost + FOUND_VAR PkgConfigHost_FOUND + VERSION_VAR PKG_CONFIG_HOST_VERSION_STRING + REQUIRED_VARS PKG_CONFIG_HOST_EXECUTABLE + ) +else() # if not corss build simply wrap FindPkgConfig + find_package(PkgConfig) + if(PKG_CONFIG_FOUND) + include(FindPackageHandleStandardArgs) + set(PKG_CONFIG_HOST_VERSION ${PKG_CONFIG_VERSION}) + set(PKG_CONFIG_HOST_EXECUTABLE ${PKG_CONFIG_EXECUTABLE}) + find_package_handle_standard_args(PkgConfigHost + FOUND_VAR PkgConfigHost_FOUND + VERSION_VAR PKG_CONFIG_HOST_VERSION_STRING + REQUIRED_VARS PKG_CONFIG_HOST_EXECUTABLE + ) + endif() +endif() |