[CMake] Executable depending on all source files
Russell Wallace
russell.wallace at gmail.com
Sat Aug 25 14:17:11 EDT 2012
No, you can type e.g. 'git add .' to add all newly created files to
the repository.
It is true that you do have to prompt git to do that, it won't go off
looking for new files on its own initiative. And I'm not expecting
cmake to go off looking for new files on its own initiative either; as
another poster observes, that could cause slowdown for very large
projects. I expect to have to prompt cmake about new files (by
cleaning up the build directory). But that's a very different thing
from trying to keep file lists in sync by hand!
On Sat, Aug 25, 2012 at 7:01 PM, Eric Noulard <eric.noulard at gmail.com> wrote:
> No sorry, I wasn't clear enough
> unless I'm wrong you can do:
>
> git add blah*.c
>
> but :
> 1) If you add an extra blah-whatever.c file after the git command
> then git won't handle the file.
>
> 2) When you manually suppress a file you still have to do
> git rm blah-whatever.c
>
> 3) In my example, git is not doing the globbing, the shell does.
> I know you can ask git to handle a pattern of file (and not the shell)
> but this like FILE(GLOB ...) for cmake
>
> My point is when file "appear" or "disappear" you have to *manually*
> inform git about it. Updating the list of source from within a CMakeLists.txt
> is exactly the same process.
>
>>> What you 'could do' is to craft some scripts (CMake or else) that
>>> may automagically update the extensive list of sources in your CMakeLists.txt.
>>> This script may be launched by a CMake custom target of yours, e.g.
>>> then you'll be able to do
>>>
>>> make up_src_list
>>>
>>> instead of editing the CMakeLists.txt manually,
>>
>> Sure, that would have been my fallback, treat CMakeLists.txt as object
>> code and write a Python script to maintain it automatically. But
>> adding an extra layer like that is strictly inferior to a solution
>> that works within CMake.
>
> You can write a CMake-script that create a FileList.cmake which
> contains only a variable definition:
> set(SOURCE_LIST blah.c toto.c)
>
> then in your CMakeLists.txt you do
>
> add_custom_target(GenSrcLst
> COMMAND ${CMAKE_COMMAND} -P YourScript.cmake)
>
> include(FileList.cmake)
> add_executable(YourExe ${SOURCE_LIST})
>
> that way your CMakeLists.txt is almost as before and
> you can find the way you want to re-generate FileList.cmake
> **when needed** with a
>
> make GenSrcLst
>
> without considering the whole CMakeLists.txt an "object file".
>
> All "within" CMake.
>
> I still don't find it "necessary" but it should work without too
> much manual edition.
>
> You will still need to git add / rm the files.
> --
> Erk
> Le gouvernement représentatif n'est pas la démocratie --
> http://www.le-message.org
More information about the CMake
mailing list