[OE-core] cmake find_program and hosttools_dir

Michael Ho Michael.Ho at bmw.de
Wed Aug 14 15:05:14 UTC 2019


Hi all,

I wanted to ask what would be a good way to fix an issue with cmake
find_program and the tools listed in ASSUME_PROVIDED. I checked against the
Warrior branch and it seems that currently find_program does not search the
hosttools directory for programs because HOSTTOOLS_DIR is not listed in the
CMAKE_FIND_ROOT_PATH variable (in cmake.bbclass). This means if you call
find_program to get the path to the git binary, it will fail to find the
program. I've attached a minimal recipe and CMakeLists.txt to demonstrate.

If you attempt to compile the recipe, you'll see:
| CMake Error at CMakeLists.txt:6 (message):
|   No git binary found

If I modify the cmake.bbclass and add this directory to CMAKE_FIND_ROOT_PATH,
it still fails because by default it wants to only search in the
subdirectories bin and usr/bin. If I then modify base.bbclass to generate a
"bin" symlink in the hosttools directory that points back to the hosttools
directory, it is enough to trick cmake. I also found a second solution where
if I instead add a default definition to CMAKE_PROGRAM_PATH to include the
root directory, this works also. I've included this second fix in the patch
I've sent.

Is this a good solution or is there something I'm missing here?

Thanks.

Kind regards,
Michael Ho

$ cat files/CMakeLists.txt
cmake_minimum_required (VERSION 2.6)
project (Tutorial)

find_program(HOST_GIT git)
if(NOT HOST_GIT)
    message(FATAL_ERROR "No git binary found")
endif()

$ cat find-git.bb
SUMMARY = "Example recipe to test find_program and git-native"
LICENSE = "CLOSED"

DEPENDS = "git-native"

SRC_URI = "file://CMakeLists.txt"
S = "${WORKDIR}"

inherit cmake

do_install() {
    :
}


More information about the Openembedded-core mailing list