cmake: set CMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER
authorEneas U de Queiroz <[email protected]>
Fri, 20 Jun 2025 13:18:58 +0000 (10:18 -0300)
committerChristian Marangi <[email protected]>
Wed, 5 Nov 2025 15:57:51 +0000 (16:57 +0100)
commite4956451353b744fe15312366a09b0d17832332d
tree1e0f5d1549ffc586377a924ca86015c69d074551
parentac7abe070a316533d18d399cb5cc7cafcf7cfe3a
cmake: set CMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER

According to CMake documentation[1]:

  [CMAKE_FIND_ROOT_PATH] is a list of directories that contain the
  target environment.

  [CMAKE_FIND_ROOT_PATH_MODE_PROGRAM] sets the default behavior for the
  find_program command.

  In most cases, find_program is used to search for an executable which
  will then be executed, e.g. using execute_process or
  add_custom_command. So in most cases an executable from the build host
  is required, so setting CMAKE_FIND_ROOT_PATH_MODE_PROGRAM to NEVER is
  normally preferred.

Since CMAKE_FIND_ROOT_PATH is set to the target staging dir, and the
toolchain root dir, it will find target programs before the host ones.

An example of this problem is if you try to build antiblock from the
packages feed after llvm from the video feeds is built.  Antiblock will
search for clang-format, pickup the target version, and fail to build.

Signed-off-by: Eneas U de Queiroz <[email protected]>
[1] https://cmake.org/cmake/help/book/mastering-cmake/chapter/Cross%20Compiling%20With%20CMake.html
Link: https://github.com/openwrt/openwrt/pull/20656
Signed-off-by: Christian Marangi <[email protected]>
include/cmake.mk