[cmake-developers] Safe source list GLOBs

Bill Hoffman bill.hoffman at kitware.com
Tue May 14 15:55:37 EDT 2013


Sorry for the top post...  :)

Globs simply do not work well for source files.   I don't think this 
will be come a module in CMake.

To have this work in a generic way, you would have to run something that 
did the glob with each time the build system was run, and be able to 
change the sources being compiled if something changed.   This would 
have to work with VS, make, ninja, Xcode, and all the other generators. 
   This module is very "make" centric and would only work for that 
generator, so I do not think we would want to include it in CMake proper.


-Bill


On 5/13/2013 8:42 PM, Wojciech Knapik wrote:
> On Mon, May 13, 2013 at 09:49:03AM -0400, Brad King wrote:
>
>> On 05/11/2013 11:09 PM, Wojciech Knapik wrote:
>>
>>> I recently ran into the issue of GLOBs being unsafe for source lists and
>>> wrote a very simple piece of code to fix the problem. A generalized
>>> version of that code is available here:
>>>
>>> https://github.com/wknapik/scm/blob/master/code/cmake/Modules/RegenerateSourceListGlobs.cmake
>>>
>>> It seems to work quite well, at least on Linux. If you guys think this
>>> is worth turning into an official module, I can make any changes
>>> deemed necessary. I'm not up for the maintainer role though.
>>
>> It looks like you're using a custom target to re-run CMake with
>> dependencies on the source directories themselves.
>
> Is it just me, or did that sound like Clippy ?;]
>
>> I think this is suitable as an example in a Wiki but not as an
>> official module.
>>
>> This would be much better done as a change to CMake's implementation.
>
> Oh, definitely. I'm not a C++ coder though, so I wrote a CMake module ;]
>
>> We already generate a rule to re-run CMake when CMakeLists.txt and
>> other files read by CMake change.  One could add an option to add
>> directories to the dependencies of that rule too.  Look for the
>> AddCMakeDependFile method for example.  If you go this route please
>> post a proposed interface here first before diving into the effort
>> of a patch.
>
> I hope someone does make the effort to implement this. Using GLOBs can
> reduce the size of your CMakeLists by an order of magnitude and is just
> so convenient...
>
>>> PS. The wiki page mentioned in Modules/readme.txt says you should send
>>> stuff like this to cmake-developers, but the email referred in the first
>>> sentence says you should send new module proposals to the cmake list. I
>>> guess the wiki could use an update.
>>
>> Which wiki page?  The module maintainer one is:
>>
>> http://www.cmake.org/Wiki/CMake:Module_Maintainers
>>
>> and that one says cmake-developers.
>
> The email linked in the first sentence - "Call for maintainers" - says
> "cmake at www.cmake.org".
>
> BTW, would you say the module is ok to use ? Do you see any problems
> with this implementation ? I need that feature, so I'm planning to rely
> on the module for the time being at least.
>
> thanks,
> WK
> --
>
> 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://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
>


-- 
Bill Hoffman
Kitware, Inc.
28 Corporate Drive
Clifton Park, NY 12065
bill.hoffman at kitware.com
http://www.kitware.com
518 881-4905 (Direct)
518 371-3971 x105
Fax (518) 371-4573



More information about the cmake-developers mailing list