MantisBT - CMake
View Issue Details
0003986CMakeCMakepublic2006-10-27 11:052016-06-10 14:21
Tristan Carel 
 
lowfeaturealways
closedfixed 
 
CMake 3.6CMake 3.6 
0003986: LIST(FILTER <list> <regex> [<regex> ...] [OUTPUT_VARIABLE <variable>])
SYNOPSIS:
LIST(FILTER <list> <regex> [<regex> ...] [OUTPUT_VARIABLE <variable>])

FILTER removes items from <list> which do not match any of the
specified regular expressions. An optional argument OUTPUT_VARIABLE
specifies a variable in which to store the matched items instead of
updating <list>.

Thank you
--
Tristan
No tags attached.
txt CMakeLists.txt (399) 2016-01-16 11:59
https://public.kitware.com/Bug/file/5613/CMakeLists.txt
Issue History
2007-08-21 13:38Alex NeundorfNote Added: 0008549
2007-08-21 13:38Alex NeundorfAssigned ToSystem Admin => Alex Neundorf
2007-08-21 13:38Alex NeundorfCategory => Test Category
2007-08-23 16:09Tristan CarelNote Added: 0008633
2007-08-23 16:26Alex NeundorfNote Added: 0008636
2007-09-01 03:55Tristan CarelNote Added: 0008798
2011-03-10 15:13Alex NeundorfNote Added: 0025741
2011-03-10 15:13Alex NeundorfAssigned ToAlex Neundorf =>
2011-03-10 15:13Alex NeundorfSummaryLIST(FILTER <list> <regex> [<regex> ...] [OUTPUT_VARIABLE <variable>]) => LIST(FILTER <list> <regex> [<regex> ...] [OUTPUT_VARIABLE <variable>])
2011-03-10 15:13Alex NeundorfDescription Updatedbug_revision_view_page.php?rev_id=241#r241
2011-03-10 15:25Alex NeundorfNote Added: 0025746
2011-03-10 15:25Alex NeundorfStatusassigned => backlog
2016-01-16 11:59Ashley WhetterFile Added: CMakeLists.txt
2016-01-16 12:01Ashley WhetterNote Added: 0040248
2016-01-17 17:11Ashley WhetterNote Added: 0040251
2016-02-03 11:18Brad KingNote Added: 0040432
2016-02-03 11:18Brad KingStatusbacklog => resolved
2016-02-03 11:18Brad KingResolutionopen => fixed
2016-02-03 11:18Brad KingFixed in Version => CMake 3.6
2016-02-03 11:18Brad KingTarget Version => CMake 3.6
2016-06-10 14:21Kitware RobotNote Added: 0041266
2016-06-10 14:21Kitware RobotStatusresolved => closed

Notes
(0008549)
Alex Neundorf   
2007-08-21 13:38   
What's the use case ?
(0008633)
Tristan Carel   
2007-08-23 16:09   
Do you want an example of how to use it or me to explain how useful it can be?


Here is an example to extract CPACK variables defined in environment:

---------------------------------------
GET_CMAKE_PROPERTY(cpack_variables VARIABLES)
LIST(FILTER cpack_variables "^CPACK.+")
---------------------------------------

or by using the optional parameter:
---------------------------------------
GET_CMAKE_PROPERTY(variables VARIABLES)
LIST(FILTER variables "^CPACK.+" OUTPUT_VARIABLE cpack_variables)
---------------------------------------

which is much more concise and lisible than doing is manually. Users don't have to filter lists manually with FOREACH statement anymore, which can be source of many errors. With several criteria, the code becomes as huge as repetitive.
The optional argument avoid user to make a copy before using the command in case he wants to keep the previous content.

Hope this answer the question
(0008636)
Alex Neundorf   
2007-08-23 16:26   
There are so many things which can be done with lists.
This sounds a bit very special.
Can't this be wrapped in a macro ?
(0008798)
Tristan Carel   
2007-09-01 03:55   
I wish list filtering to be a `real' CMake command as I believe this is a common operation.

Write a macro, and add it to the wiki (in http://cmake.org/WIKI/CMakeMacroListOperations [^]) is quiet useless because the rookie CMake user doesn't know about this page.
Maybe the solution would be to ease accessibility of this wiki page by adding the url in the official LIST documentation.
Also this would promote user contributions.
(0025741)
Alex Neundorf   
2011-03-10 15:13   
I don't feel like working on this, maybe somebody else picks it up.

(0025746)
Alex Neundorf   
2011-03-10 15:25   
The "backlog" status is intended to be used for this.

Alex
(0040248)
Ashley Whetter   
2016-01-16 12:01   
I'm about to submit a patch for this but if it's decided that using a macro would be more appropriate then I've uploaded a sample macro here that will do the same thing.
(0040251)
Ashley Whetter   
2016-01-17 17:11   
For reference, here is a link to the submitted patch: http://public.kitware.com/pipermail/cmake-developers/2016-January/027494.html [^]
(0040432)
Brad King   
2016-02-03 11:18   
I've applied the patch proposed here:

 http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/15496/focus=15606 [^]

as:

 list: Add FILTER subcommand
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0205f882 [^]
(0041266)
Kitware Robot   
2016-06-10 14:21   
This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.