[CMake] automatically re-generating makefiles

Eric Noulard eric.noulard at gmail.com
Tue Mar 17 03:17:24 EDT 2009


2009/3/16 Matthew Woehlke <mw_triad at users.sourceforge.net>:
> Eric Noulard wrote:
>>
>> 2009/2/26 Alex Flint <alex.flint at gmail.com>:
>>>
>>> Hi there,
>>>
>>> I've noticed that when I run "make blah" then the makefile is
>>> automatically re-generated if I've changed anything in CMakeLists.txt
>>> since the last time I built "blah". However, if I add a new target to
>>> CMakeLists.txt then I have to run cmake manually or else I just get
>>> "to rule to make foo".
>>
>> I think this already works if you call
>> "make"
>> and not
>> "make foo"
>>
>> Because "existing target" do depends on "cmake_check_build_system"
>> which should check for CMakeLists.txt changes (not verified just a guess).
>
> Actually, it's supposed to be possible to make the makefile itself dependent
> on something.

You may be right but currently I do not see anything like a DIRECT
dependency between Makefile and CMakeLists.txt in the CMake
generated Makefile.

The dependency exists  (cmake_check_build_system)
but it is somehow "lazy", that is it is checked if
you try to build any **already existing** target and not when trying
to build a new target freshly added to a CMakeLists.txt.

> I think if this isn't working, either a: cmake isn't writing
> optimal dependencies for the makefiles themselves,

Optimal depends in which sense. With the current scheme
I would say that dependency is checked "almost always when needed",
with your propose scheme it would have to be checked
"always even if not needed", I would bet that unconditionnally checking
dependency for non-existing target may be "sub-optimal" because
it may cost you many unneeded check for rare case of needed checks.

I may be wrong, may be some CMake developer, expert in Unix Makefiles
generator dependency may shed the light on this?

> or b: 'make' could be doing better.

I would say that make is an almost stupid tool, it does not check
for unspecified dependency :-)

Current CMake generated Makefiles lacks some rule like:

Makefile : cmake_check_build_system

My point of view is, I don't think it would be worth the cost to add it.


-- 
Erk


More information about the CMake mailing list