]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
cmake: set CMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER 20656/head
authorEneas U de Queiroz <cotequeiroz@gmail.com>
Fri, 20 Jun 2025 13:18:58 +0000 (10:18 -0300)
committerChristian Marangi <ansuelsmth@gmail.com>
Wed, 5 Nov 2025 15:57:51 +0000 (16:57 +0100)
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@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@gmail.com>
include/cmake.mk

index 699257506aa21c40d510b216c5539e56decf2342..b6e485eb4ffe20a612707bf9cea7658ac7d349b9 100644 (file)
@@ -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=: \