From: Eneas U de Queiroz Date: Fri, 20 Jun 2025 13:18:58 +0000 (-0300) Subject: cmake: set CMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F20656%2Fhead;p=thirdparty%2Fopenwrt.git 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 [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 --- diff --git a/include/cmake.mk b/include/cmake.mk index 699257506aa..b6e485eb4ff 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=: \