I am cross-compiling from intel to ARM. My problem is the ninja generated files seem to refer to the host system includes rather than the cross-compile includes
cat ../../toolchain-armv7l.cmake
# Define the toolchain file for the ARMv7l architecture
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
# Define the sysroot path
set(CMAKE_SYSROOT "/usr/arm-linux-gnueabihf")
set(CMAKE_FIND_ROOT_PATH "/usr/arm-linux-gnueabihf")
# Define the cross-compiler
set(CMAKE_C_COMPILER "/usr/bin/arm-linux-gnueabihf-gcc")
set(CMAKE_CXX_COMPILER "/usr/bin/arm-linux-gnueabihf-g++")
# Define the linker
set(CMAKE_LINKER "/usr/bin/arm-linux-gnueabihf-ld")
SET(CMAKE_EXE_LINKER_FLAGS "-L/usr/arm-linux-gnueabihf/lib/")
# Define the include and library directories
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
set(CMAKE_INCLUDE_PATH ${CMAKE_SYSROOT}/include)
set(CMAKE_LIBRARY_PATH ${CMAKE_SYSROOT}/lib)
# Define the path to the cross-compiled include directories
# Define the include and library directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
# Define the flags for the cross-compiler
set(CMAKE_C_FLAGS "-Wall -march=armv7-a -mfpu=neon-vfpv4 -mfloat-abi=hard")
set(CMAKE_CXX_FLAGS "-Wall -march=armv7-a -mfpu=neon-vfpv4 -mfloat-abi=hard")
----
cmake -G Ninja ../.. -DCMAKE_TOOLCHAIN_FILE=/home/jeremy/Projects/meercam/toolchain-armv7l.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=ONq
-- Host Processor is x86_64
-- Set up for Release
Definitions are -Wall -march=armv7-a -mfpu=neon-vfpv4 -mfloat-abi=hard
-- Configuring done
-- Generating done
-- Build files have been written to: /home/jeremy/Projects/meercam/build/armv7l
--- Generated script build.ninja
#############################################
# Order-only phony target for meercam
build cmake_object_order_depends_target_meercam: phony || src/CMakeFiles/meercam.dir
build src/CMakeFiles/meercam.dir/meercam.cpp.o: CXX_COMPILER__meercam_Release ../../src/meercam.cpp || cmake_object_order_depends_target_meercam
DEP_FILE = src/CMakeFiles/meercam.dir/meercam.cpp.o.d
FLAGS = -Wall -march=armv7-a -mfpu=neon-vfpv4 -mfloat-abi=hard -O3 -DNDEBUG -Wall -std=c++17 -ftree-vectorize
INCLUDES = -I/usr/local/include
OBJECT_DIR = src/CMakeFiles/meercam.dir
OBJECT_FILE_DIR = src/CMakeFiles/meercam.dir
The problem line is
INCLUDES = -I/usr/local/include
Also
cat CMakeFiles/rules.ninja
# CMAKE generated file: DO NOT EDIT!
# Generated by "Ninja" Generator, CMake Version 3.18
# This file contains all the rules used to get the outputs files
# built from the input files.
# It is included in the main 'build.ninja'.
# =============================================================================
# Project: meercam
# Configurations: Release
# =============================================================================
# =============================================================================
#############################################
# Rule for running custom commands.
rule CUSTOM_COMMAND
command = $COMMAND
description = $DESC
#############################################
# Rule for compiling CXX files.
rule CXX_COMPILER__meercam_Release
depfile = $DEP_FILE
deps = gcc
command = /usr/bin/arm-linux-gnueabihf-g++ --sysroot=/usr/arm-linux-gnueabihf $DEFINES $INCLUDES $FLAGS -MD -MT $out -MF $DEP_FILE -o $out -c $in
description = Building CXX object $out
#############################################
# Rule for linking CXX executable.
rule CXX_EXECUTABLE_LINKER__meercam_Release
command = $PRE_LINK && /usr/bin/arm-linux-gnueabihf-g++ --sysroot=/usr/arm-linux-gnueabihf $FLAGS $LINK_FLAGS $in -o $TARGET_FILE $LINK_PATH $LINK_LIBRARIES && $POST_BUILD
description = Linking CXX executable $TARGET_FILE
restat = $RESTAT