i try to crosscompile a c++ project for a specific glibc/kernel version in debian container. The toolchain was created with crosstool-ng and works fine as i can tell.
The project uses vcpkg for different libs in manifest mode. If i call the cmake-build, vcpkg is compiling the libs with the cross compiler. But after it finishes an goes for the code of the project suddenly the standard-compiler from the deiban system is used. So far i have no idea what went wrong, any help would be apriciated.
calling script:
#!/bin/bash
export TMP=/var/tmp
export TMP4VCPKG=$TMP/vcpkg
export CMake_BUILD_DIR=cmakebuild_linux
export TRIPLET=x64-linux-crosscompiler
cmake -G "Unix Makefiles" -B $CMake_BUILD_DIR -DCMAKE_BUILD_TYPE=MinSizeRel
cmake --build $CMake_BUILD_DIR --clean-first
Root CMakeLists.txt:
cmake_minimum_required(VERSION 3.30.1)
set(VCPKG_OVERLAY_TRIPLETS "${CMAKE_CURRENT_SOURCE_DIR}")
set(VCPKG_TARGET_TRIPLET "$ENV{TRIPLET}")
set(CMAKE_TOOLCHAIN_FILE "$ENV{TMP4VCPKG}/scripts/buildsystems/vcpkg.cmake")
set(VCPKG_MANIFEST_FEATURES)
project(testproject CXX)
set(CMAKE_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${testproject_SOURCE_DIR}/cmake)
set(CMAKE_FIND_STATIC FIRST)
set(CMAKE_CXX_FLAGS "-std=c++20 -Wall -static-libgcc -static-libstdc++ -DUNIX")
include_directories(
${CMAKE_SOURCE_DIR}/include
)
add_subdirectory(shared)
add_subdirectory(src)
the custom-triplet file from vcpkg:
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/build/repos/projects/testproject/CMakeToolChainFile.cmake)
the toolchain file:
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x64)
set(CMAKE_SYSROOT /home/build/x-tools/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/sysroot)
set(tools /home/build/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 tried to set the CMAKE_TOOLCHAIN_FILE as env-variable (as default) in additon to the cmakelists settings, pointung to the toolchain file (not the vcpkg one). But the build process still prints something like this:
first vcpkg install:
-- Running vcpkg install Detecting compiler hash for triplet x64-linux... Compiler found: /usr/bin/c++ Detecting compiler hash for triplet x64-linux-crosscompiler... Compiler found: /home/build/x-tools/x86_64-unknown-linux-gnu/bin/x86_64-unknown-linux-gnu-g++ The following packages will be built and installed:
and after that:
- Running vcpkg install - done -- The CXX compiler identification is GNU 12.2.0 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done
and it continues with the wrong compiler in /usr/bin/c++
fwlff is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.