[CMake] Diff output from CMake?

Eric Noulard eric.noulard at gmail.com
Tue Sep 13 16:53:26 EDT 2011


2011/9/13 Clifford Yapp <cliffyapp at gmail.com>:
>
>
> On Tue, Sep 13, 2011 at 1:58 PM, David Cole <david.cole at kitware.com> wrote:
>>
>> On Tue, Sep 13, 2011 at 1:39 PM, Alexander Neundorf
>> <a.neundorf-work at gmx.net> wrote:
>> > On Tuesday, September 13, 2011 05:07:00 AM Clifford Yapp wrote:
>> >> I am trying to compare two large lists of file paths (about 14,000
>> >> lines
>> >> each) to identify which entries in each list are missing from the
>> >> other,
>> >> and while I can get CMake to do it I must be doing it the wrong way
>> >> because the results are hideously slow.
>> >>
>> >> I currently generate two files with the paths and then read them in as
>> >> lists, using LIST() commands to peform STREQUAL tests.  I was hoping to
>> >
>> > How do you do that ?
>> > Do you iterate over one list using foreach() and then list(FIND) to
>> > check
>> > whether it exists in the other list ?
>
> I tried a couple of ways, most of them variations on that theme (BUILD_FILES
> and SVN_FILES are two manifest lists, and I need items from each list that
> are not in the other list)
>
> FOREACH(ITEM ${BUILD_FILES})
>      LIST(FIND ${ITEM} SVN_FILES POS)
>      IF(NOT POS STREQUAL "-1")
>         LIST(REMOVE_ITEM SVN_FILES ${ITEM})
>         LIST(REMOVE_ITEM BUILD_FILES ${ITEM})
>      ENDIF()
> ENDFOREACH()
>
> In essence, the idea is BUILD_FILES will end  up holding items unique to
> BUILD_FILES and SVN_FILES will end up holding items unique to SVN_FILES,
> which are the two pieces of information I'm after.

If  I understand it well you want to compute "symmetric difference".

Assuming BUILD_FILES and SVN_FILES initially contains  the whole list of names.
Then could you try:

set(BUILD_FILES_UNIQUE ${BUILD_FILES})
set(SVN_FILES_UNIQUE ${SVN_FILES})
list(REMOVE_ITEM BUILD_FILES_UNIQUE ${SVN_FILES})
list(REMOVE_ITEM SVN_FILES_UNIQUE ${BUILD_FILES})

I don't know about the performance of this with huge list but after that
BUILD_FILES_UNIQUE and SVN_FILES_UNIQUE should contains what you want.
at least it work on my small (attached) example.


-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: difflist.cmake
Type: text/x-cmake
Size: 408 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110913/b747b60a/attachment.bin>


More information about the CMake mailing list