I have cmake project which I've successfully set up and used for cross compiling with a toolchain file.
I have a separate variable I want to set in my top level cmake file based on the value of the CMAKE_SYSTEM_PROCESSOR variable that is set in the tool chain file. But when referenced in the top level cmake file, the value of CMAKE_SYSTEM_PROCESSOR does not have the value from the toolchain file.
I can reproduce the conditions with a simple cmake file and one line toolchain file.
If I have the following cmake file:
project(ToolchainTest C)
message("CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR}")
and run
cmake .
I get
CMAKE_SYSTEM_PROCESSOR x86_64
as I expect.
With the following one line toolchain file "toolchain.cmake":
set(CMAKE_SYSTEM_PROCESSOR aarch64)
when I run
cmake . -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake
I get exactly the same output, x86_64, and not aarch64 as I expected.
I looked over the following related posts, but as I'm just printing the value and not doing a string match (in the example) I don't think they apply.
Can I use CMAKE_SYSTEM_PROCESSOR, defined in a toolchain file, in CMakeLists?
CMake compare to empty string with STREQUAL failed
I'm using cmake version 3.13.4 on Ubuntu 19.04.