Skip to contentSkip to conversation

cmake: allow target names to be overridden

PATCH In review Ross Burton 2 participants 4 messages Jan 16, 2018 – Jan 17, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 cmake: allow target names to be overridden

Don't hardcode the targets used in do_compile and do_install, instead build "all" and "install" by default but respect OECMAKE_TARGET_COMPILE and OECMAKE_TARGET_INSTALL variables.

---
 meta/classes/cmake.bbclass | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
meta/classes/cmake.bbclass +7 -4
index a4079dab0d7..10c4edcf1a5 100644
@@ -34,6 +34,9 @@ EXTRA_OECMAKE_append = " ${PACKAGECONFIG_CONFARGS}"
 EXTRA_OECMAKE_BUILD_prepend_task-compile = "${PARALLEL_MAKE} "
 EXTRA_OECMAKE_BUILD_prepend_task-install = "${PARALLEL_MAKEINST} "
 
+OECMAKE_TARGET_COMPILE ?= "all"
+OECMAKE_TARGET_INSTALL ?= "install"
+
 FILES_${PN}-dev += "${libdir}/cmake ${datadir}/cmake"
 
 # CMake expects target architectures in the format of uname(2),
@@ -140,13 +143,13 @@ cmake_do_configure() {
 
 do_compile[progress] = "percent"
 cmake_do_compile()  {
-	bbnote VERBOSE=1 cmake --build '${B}' -- ${EXTRA_OECMAKE_BUILD}
-	VERBOSE=1 cmake --build '${B}' -- ${EXTRA_OECMAKE_BUILD}
+	bbnote VERBOSE=1 cmake --build '${B}' --target ${OECMAKE_TARGET_COMPILE} -- ${EXTRA_OECMAKE_BUILD}
+	VERBOSE=1 cmake --build '${B}' --target ${OECMAKE_TARGET_COMPILE} -- ${EXTRA_OECMAKE_BUILD}
 }
 
 cmake_do_install() {
-	bbnote DESTDIR='${D}' cmake --build '${B}' --target install -- ${EXTRA_OECMAKE_BUILD}
-	DESTDIR='${D}' cmake --build '${B}' --target install -- ${EXTRA_OECMAKE_BUILD}
+	bbnote DESTDIR='${D}' cmake --build '${B}' --target ${OECMAKE_TARGET_INSTALL} -- ${EXTRA_OECMAKE_BUILD}
+	DESTDIR='${D}' cmake --build '${B}' --target ${OECMAKE_TARGET_INSTALL} -- ${EXTRA_OECMAKE_BUILD}
 }
 
 EXPORT_FUNCTIONS do_configure do_compile do_install do_generate_toolchain_file
Signature · 1 line
2.11.0
#1 lore raw

PATCH 2/2 piglit: override install target name instead of do_install

Simply override the install target, instead of reimplementing do_install.

Apart from being neater, this also stops the recipe expecting that cmake is using the Make backend.

---
 meta/recipes-graphics/piglit/piglit_git.bb | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
meta/recipes-graphics/piglit/piglit_git.bb +1 -3
index 9471bd08c43..06c5021eb76 100644
@@ -41,9 +41,7 @@ do_configure_prepend() {
    fi
 }
 
-do_install() {
-	oe_runmake -C ${B} 'DESTDIR=${D}' install/strip
-}
+OECMAKE_TARGET_INSTALL = "install/strip"
 
 RDEPENDS_${PN} = "waffle python3 python3-mako python3-json \
 	python3-subprocess python3-misc python3-importlib \
Signature · 1 line
2.11.0
Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] piglit: override install target name instead of do_install

Quoted 6 lines · Ross Burton

Simply override the install target, instead of reimplementing do_install.

Apart from being neater, this also stops the recipe expecting that cmake is using the Make backend.

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750
Acked-by on v1 1/2
#3 lore raw
In reply to Ross Burton
Quoted 5 lines · Ross Burton

Don't hardcode the targets used in do_compile and do_install, instead build "all" and "install" by default but respect OECMAKE_TARGET_COMPILE and OECMAKE_TARGET_INSTALL variables.

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750