[cmake-developers] [CMake 0014948]: list() command does not work universally on implicitly defined lists (ARGN inside function)

Mantis Bug Tracker mantis at public.kitware.com
Tue Jun 3 06:42:39 EDT 2014


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                                    
======================================================================



More information about the cmake-developers mailing list