# CMake C++ Toolchain Changing during crosscompile Projekt Build with vcpkg

**URL:** https://discourse.cmake.org/t/cmake-c-toolchain-changing-during-crosscompile-projekt-build-with-vcpkg/11365
**Category:** Usage
**Tags:** os:linux
**Created:** [August 1, 2024, 6:02am UTC](https://discourse.cmake.org/t/cmake-c-toolchain-changing-during-crosscompile-projekt-build-with-vcpkg/11365 "2024-08-01T06:02:52Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![fwlff](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/f/a587f6/32.png) [@fwlff](https://discourse.cmake.org/u/fwlff)
#### Post date: [August 1, 2024, 6:02am UTC](https://discourse.cmake.org/t/cmake-c-toolchain-changing-during-crosscompile-projekt-build-with-vcpkg/11365/1 "2024-08-01T06:02:52Z")

</div>

Hello there,

im trying to compile a c++ Project with vcpkg in manifestmode with a cross compiler on a debian linux.  
I configured the toolchain file in the CMakeLists to use the vcpkg.cmake. In the vcpkg triplet i reference my Toolchain file, that points to the crosscompiler.

The build of the vcpkg librarys works, but after that, cmake continues with the standard compiler from my debian container.

i have already set the env-variable CMAKE\_TOOLCHAIN\_FILE that points to my Toolchain file, but it still does not work. If i disable the vcpkg entries in the CMakeLists.txt, the right compiler is used, but ofcourse the vcpkg dependencys are now not found.

```auto
relevant CMakeLists.txt entries:
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake)
set(VCPKG_MANIFEST_FEATURES)
set(VCPKG_TARGET_TRIPLET "x64-linux")
set(CMAKE_CXX_FLAGS "-std=c++20 -Wall -static-libgcc -static-libstdc++ -DUNIX")

```

```auto
vcpkg triplet file:
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 /home/myuser/myproject/CMakeToolChainFile.cmake)

```

```auto
CMakeToolChainFile:
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x64)

set(CMAKE_SYSROOT /home/myuser/x-tools/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/sysroot)

set(tools /home/myuser/x-tools/x86_64-unknown-linux-gnu)
set(CMAKE_C_COMPILER ${tools}/bin/x86_64-unknown-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER ${tools}/bin/x86_64-unknown-linux-gnu-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)

```

I would be grateful for any help

---

<div class="post-metadata">

### Author: ![fwlff](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/f/a587f6/32.png) [@fwlff](https://discourse.cmake.org/u/fwlff)
#### Post date: [August 1, 2024, 6:14am UTC](https://discourse.cmake.org/t/cmake-c-toolchain-changing-during-crosscompile-projekt-build-with-vcpkg/11365/2 "2024-08-01T06:14:48Z")

</div>

im using the cmake version 3.30.1 🙂
