The following issue has been SUBMITTED. ====================================================================== http://public.kitware.com/Bug/view.php?id=14948 ====================================================================== Reported By: thokra Assigned To: ====================================================================== Project: CMake Issue ID: 14948 Category: CMake Reproducibility: always Severity: major Priority: normal Status: new ====================================================================== Date Submitted: 2014-06-03 06:42 EDT Last Modified: 2014-06-03 06:42 EDT ====================================================================== Summary: list() command does not work universally on implicitly defined lists (ARGN inside function) Description: While optimizing a large CMake based project I came across a problem involving lists and sub-commands of the list() command.
Suppose we have a macro(some_macro mandatoryArg [opt1[opt2...]]) to which we pass a large list of files and, sub-optimally, copy the entire list via set(newList ${ARGN}) so we are able to further process the resulting list using the list() command. This, depending on the current amount of entries, is obviously a costly operation which we want to get rid of. Also, we need to sort the list afterwards so the logical step is to invoke list(SORT newList) This all works, but seems unnecessary because we could just as well use a function and process ARGN directly. The problem is that some list() sub-commands work properly and others don't. For instance, determining the length of the list using list(LENGTH ARGN len) works. list(SORT ARGN) however generates an error message that the second argument needs to be a list. Using the above macro leads to, AFAICT, correct error messages being generated by either sub-command. I suppose the above is not intentional. Steps to Reproduce: macro(some_macro ARG1) list(LENGTH ARGN len) # generates an error message("Length: " ${len}) list(SORT ARGN) # generates an error endmacro() function(some_func ARG1) list(LENGTH ARGN len) message("Length: " ${len}) # reports the correct size of ARGN list(SORT ARGN) # generates an error, ARGN supposedly not a list endfunction() ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-06-03 06:42 thokra New Issue ====================================================================== -- 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://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers