[CMake] get_file_name_component - how to return true extension

Martin Guillon MGuillon at movea.com
Wed Feb 17 12:24:32 EST 2010


Just stumbled upon that problem. I have files like *.darwin.cpp
And get_filename_component returns  .darwin.cpp for the extension which is wrong!
The extension  is .cpp.

Let s take the example of toto.tar.gz. It s a gz file, not tar.gz file.  To  see why it s  wrong we can think of file association, which is most cases would associate .gz and not .tar.gz

Right now I use that regex "(\.[^\.]*)$" to get the right extension.

But I really think it should be corrected.

Martin
From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On Behalf Of Brian Davis
Sent: Wednesday, November 25, 2009 9:24 PM
To: cmake at cmake.org
Subject: [CMake] get_file_name_component - how to return true extension


for a given file of the form:

openssl-0.9.8a.tar.gz

I call as an example:

 get_filename_component( TAR_EXT openssl-0.9.8a.tar.gz EXT )

and I get for TAR_EXT

.9.1.tar.gz

Which is not quite what I was expecting.

I was expecting .gz and with successive calls I would get  .tar

Is there a mechanism in CMake for getting the trailing extension?

--
Brian J. Davis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100217/92b4a86d/attachment.htm>


More information about the CMake mailing list