globs case sensitivity depends on platform

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

globs case sensitivity depends on platform

πŸ‹ Jan Hegewald
Hi all,
I have some trouble with file globbing using the glob command like so:
        file(GLOB all_sources ${src_home}/*.F**)
the src_home contains files with uppercase and also some with lowercase suffixes, e.g. .F and .f (This makes an important difference to some Fortran compilers regarding the C preprocessor.).
Now the all_sources does not contain the same list of files on different platforms: On my Mac, the F* glob returns the F* and the f* files, whereas on linux it only returns the F* files.
I tested with a case sensitive filesystem on the Mac too, same result: uppercase and lowercase are returned.
The cmake on both tested systems is "cmake version 3.4.3".

My current solution is this:
        file(GLOB all_sources ${src_home}/*.F** ${src_home}/*.f**)
        list(REMOVE_DUPLICATES all_sources)

Am I missing something obvious here? Do you know a better workaround? I think this is an error with cmakes glob, where can I report it?

Many TIA,
Jan
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: globs case sensitivity depends on platform

Nils Gladitz-2
On 01/28/2016 12:56 PM, πŸ‹ Jan Hegewald wrote:
> Hi all,
> I have some trouble with file globbing using the glob command like so:
> file(GLOB all_sources ${src_home}/*.F**)

You might already be aware but CMake discourages using GLOB for source
files; though for different reasons (see Note in [1]).
Incidentally using explicit source file listings would work around this
issue as well.

Nils

[1] https://cmake.org/cmake/help/v3.4/command/file.html
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: globs case sensitivity depends on platform

πŸ‹ Jan Hegewald
Hi Nils,

> On 28.01.2016, at 13:39, Nils Gladitz <[hidden email]> wrote:
>
> You might already be aware but CMake discourages using GLOB for source files

yes, I read the docs before posting (:
Avoiding glob would be a workaround to my problem. But anyway I think that glob is broken if it produces different results on different platforms.

Cheers,
Jan
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: globs case sensitivity depends on platform

Andreas Pakulat-2
Hi Jan,

On Thu, Jan 28, 2016 at 2:35 PM, πŸ‹ Jan Hegewald <[hidden email]> wrote:
Hi Nils,

> On 28.01.2016, at 13:39, Nils Gladitz <[hidden email]> wrote:
>
> You might already be aware but CMake discourages using GLOB for source files

yes, I read the docs before posting (:
Avoiding glob would be a workaround to my problem. But anyway I think that glob is broken if it produces different results on different platforms.

I can't find any docs on cmake.org about what a globbing-expression is exactly, but the docs for file(glob) at least don't say anything about this function producing the same results on different platforms. In fact I'd be surprised if the behavior of the file(glob) function is different than using the same wildcards with ls/dir on a terminal.

The only bug that I can see from your description is that the behavior is inconsistent with different types of FS on OSX, that is definetly not matching above mentioned expectation.

Anyway, the right place to report bugs/problems isΒ https://public.kitware.com/Bug/my_view_page.php

Andreas

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: globs case sensitivity depends on platform

πŸ‹ Jan Hegewald
Hi Andreas,

> On 28.01.2016, at 16:43, Andreas Pakulat <[hidden email]> wrote:
>
> Hi Jan,
>
> On Thu, Jan 28, 2016 at 2:35 PM, πŸ‹ Jan Hegewald <[hidden email]> wrote:
> Hi Nils,
>
> > On 28.01.2016, at 13:39, Nils Gladitz <[hidden email]> wrote:
> >
> > You might already be aware but CMake discourages using GLOB for source files
>
> yes, I read the docs before posting (:
> Avoiding glob would be a workaround to my problem. But anyway I think that glob is broken if it produces different results on different platforms.
>
> I can't find any docs on cmake.org about what a globbing-expression is exactly, but the docs for file(glob) at least don't say anything about this function producing the same results on different platforms. In fact I'd be surprised if the behavior of the file(glob) function is different than using the same wildcards with ls/dir on a terminal.

the cmake glob is different from the results of a terminal ls.

>
> The only bug that I can see from your description is that the behavior is inconsistent with different types of FS on OSX, that is definetly not matching above mentioned expectation.

Maybe I was unclear about this, but cmake glob ignores the case regardless of the FS being case sensitive or not.

>
> Anyway, the right place to report bugs/problems is https://public.kitware.com/Bug/my_view_page.php

As you hinted at above, I am not really sure if this really is a bug (:

Cheers,
Jan
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: globs case sensitivity depends on platform

Andreas Pakulat-2
Hi Jan,

On Thu, Jan 28, 2016 at 4:52 PM, πŸ‹ Jan Hegewald <[hidden email]> wrote:
Hi Andreas,

> On 28.01.2016, at 16:43, Andreas Pakulat <[hidden email]> wrote:
>
> Hi Jan,
>
> On Thu, Jan 28, 2016 at 2:35 PM, πŸ‹ Jan Hegewald <[hidden email]> wrote:
> Hi Nils,
>
> > On 28.01.2016, at 13:39, Nils Gladitz <[hidden email]> wrote:
> >
> > You might already be aware but CMake discourages using GLOB for source files
>
> yes, I read the docs before posting (:
> Avoiding glob would be a workaround to my problem. But anyway I think that glob is broken if it produces different results on different platforms.
>
> I can't find any docs on cmake.org about what a globbing-expression is exactly, but the docs for file(glob) at least don't say anything about this function producing the same results on different platforms. In fact I'd be surprised if the behavior of the file(glob) function is different than using the same wildcards with ls/dir on a terminal.

the cmake glob is different from the results of a terminal ls

On the Mac apparently (based on your first mail)

> The only bug that I can see from your description is that the behavior is inconsistent with different types of FS on OSX, that is definetly not matching above mentioned expectation.

Maybe I was unclear about this, but cmake glob ignores the case regardless of the FS being case sensitive or not.

Now that contradicts your initial mail, you said there that on OSX you get F* and f* files for a case-insensitive filesystem, but on Linux you get only F*. But you also said that a case-sensitive filesystem on OSX still gives you F* and f* files, which in my eyes is a bug in the implementation.

I also just checked the CMake sources quickly and it seems that the glob-support is completely 'inhouse', meaning it does not call out to platform-specific functions (I guess that would explain the discrepancy on OSX).

So I guess asking for the same behavior across platforms is just as reasonable (given the logics are fully under CMake's control) as asking for it to reflect what a ls/dir would do on the corresponding platform.

I think a bugreport is the correct next step, even if it merely leads to a clarification of the behavior in the documentation.

Andreas

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: globs case sensitivity depends on platform

πŸ‹ Jan Hegewald
Hi Andreas,

thanks for bearing with me (-:

> On 28.01.2016, at 20:28, Andreas Pakulat <[hidden email]> wrote:
>
> Hi Jan,
>
> On Thu, Jan 28, 2016 at 4:52 PM, πŸ‹ Jan Hegewald <[hidden email]> wrote:
> Hi Andreas,
>
> > On 28.01.2016, at 16:43, Andreas Pakulat <[hidden email]> wrote:
> >
> > Hi Jan,
> >
> > On Thu, Jan 28, 2016 at 2:35 PM, πŸ‹ Jan Hegewald <[hidden email]> wrote:
> > Hi Nils,
> >
> > > On 28.01.2016, at 13:39, Nils Gladitz <[hidden email]> wrote:
> > >
> > > You might already be aware but CMake discourages using GLOB for source files
> >
> > yes, I read the docs before posting (:
> > Avoiding glob would be a workaround to my problem. But anyway I think that glob is broken if it produces different results on different platforms.
> >
> > I can't find any docs on cmake.org about what a globbing-expression is exactly, but the docs for file(glob) at least don't say anything about this function producing the same results on different platforms. In fact I'd be surprised if the behavior of the file(glob) function is different than using the same wildcards with ls/dir on a terminal.
>
> the cmake glob is different from the results of a terminal ls
>
> On the Mac apparently (based on your first mail)

Yes, on the Mac. ls behaves the same on both platforms.

>
> > The only bug that I can see from your description is that the behavior is inconsistent with different types of FS on OSX, that is definetly not matching above mentioned expectation.
>
> Maybe I was unclear about this, but cmake glob ignores the case regardless of the FS being case sensitive or not.
>
> Now that contradicts your initial mail, you said there that on OSX you get F* and f* files for a case-insensitive filesystem, but on Linux you get only F*. But you also said that a case-sensitive filesystem on OSX still gives you F* and f* files, which in my eyes is a bug in the implementation.

Yes. On the Mac I get the same unexpected results for case sensitive and case insensitive FS (i.e. glob returns files with different cases).

>
> I also just checked the CMake sources quickly and it seems that the glob-support is completely 'inhouse', meaning it does not call out to platform-specific functions (I guess that would explain the discrepancy on OSX).
>
> So I guess asking for the same behavior across platforms is just as reasonable (given the logics are fully under CMake's control) as asking for it to reflect what a ls/dir would do on the corresponding platform.
>
> I think a bugreport is the correct next step, even if it merely leads to a clarification of the behavior in the documentation.
>
> Andreas

OK, I did that: https://public.kitware.com/Bug/view.php?id=15941

FYI, regarding the specification of glob patterns there is https://public.kitware.com/Bug/view.php?id=8814

Best,
Jan

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake