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

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.

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")
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)
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

im using the cmake version 3.30.1 :slight_smile: