zmkfirmware / zmk

ZMK Firmware Repository
https://zmk.dev/
MIT License
2.83k stars 2.86k forks source link

Building on Windows with Studio enabled results in false positive protoc not found error #2629

Open joelspadin opened 2 weeks ago

joelspadin commented 2 weeks ago

When building on windows with CONFIG_ZMK_STUDIO enabled, zephyr/modules/nanopb/nanopb.cmake will cause a fatal error on line 11 saying "'protoc' not found" unless protoc is installed and in the PATH, even though we are going to use the one provided by nanopb anyways. This is because it separately tries to find_program() protoc, and it does not search in nanopb.

The latest version of this file in Zephyr corrects this issue. It uses this instead, which loads the nanopb package and then checks if it found protoc:

find_package(Nanopb REQUIRED)

if(NOT PROTOBUF_PROTOC_EXECUTABLE)
  message(FATAL_ERROR "'protoc' not found, please ensure protoc is installed\
and in path. See https://docs.zephyrproject.org/latest/samples/modules/nanopb/README.html")
else()
  message(STATUS "Found protoc: ${PROTOBUF_PROTOC_EXECUTABLE}")
endif()