* cmake find_program and hosttools_dir
@ 2019-08-14 15:05 Michael Ho
2019-08-14 15:05 ` [PATCH] cmake.bbclass: add HOSTTOOLS_DIR to CMAKE_FIND_ROOT_PATH Michael Ho
2019-08-14 15:32 ` ✗ patchtest: failure for " Patchwork
0 siblings, 2 replies; 3+ messages in thread
From: Michael Ho @ 2019-08-14 15:05 UTC (permalink / raw)
To: openembedded-core
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() {
:
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] cmake.bbclass: add HOSTTOOLS_DIR to CMAKE_FIND_ROOT_PATH
2019-08-14 15:05 cmake find_program and hosttools_dir Michael Ho
@ 2019-08-14 15:05 ` Michael Ho
2019-08-14 15:32 ` ✗ patchtest: failure for " Patchwork
1 sibling, 0 replies; 3+ messages in thread
From: Michael Ho @ 2019-08-14 15:05 UTC (permalink / raw)
To: openembedded-core; +Cc: Michael Ho
The find_program command will fail if it is used on a tool that is listed in
ASSUME_PROVIDED. This is because these tools are in the hosttools directory
which is not listed in CMAKE_FIND_ROOT_PATH so cmake will not find them.
Adding the directory HOSTTOOLS_DIR to the CMAKE_FIND_ROOT_PATH variable fixes
the initial issue of needing to search for tools in ASSUME_PROVIDED.
Note that this change alone does not fix the issue because find_program will
by default only look into the subdirectories bin and usr/bin under the paths
in CMAKE_FIND_ROOT_PATH to find the programs and the hosttools directory has
instead the symlinks directly present without these subdirectories.
Set CMAKE_PROGRAM_PATH to by default include the root directory so
find_program can search the hosttools directory without needing the prefix
directories.
---
meta/classes/cmake.bbclass | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/meta/classes/cmake.bbclass b/meta/classes/cmake.bbclass
index d3f0d70..f41eb8d 100644
--- a/meta/classes/cmake.bbclass
+++ b/meta/classes/cmake.bbclass
@@ -99,11 +99,12 @@ set( CMAKE_CXX_LINK_FLAGS "${OECMAKE_CXX_LINK_FLAGS}" CACHE STRING "LDFLAGS" )
# only search in the paths provided so cmake doesnt pick
# up libraries and tools from the native build machine
-set( CMAKE_FIND_ROOT_PATH ${STAGING_DIR_HOST} ${STAGING_DIR_NATIVE} ${CROSS_DIR} ${OECMAKE_PERLNATIVE_DIR} ${OECMAKE_EXTRA_ROOT_PATH} ${EXTERNAL_TOOLCHAIN})
+set( CMAKE_FIND_ROOT_PATH ${STAGING_DIR_HOST} ${STAGING_DIR_NATIVE} ${CROSS_DIR} ${OECMAKE_PERLNATIVE_DIR} ${OECMAKE_EXTRA_ROOT_PATH} ${EXTERNAL_TOOLCHAIN} ${HOSTTOOLS_DIR})
set( CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ${OECMAKE_FIND_ROOT_PATH_MODE_PROGRAM} )
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
+set( CMAKE_PROGRAM_PATH "/" )
# Use qt.conf settings
set( ENV{QT_CONF_PATH} ${WORKDIR}/qt.conf )
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* ✗ patchtest: failure for cmake.bbclass: add HOSTTOOLS_DIR to CMAKE_FIND_ROOT_PATH
2019-08-14 15:05 cmake find_program and hosttools_dir Michael Ho
2019-08-14 15:05 ` [PATCH] cmake.bbclass: add HOSTTOOLS_DIR to CMAKE_FIND_ROOT_PATH Michael Ho
@ 2019-08-14 15:32 ` Patchwork
1 sibling, 0 replies; 3+ messages in thread
From: Patchwork @ 2019-08-14 15:32 UTC (permalink / raw)
To: Michael Ho; +Cc: openembedded-core
== Series Details ==
Series: cmake.bbclass: add HOSTTOOLS_DIR to CMAKE_FIND_ROOT_PATH
Revision: 1
URL : https://patchwork.openembedded.org/series/19273/
State : failure
== Summary ==
Thank you for submitting this patch series to OpenEmbedded Core. This is
an automated response. Several tests have been executed on the proposed
series by patchtest resulting in the following failures:
* Patch cmake.bbclass: add HOSTTOOLS_DIR to CMAKE_FIND_ROOT_PATH
Issue Patch is missing Signed-off-by [test_signed_off_by_presence]
Suggested fix Sign off the patch (either manually or with "git commit --amend -s")
If you believe any of these test results are incorrect, please reply to the
mailing list (openembedded-core@lists.openembedded.org) raising your concerns.
Otherwise we would appreciate you correcting the issues and submitting a new
version of the patchset if applicable. Please ensure you add/increment the
version number when sending the new version (i.e. [PATCH] -> [PATCH v2] ->
[PATCH v3] -> ...).
---
Guidelines: https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines
Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
Test suite: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-08-14 15:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-14 15:05 cmake find_program and hosttools_dir Michael Ho
2019-08-14 15:05 ` [PATCH] cmake.bbclass: add HOSTTOOLS_DIR to CMAKE_FIND_ROOT_PATH Michael Ho
2019-08-14 15:32 ` ✗ patchtest: failure for " Patchwork
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox