[CMake] Globbing expression

Marcel Loose loose at astron.nl
Tue Jul 14 03:20:54 EDT 2009


Hi Arnaud,

You can't trigger the FILE(GLOB...) command during or prior to
compilation or linking. The FILE(GLOB...) is executed by CMake, when
CMake runs. The only way I can think of doing this is, indeed, to create
a custom command and invoke some kind of globbing command (be it a shell
script, you name it). I certainly do NOT recommend this!! For one,
because glob cannot match names of libraries that have not yet been
built, because the files don't yet exist!

If you've got your dependencies set up correctly, then you'll never run
into the problem of the need to link against a library that's not yet
built. Just use target_link_libraries() judiciously.

Best regards,
Marcel Loose.

On Mon, 2009-07-13 at 14:08 +0200, Arnaud Devalkeneer wrote:
> Thanks a lot Marcel.
> 
> Another should be :
> - make a second GLOB expression gathering all libraries you do not
> need 
> - make a LIST( REMOVE_ITEM FIRST_GLOB_RESULT SECOND_BLOG_RESULT)
> but I suspect your solution is much efficient...
> 
> One additionnal question : do you know how to trigger the GLOB command
> just before a link target handling.
> Because in my case, the GLOB command is running at the beginning of
> the compilation process, regardless 
> the fact that I need to link to some .so's that have not been built
> yet. 
> Is a custom target is a right way?
> 
> Thanks again,
> Arnaud.
> 
> 
> On Mon, Jul 13, 2009 at 10:58 AM, Marcel Loose <loose at astron.nl>
> wrote:
>         Hi Arnaud,
>         
>         Your mixing globbing with regular expressions. AFAIK it is not
>         possible
>         to do this with one statement. I would just glob for all *.so
>         files and
>         then use string(REGEX REPLACE ...) to replace occurrences of
>         '^libA.*
>         \.so' with an empty string.
>         
>         Best regards,
>         Marcel Loose.
>         
>         
>         On Mon, 2009-07-13 at 10:43 +0200, Arnaud Devalkeneer wrote:
>         > Hello everybody,
>         >
>         > I would like to know if there exists a way to find all files
>         in a
>         > directory with a custom file extension (e.g. *.so) except
>         files
>         > beginning by a
>         > custom string (here libA). For example I am using the line :
>         >
>         > FILE( GLOB RESULT path/[^libA]*.so )
>         >
>         > but the RESULT variable remains empty. Of cource I am sure
>         of *.so
>         > files existance in the path.
>         >
>         > Has anybody already tried to glob files in a directory,
>         excluding some
>         > file name patterns?
>         > Thank you in advance for your help.
>         >
>         > Enjoy Cmake,
>         > Arnaud.
>         >
>         
>         > _______________________________________________
>         > Powered by www.kitware.com
>         >
>         > Visit other Kitware open-source projects at
>         http://www.kitware.com/opensource/opensource.html
>         >
>         > Please keep messages on-topic and check the CMake FAQ at:
>         http://www.cmake.org/Wiki/CMake_FAQ
>         >
>         > Follow this link to subscribe/unsubscribe:
>         > http://www.cmake.org/mailman/listinfo/cmake
>         
> 



More information about the CMake mailing list