[CMake] FIND_FILE in vector

William A. Hoffman billlist at nycap.rr.com
Fri Oct 21 09:44:14 EDT 2005


The trick is that double quoting something turns it into a single argument.
Before calling any command in cmake all variables with ; separated lists of
values are broken apart.

So 
SET(BAR a;b;c)
FIND_FILE(foo.h ${BAR})
is the same as:
FIND_FILE(foo.h a b c)

With a macro often times you do not want to have a variable number of arguments
(since cmake did not used to support them in macros), so to pass in a number of
variables you would use the double quotes to pass them in as only one argument.

So:
SET(BAR a;b;c)
FIND_FILE(foo.h "${BAR}")
is the same as:
FIND_FILE(foo.h "a;b;c")


-Bill


At 04:39 AM 10/21/2005, klaas.holwerda wrote:
>Hi Bill or is it William??
>
>This indeed works, but i like to understand why.
>Does Cmake Unwrap a vertor in seperate argument when not quoted?
>
>Is this mechanism the same for macros? Currently when i want to give a vector to a macro, i write "var;var2;var3".
>
>Where is the trick ? :-)
>
>Thanks for answering, and maybe some more explanation,
>
>Klaas
>
>William A. Hoffman wrote:
>
>>The double quotes are messing you up.
>>
>>Try:
>>FIND_FILE( VERSION_H wx/version.h ${WXWINDOWS_INCLUDE_DIRECTORIES} )
>>
>>-Bill
>> 
>
>
>_______________________________________________
>CMake mailing list
>CMake at cmake.org
>http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list