[Omake] Propagating values
Aleksey Nogin
nogin at metaprl.org
Tue Feb 27 11:21:07 PST 2007
On 27.02.2007 11:01, Luis O'Shea wrote:
> Suppose I have a number of subprojects each of which is in charge of
> building a number of files. I would like to define a target (probably
> in the top level OMakefile) that builds everything. In order to do this
> the top level OMakefile needs to know the list of files that need to be
> built. The OMakefile in each subdir can append to a variable the files
> it wants built. My question is, how to propagate them up the hierarchy?
Luis,
While you can use a global variable and force propagation of its value
back up from the subprojects, there is no need to do that in this case.
As in a normal make, in OMake you can specify dependencies for a target
in several times in more than one place, and all those dependencies will
be appended together.
One minor thing is that targets that do not correspond to an actual file
should be specified as phony and the ".PHONY: foo" (or in your case
".PHONY: all") line should precede any usage of the target.
So, basically, you can use
.PHONY: all
.SUBDIRS: subproject_1 subproject_2
in the top-level OMakefile and then use the lines like
all: foo bar
in each of the subprojects' OMakefiles.
Aleksey
P.S. Note that there is a pre-defined phony target ".DEFAULT" that is
built by default when no targets are given to OMake explicitly. You can
also use the .DEFAULT target in place of your "all". And if you want the
set of files built by default to be smaller than the one included in
"all", you can do:
# Root OMakefile
.PHONY: all
all: .DEFAULT
.SUBDIRS: subproject_1 subproject_2
# subproject_1/OMakefile
all: foo # "omake all" will build foo, but simple "omake" will not
.DEFAULT: bar # both "omake all" and "omake" will build bar.
More information about the Omake
mailing list