[openwrt/openwrt] cmake: set CMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER

LEDE Commits lede-commits at lists.infradead.org
Wed Nov 5 07:58:01 PST 2025


ansuel pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/e4956451353b744fe15312366a09b0d17832332d

commit e4956451353b744fe15312366a09b0d17832332d
Author: Eneas U de Queiroz <cotequeiroz at gmail.com>
AuthorDate: Fri Jun 20 10:18:58 2025 -0300

    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 <cotequeiroz at gmail.com>
    
    [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 <ansuelsmth at gmail.com>
---
 include/cmake.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/cmake.mk b/include/cmake.mk
index 699257506a..b6e485eb4f 100644
--- a/include/cmake.mk
+++ b/include/cmake.mk
@@ -113,7 +113,7 @@ define Build/Configure/Default
 			-DCMAKE_NM="$(CMAKE_NM)" \
 			-DCMAKE_RANLIB="$(CMAKE_RANLIB)" \
 			-DCMAKE_FIND_ROOT_PATH="$(CMAKE_FIND_ROOT_PATH)" \
-			-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=BOTH \
+			-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
 			-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
 			-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
 			-DCMAKE_STRIP=: \




More information about the lede-commits mailing list