[Solved] Problem with arm-none-eabi compiler variables on Windows

Hi! After several hours of trying to build blink with pico-sdk “the harder way :)” (mostly playing with CMake and learning), I am coming for help.

I have setup VS 2022, CMake 3.25, ARM GNU toolchain, Ninja. So far so good.
But I cannot convince pico-sdk to compile “the way I want”.

In my cmake I have these variables:

set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)

These executables are in my path, I can call them in terminal and even CMake finds them. cmake -G Ninja .. goes without any problem:

PS C:\Projects\RPico\blink\build> cmake .. -G Ninja
Using PICO_SDK_PATH from environment ('C:\Projects\RPico\pico-sdk')
PICO_SDK_PATH is C:/Projects/RPico/pico-sdk
Defaulting PICO_PLATFORM to rp2040 since not specified.
Defaulting PICO platform compiler to pico_arm_gcc since not specified.
-- Defaulting build type to 'Release' since not specified.
PICO compiler is pico_arm_gcc
-- The C compiler identification is GNU 12.2.1
-- The CXX compiler identification is GNU 12.2.1
-- The ASM compiler identification is GNU
-- Found assembler: C:/Program Files (x86)/Arm GNU Toolchain arm-none-eabi/12.2 rel1/bin/arm-none-eabi-gcc.exe
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Arm GNU Toolchain arm-none-eabi/12.2 rel1/bin/arm-none-eabi-gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Arm GNU Toolchain arm-none-eabi/12.2 rel1/bin/arm-none-eabi-g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Build type is Release
Defaulting PICO target board to pico since not specified.
Using board configuration from C:/Projects/RPico/pico-sdk/src/boards/include/boards/pico.h
-- Found Python3: C:/Users/husar/AppData/Local/Programs/Python/Python310/python.exe (found version "3.10.9") found components: Interpreter
TinyUSB available at C:/Projects/RPico/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040; enabling build support for USB.
BTstack available at C:/Projects/RPico/pico-sdk/lib/btstack
cyw43-driver available at C:/Projects/RPico/pico-sdk/lib/cyw43-driver
Pico W Bluetooth build support available.
lwIP available at C:/Projects/RPico/pico-sdk/lib/lwip
mbedtls available at C:/Projects/RPico/pico-sdk/lib/mbedtls
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Projects/RPico/blink/build

The problem comes when I want to build the project.

PS C:\Projects\RPico\blink\build> cmake --build .
[13/91] Performing configure step for 'PioasmBuild'
FAILED: pico-sdk/src/rp2_common/pico_cyw43_driver/pioasm/src/PioasmBuild-stamp/PioasmBuild-configure C:/Projects/RPico/blink/build/pico-sdk/src/rp2_common/pico_cyw43_driver/pioasm/src/PioasmBuild-stamp/PioasmBuild-configure
cmd.exe /C "cd /D C:\Projects\RPico\blink\build\pioasm && "C:\Program Files\CMake\bin\cmake.exe" -DCMAKE_MAKE_PROGRAM:FILEPATH=C:/Ninja/ninja.exe -GNinja -CC:/Projects/RPico/blink/build/pico-sdk/src/rp2_common/pico_cyw43_driver/pioasm/tmp/PioasmBuild-cache-Release.cmake C:/Projects/RPico/pico-sdk/tools/pioasm && "C:\Program Files\CMake\bin\cmake.exe" -E touch C:/Projects/RPico/blink/build/pico-sdk/src/rp2_common/pico_cyw43_driver/pioasm/src/PioasmBuild-stamp/PioasmBuild-configure"
loading initial cache file C:/Projects/RPico/blink/build/pico-sdk/src/rp2_common/pico_cyw43_driver/pioasm/tmp/PioasmBuild-cache-Release.cmake
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:2 (project):
  No CMAKE_CXX_COMPILER could be found.

  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:/Projects/RPico/blink/build/pioasm/CMakeFiles/CMakeOutput.log".
See also "C:/Projects/RPico/blink/build/pioasm/CMakeFiles/CMakeError.log".
[14/91] Performing configure step for 'ELF2UF2Build'
FAILED: elf2uf2/src/ELF2UF2Build-stamp/ELF2UF2Build-configure C:/Projects/RPico/blink/build/elf2uf2/src/ELF2UF2Build-stamp/ELF2UF2Build-configure
cmd.exe /C "cd /D C:\Projects\RPico\blink\build\elf2uf2 && "C:\Program Files\CMake\bin\cmake.exe" -DCMAKE_MAKE_PROGRAM:FILEPATH=C:/Ninja/ninja.exe -GNinja C:/Projects/RPico/pico-sdk/tools/elf2uf2 && "C:\Program Files\CMake\bin\cmake.exe" -E touch C:/Projects/RPico/blink/build/elf2uf2/src/ELF2UF2Build-stamp/ELF2UF2Build-configure"
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:2 (project):
  No CMAKE_C_COMPILER could be found.

  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.


CMake Error at CMakeLists.txt:2 (project):
  No CMAKE_CXX_COMPILER could be found.

  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:/Projects/RPico/blink/build/elf2uf2/CMakeFiles/CMakeOutput.log".
See also "C:/Projects/RPico/blink/build/elf2uf2/CMakeFiles/CMakeError.log".
ninja: build stopped: subcommand failed.

It fails building pioasm because it doesn’t see my compiler variables. Why doesn’t Ninja pass them to it? Is it something I can control? How?
I know this would work if I set those variables as system variables or if I opened VS developer prompt, the VS prompt compiled successfully, but I’m curious why this method doesn’t work.

I have also tried set(CMAKE_C_COMPILER arm-none-eabi-gcc CACHE INTERNAL "C Compiler") and set(ENV{CMAKE_C_COMPILER} arm-none-eabi-gcc), but these were just random ideas I found and thought might work. Any they didn’t.

Here is my full CMakeLists:

cmake_minimum_required(VERSION 3.22)

set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)

include(pico_sdk_import.cmake)

project(blink_test C CXX ASM)

pico_sdk_init()

add_executable(blink
	blink.c
	)

target_link_libraries(blink pico_stdlib)

pico_enable_stdio_usb(blink 1)
pico_enable_stdio_uart(blink 1)

pico_add_extra_outputs(blink)

Any help would be appreciated!

EDIT: After even more digging into it, I finally understand what’s wrong.
pioasm is not supposed to be compiled with ARM GCC, but it compiles into Windows executable! This is why it works in VS developer powershell, because I don’t have MSVC in my path.