Toolchain compilation concern

Hello all

I just started with the RubikPi.
As a first step I wanted to build a simple c++ program using cmake, so I started following:

I have installed the toolchain (I can see yocto logs are correct) and sourced the
environment-setup-armv8-2a-qcom-linux script and followed the suggested cmake confnigurations:

cmake_minimum_required(VERSION 3.10)
...
...
...
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm64) #Set the target processor architecture

#Set sysroot
set(TOOLCHAIN_DIR /PATH_TO_MY_SDK_DIR/sysroots/armv8-2a-qcom-linux)
set(CMAKE_SYSROOT ${TOOLCHAIN_DIR}/sysroots/armv8-2a-qcom-linux)

#Set the cross-compiler
SET(CMAKE_C_COMPILER ${TOOLCHAIN_DIR}/sysroots/x86_64-qcomsdk-linux/usr/bin/aarch64-qcom-linux/aarch64-qcom-linux-gcc)
SET(CMAKE_CXX_COMPILER ${TOOLCHAIN_DIR}/sysroots/x86_64-qcomsdk-linux/usr/bin/aarch64-qcom-linux/aarch64-qcom-linux-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)

Result: Is not working

The only way to make it work:

cmake_minimum_required(VERSION 3.10)
...
...
...
#Set sysroot
#set(TOOLCHAIN_DIR /home/avilagtz/qcom-wayland_sdk/tmp/sysroots/x86_64)
#set(CMAKE_SYSROOT ${TOOLCHAIN_DIR}/usr/bin/aarch64-qcom-linux)

#Set the cross-compiler
SET(CMAKE_C_COMPILER aarch64-qcom-linux-gcc)
SET(CMAKE_CXX_COMPILER aarch64-qcom-linux-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)

I can execute the binary on the board with QCOM Linux but my question is, by doing this cmake modification I’m losing important features? As for now is a very simple code but I’m wondering if I’m following the right way:

Current basic code:

#include <iostream>

int main() {
    std::cout<<"Hello RubikPI 3!\n";
    return 0;
}

The cross development toolchain has to be setup correctly with sysroot or you will not be able to build correctly with the libraries included on your target. I think of sysroot as the exact target libraries and include files on my local PC that the RubikPi was built with.