Re: [CMake] list( LENGTH ) problem
Le Wed, 3 Dec 2008 10:09:56 -0600, "Robert Dailey" <[EMAIL PROTECTED]> a écrit : > On Tue, Dec 2, 2008 at 3:00 PM, Alexander Neundorf > <[EMAIL PROTECTED]>wrote: > > > It expects a variable which holds a list: > > > > set(myList foo bar) > > list( LENGTH myList listlen ) > > message( ${listlen} ) > > > > (didn't test or check docs, but I think that should be it) > > > Why did you do: > > list( LENGTH myList listlen ) > > instead of: > > list( LENGTH ${myList} listlen ) > > This seems pretty inconsistent with how I pass variables into > functions in other places, like message() for example. Nope it is consistent. "list" command is working on the "object" list whereas message is generally interested in the "value" of your "object". There is the same idea/issue/feature with "if" command which can work either on content (i.e. value) or on the variable itself (object). if(variable STRLESS string) if(string STRLESS string) I do attach a file for playing with value and object try to execute it with cmake -P playing_with_value_and_object.cmake. You may eventually find it interesting. -- Erk # classic VAR SET(VALUE "Value") SET(NAME "Name") # use value for VAR name SET(Toto.${VALUE} "another value") SET(Toto.${NAME} "nice name") # use those in message MESSAGE(VALUE=${VALUE}) MESSAGE(NAME=${NAME}) MESSAGE(Toto.${VALUE}=${Toto.${VALUE}}) MESSAGE(Toto.${NAME}=${Toto.${NAME}}) # Now with list SET(MyList1 a b c) SET(MyList2 a d) IF(UNIX) SET(C MyList1) ELSE(UNIX) SET(C MyList2) ENDIF(UNIX) LIST(LENGTH ${C} len) MESSAGE(len = ${len}) ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] list( LENGTH ) problem
On Tue, Dec 2, 2008 at 3:00 PM, Alexander Neundorf <[EMAIL PROTECTED]>wrote: > It expects a variable which holds a list: > > set(myList foo bar) > list( LENGTH myList listlen ) > message( ${listlen} ) > > (didn't test or check docs, but I think that should be it) Why did you do: list( LENGTH myList listlen ) instead of: list( LENGTH ${myList} listlen ) This seems pretty inconsistent with how I pass variables into functions in other places, like message() for example. ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] list( LENGTH ) problem
On Tuesday 02 December 2008, Robert Dailey wrote: > Hi, > > I execute the following CMake code: > > list( LENGTH "foo;bar" listlen ) > message( ${listlen} ) > > However, this results in the value "0" to be printed. I expect this to > print "2". What am I doing wrong? It expects a variable which holds a list: set(myList foo bar) list( LENGTH myList listlen ) message( ${listlen} ) (didn't test or check docs, but I think that should be it) Alex ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] list( LENGTH ) problem
Am Dienstag, 2. Dezember 2008 schrieb Robert Dailey: > Hi, > > I execute the following CMake code: > > list( LENGTH "foo;bar" listlen ) > message( ${listlen} ) > > However, this results in the value "0" to be printed. I expect this to > print "2". What am I doing wrong? list takes a list-name, so list( LENGTH "foo;bar" listlen ) looks for a list named "foo;bar", doesn't find it and sets listlen to 0. Try set(mylist "foo;bar") list(LENGTH mylist listlen) message(${listlen}) ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
[CMake] list( LENGTH ) problem
Hi, I execute the following CMake code: list( LENGTH "foo;bar" listlen ) message( ${listlen} ) However, this results in the value "0" to be printed. I expect this to print "2". What am I doing wrong? ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake