Hi,
I am having some trouble setting up a cross compiling build environment from a Windows host targeting raspbian 32 bits arm. If I directly use the cross compiler to build a hello world it works fine and run on my target. But as soon as I try to build the same from CMake I cannot find any way to setup things.
MINGW64 ~/work/testArm/build
$ /e/Qt/Tools/CMake_64/bin/cmake -D CMAKE_TOOLCHAIN_FILE=/e/SysGCC/raspberry/rpi_toolchain.cmake -D CMAKE_MAKE_PROGRAM=/e/Qt/Tools/Ninja/ninja.exe -G Ninja ..
-- The CXX compiler identification is GNU 10.2.1
CMake Error at CMakeLists.txt:3 (project):
The CMAKE_CXX_COMPILER:
E:/SysGCC/raspberry/bin/arm-linux-gnueabihf-g++
is not a full path to an existing compiler tool.
Tell CMake where to find the compiler by setting either the environment
variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.
-- Configuring incomplete, errors occurred!
See also "C:/Users/vivien.delmon/work/testArm/build/CMakeFiles/CMakeOutput.log".
MINGW64 ~/work/testArm/build
$ cat C:/Users/vivien.delmon/work/testArm/build/CMakeFiles/CMakeOutput.log
The target system is: Linux - -
The host system is: Windows - 10.0.19045 - AMD64
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler: E:/SysGCC/raspberry/bin/arm-linux-gnueabihf-g++
Build flags:
Id flags:
The output was:
0
Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.out"
The CXX compiler identification is GNU, found in "C:/Users/vivien.delmon/work/testArm/build/CMakeFiles/3.24.2/CompilerIdCXX/a.out"
My rpi_toolchain.cmake contains the following :
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_CROSSCOMPILING TRUE)
set(CMAKE_SYSTEM_PROCESSOR "armv7")
# Specify the cross compiler
set(CMAKE_C_COMPILER ${CMAKE_CURRENT_LIST_DIR}/bin/arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER ${CMAKE_CURRENT_LIST_DIR}/bin/arm-linux-gnueabihf-g++)
# Where is the target environment
set(CMAKE_FIND_ROOT_PATH ${CMAKE_CURRENT_LIST_DIR}/arm-linux-gnueabihf/sysroot)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --sysroot=${CMAKE_FIND_ROOT_PATH}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --sysroot=${CMAKE_FIND_ROOT_PATH}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} --sysroot=${CMAKE_FIND_ROOT_PATH}")
# Search for programs only in the build host directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# Search for libraries and headers only in the target directories
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
It is the first time I try to setup a cross compiling environment from Windows/CMake and I probably miss something obvious but I cannot find what …