[CMake] add_custom_target dependency list issue
Andreas Pakulat
apaku at gmx.de
Sun Sep 26 17:30:59 EDT 2010
On 26.09.10 21:31:20, Szilárd Páll wrote:
> I figured out something that makes me even more puzzled. The following
> does _not_ work as expected::
>
> set(DEPS "dep1 dep2 dep3")
> add_dependencies(foo bar
> ${DEPS})
>
> Target "foo" gets only dependent on bar and not dep1,2,3. On the other
> hand, manually listing the latter instead of using the DEPS variable
> works as well as adding them one-by-one in a loop (where also a
> variables is used).
>
> This seems to be _extremely_counterintuitive! Is there some sort of
> CMake black-magic or basic rule that I don't know of?
No black magic, just cmake's rules about variable contents.
Basically CMake has only 1 type of variable value, thats a string. What
you created above is a string variable "DEPS" with the value "dep1 dep2
dep3", i.e. a single string consisting of 3 words separated by spaces.
Some strings are considered to be a list if you use a cmake command that
expects a list, these strings need to separate each list entry with a
semicolon.If you use
set(DEPS dep1 dep2 dep3)
then CMake will create DEPS as a string containing a list with those 3
words. What should also work is
set(DEPS "dep1;dep2;dep3")
as that should create a list in the variable DEPS.
The CMake Manual under the set() command also explains this.
Andreas
--
Your motives for doing whatever good deed you may have in mind will be
misinterpreted by somebody.
More information about the CMake
mailing list