Globbing expression

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Globbing expression

Arnaud Devalkeneer
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Globbing expression

Marcel Loose
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

_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Globbing expression

Arnaud Devalkeneer
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 <[hidden email]> 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



_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Globbing expression

Tyler Roscoe
On Mon, Jul 13, 2009 at 02:08:29PM +0200, Arnaud Devalkeneer wrote:
> 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...

Yeah I would do it the way Marcel proposed.

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

First of all, using file(GLOB ...) to collect lists of files to process
is not a best practice because CMake then can't know if you've added or
removed files from this list and can't know if it needs to reprocess
your CMakeLists. Check the docs for more info.

Either way, if you know what those .so's are (and you obviously do since
you're going to build them), just add those names to your list of
libraries. If you just use the target name ("libfoo", not
"/path/to/libfoo.so"), CMake will figure out the path and any suffixes
or other shenanigans for you.

tyler
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Globbing expression

Marcel Loose
In reply to this post by Arnaud Devalkeneer
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 <[hidden email]>
> 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
>        
>

_______________________________________________
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
Loading...