How to integrate vcpkg in linux with cross build toolchain, as well as sysroot?
Asked Answered
E

1

8

My question is, how to integrate vcpkg in linux with cross build toolchain, as well as sysroot? example:

  • build machine is fedora30
  • cross build toolchain is x86_64-centos7-gnu

from https://github.com/microsoft/vcpkg quickstart says:

> git clone https://github.com/Microsoft/vcpkg.git
> cd vcpkg

PS> .\bootstrap-vcpkg.bat
Linux:~/$ ./bootstrap-vcpkg.sh

On my machine I have gcc 9.1 installed which is detected by vcpkg's bootstrap.sh and work fine;

Meanwhile, I built a toolchain for crossbuilding, which sits in $HOME/cross/x64_86-centos7-linux-gnu/

How can I setup another vcpkg dir tree which uses that perticular toolchain?

By 'use', I mean vcpkg and all its packages should be compiled by that toolchain, and my projects which use vcpkg's toolchain_file '$vcpkg_home/scripts/buildsystems/vcpkg.cmake' should all have that toolchain as $CC and build toolset?

Expanded answered 9/11, 2019 at 9:2 Comment(6)
Did you follow all the steps from the Quickstart? Did you get errors? Which steps worked, or didn't work? Please add these details to your question post!Afternoons
edit: On my machine I have gcc 9.1 installed which is detected by vcpkg's bootstrap.sh and work fine; Meanwhile, I built a toolchain for crossbuilding, which sits in $HOME/cross/x64_86-centos7-linux-gnu/ How can I setup another vcpkg dir tree which uses that perticular toolchain? By 'use', I mean vcpkg and all its packages should be compiled by that toolchain, and my projects which use vcpkg's toolchain_file '$vcpkg_home/scripts/buildsystems/vcpkg.cmake' should all have that toolchain as $CC and build toolset?Expanded
Please add all this information to your question postAfternoons
Quick start: all steps to me work fine, compiled and runned a program with some vcpkg's packages; Non-quickstart: problem is no cmake-ish xxx-toolchain.cmake in my cross compile toolchain dir tree to try as a -DCMAKE_TOOLCHAIN_FILE list item.Expanded
Not to mention that wish to compile vcpkg downloaded packages to install with that toolchain which I think is obviously a requirement to build projects.Expanded
To set up one can download a raspberry PI build toolset tarball to try with.Expanded
K
9

You should write a triplet file that references your desired toolchain. Create a file ${VCPKG_ROOT}/triplets/x64-centos7 with content

set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)

set(VCPKG_CMAKE_SYSTEM_NAME Linux)

set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE /your/cmake/toolchain.cmake)

/your/cmake/toolchain.cmake beeing a CMake toolchain like

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x64)

set(CMAKE_SYSROOT /your/sysroot)

set(tools $HOME/cross/x64_86-centos7-linux-gnu/)
set(CMAKE_C_COMPILER ${tools}/bin/your-gcc)
set(CMAKE_CXX_COMPILER ${tools}/bin/your-g++)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
Kush answered 6/12, 2019 at 9:59 Comment(1)
How would you to this to allow multiple users to collaborate on the project, with an easy onboarding process? Would you commit the triplet and toolchain files to the git repo? Would you list them as prerequisites for the user to install? I'm trying to figure out a viable process, with no success...Thebault

© 2022 - 2024 — McMap. All rights reserved.