Re: [CMake] ARGC != list(LENGTH ARGV) and ARGV0 != list(GET ARGV 0)
CMake will not expand a string into a list when passed as arguments. It would do when using a variable: While this is true, it's also not the whole truth (and I guess is that this is bothering Clark). Consider the following two function calls: foo1(a;b;c) foo2(a;b c) Of course cmake recognises foo1 as having one parameter, and foo2 as having 2 parameters. And if you do use names arguments in your function, or access the function arguments by their positional arguments, it works as expected: function(foo2) message(Arg0: ${arg0}) # Arg0: a;b message(${ARGC} arguments.) # 2 Arguments. endfunction() If, however you try to access the argument list as a whole, you fall in the list of lists trap. CMake can not have lists as elements of other lists. Trying to use the ARGV or ARGN lists in the above example will not achieve what you are trying to do, because when cmake assembles the list of arguments, the (for lack of a better word) list property is lost: set(mylist) list(ADD mylist a;b) list(LENGTH mylist n) message( length is ${n}) # length is 2 Cheers, Johannes -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] ARGC != list(LENGTH ARGV) and ARGV0 != list(GET ARGV 0)
Am Freitag, 11. Oktober 2013, 12:07:58 schrieb Clark WANG: See following example: $ cmake --version cmake version 2.8.11.2 $ cat CMakeLists.txt cmake_minimum_required(VERSION 2.8) FUNCTION(foo) list(LENGTH ARGV argc) message(ARGC=${ARGC} list(LENGTH ARGV)=${argc}) list(GET ARGV 0 argv0) message(ARGV0=${ARGV0} list(GET ARGV 0)=${argv0}) ENDFUNCTION() foo(a;b;c) $ cmake . ARGC=1 list(LENGTH ARGV)=3 ARGV0=a;b;c list(GET ARGV 0)=a -- Configuring done -- Generating done -- Build files have been written to: /root/tmp $ I know ';' is special in cmake but it's counter-intuitive that ARGC != list(LENGTH ARGV). Is this a bug? CMake will not expand a string into a list when passed as arguments. It would do when using a variable: set(foovar a;b;c) foo(${foovar}) ARGC=3 list(LENGTH ARGV)=3 ARGV0=a list(GET ARGV 0)=a Eike signature.asc Description: This is a digitally signed message part. -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] ARGC != list(LENGTH ARGV) and ARGV0 != list(GET ARGV 0)
On Fri, Oct 11, 2013 at 2:20 PM, Rolf Eike Beer e...@sf-mail.de wrote: Am Freitag, 11. Oktober 2013, 12:07:58 schrieb Clark WANG: See following example: $ cmake --version cmake version 2.8.11.2 $ cat CMakeLists.txt cmake_minimum_required(VERSION 2.8) FUNCTION(foo) list(LENGTH ARGV argc) message(ARGC=${ARGC} list(LENGTH ARGV)=${argc}) list(GET ARGV 0 argv0) message(ARGV0=${ARGV0} list(GET ARGV 0)=${argv0}) ENDFUNCTION() foo(a;b;c) $ cmake . ARGC=1 list(LENGTH ARGV)=3 ARGV0=a;b;c list(GET ARGV 0)=a -- Configuring done -- Generating done -- Build files have been written to: /root/tmp $ I know ';' is special in cmake but it's counter-intuitive that ARGC != list(LENGTH ARGV). Is this a bug? CMake will not expand a string into a list when passed as arguments. Yes I know this. But after the literal string is passed to the function, it is broken into a list (ARGV). And the ARGC value is not consistent with the length of of ARGV which I've never seen in other languages. And this behavior makes it difficult to pass parameters around between cmake functions. It would do when using a variable: set(foovar a;b;c) foo(${foovar}) ARGC=3 list(LENGTH ARGV)=3 ARGV0=a list(GET ARGV 0)=a Eike -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] ARGC != list(LENGTH ARGV) and ARGV0 != list(GET ARGV 0)
On Fri, Oct 11, 2013 at 2:20 PM, Rolf Eike Beer e...@sf-mail.de wrote: Am Freitag, 11. Oktober 2013, 12:07:58 schrieb Clark WANG: See following example: $ cmake --version cmake version 2.8.11.2 $ cat CMakeLists.txt cmake_minimum_required(VERSION 2.8) FUNCTION(foo) list(LENGTH ARGV argc) message(ARGC=${ARGC} list(LENGTH ARGV)=${argc}) list(GET ARGV 0 argv0) message(ARGV0=${ARGV0} list(GET ARGV 0)=${argv0}) ENDFUNCTION() foo(a;b;c) $ cmake . ARGC=1 list(LENGTH ARGV)=3 ARGV0=a;b;c list(GET ARGV 0)=a -- Configuring done -- Generating done -- Build files have been written to: /root/tmp $ I know ';' is special in cmake but it's counter-intuitive that ARGC != list(LENGTH ARGV). Is this a bug? CMake will not expand a string into a list when passed as arguments. It would do when using a variable: set(foovar a;b;c) foo(${foovar}) It's not quite about using a variable or not. For your example, foo(${foovar}) would give the same result as mine. ARGC=3 list(LENGTH ARGV)=3 ARGV0=a list(GET ARGV 0)=a Eike -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] ARGC != list(LENGTH ARGV) and ARGV0 != list(GET ARGV 0)
Am Freitag, 11. Oktober 2013, 14:49:18 schrieb Clark WANG: On Fri, Oct 11, 2013 at 2:20 PM, Rolf Eike Beer e...@sf-mail.de wrote: Am Freitag, 11. Oktober 2013, 12:07:58 schrieb Clark WANG: See following example: $ cmake --version cmake version 2.8.11.2 $ cat CMakeLists.txt cmake_minimum_required(VERSION 2.8) FUNCTION(foo) list(LENGTH ARGV argc) message(ARGC=${ARGC} list(LENGTH ARGV)=${argc}) list(GET ARGV 0 argv0) message(ARGV0=${ARGV0} list(GET ARGV 0)=${argv0}) ENDFUNCTION() foo(a;b;c) $ cmake . ARGC=1 list(LENGTH ARGV)=3 ARGV0=a;b;c list(GET ARGV 0)=a -- Configuring done -- Generating done -- Build files have been written to: /root/tmp $ I know ';' is special in cmake but it's counter-intuitive that ARGC != list(LENGTH ARGV). Is this a bug? CMake will not expand a string into a list when passed as arguments. It would do when using a variable: set(foovar a;b;c) foo(${foovar}) It's not quite about using a variable or not. For your example, foo(${foovar}) would give the same result as mine. Yes, of course. And that's basically the whole point: by the quotes you tell CMake to interpret the stuff as string at this point. foo(a;b;c) should give your expected result, too. Eike -- signature.asc Description: This is a digitally signed message part. -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake