mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] [PATCH] add helper macro for simpler cmake options setting
@ 2015-11-06  9:10 Alexander Dahl
  0 siblings, 0 replies; only message in thread
From: Alexander Dahl @ 2015-11-06  9:10 UTC (permalink / raw)
  To: ptxdist

Background: while for autotools there are the ptx/endis, ptx/disen, and
ptx/wwo helpers, nothing comparable exists for cmake. For options
setting on cmake packages you can add those to FOO_CONF_OPT of your
package and currently there are for example those two ways:

ifdef PTXCONF_FOO_ENABLE_BAR
FOO_CONF_OPT += -DENABLE_BAR:BOOL=ON
else
FOO_CONF_OPT += -DENABLE_BAR:BOOL=OFF
endif

You could also use something shorter like:

FOO_CONF_OPT += -DENABLE_BAR=$(call ptx/ifdef, \
        PTXCONF_FOO_ENABLE_BAR, ON, OFF)

With the new helper macro this will be even easier:

FOO_CONF_OPT += -DENABLE_BAR=$(call ptx/onoff, PTXCONF_FOO_ENABLE_BAR)

Signed-off-by: Alexander Dahl <post@lespocky.de>
---
 rules/pre/000-option-disabled.make | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/rules/pre/000-option-disabled.make b/rules/pre/000-option-disabled.make
index c252bff..6eaecf7 100644
--- a/rules/pre/000-option-disabled.make
+++ b/rules/pre/000-option-disabled.make
@@ -87,4 +87,16 @@ define ptx/wwo
 $(call ptx/ifdef, $(1), with, without)
 endef
 
+
+#
+# $(call ptx/onoff, PTXCONF_SYMBOL) returns "ON" or "OFF"
+# depending on the symbol is defined or not
+#
+# $(call ptx/onoff, PTXCONF_SYMBOL)
+#                     $1
+#
+define ptx/onoff
+$(call ptx/ifdef, $(1), ON, OFF)
+endef
+
 # vim: syntax=make
-- 
2.1.4


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-11-06  9:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-06  9:10 [ptxdist] [PATCH] add helper macro for simpler cmake options setting Alexander Dahl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox