[ale] [OT] Any Eclipse and C users on the list

Michael Potter michael at potter.name
Fri Feb 1 10:26:21 EST 2013


Here is my question that I cannot find documented in CMake...

Is there a way to generate the dependencies from the source?

Specifically, if I have source that looks like this:

in dilbert.c:
#include "src/alice.h"
#include "src/wally.h"

Right now I have a hand coded bash script that generates
obj/dilbert.o: src/dilbert.c src/alice.h src/wally.h
   cc -o $@ src/dilbert.c

That way all I need to do is maintain the source and the tedious part
of maintaining the makefile is done for me.   The bash script is
sophisticated enough to handle recursion and ignoring some includes.
As slick as it is, I want to get of this system and move to main
stream scheme.

How does cmake eliminate that part of the makefile creation?

-- 
Michael Potter

On Wed, Jan 23, 2013 at 10:22 PM, Ryan Curtin <ryan at igglybob.com> wrote:
> On Tue, Jan 22, 2013 at 05:37:28PM -0500, Michael Potter wrote:
>> You are correct.
>> My ./configure is a hand written bash script.  It generates three things:
>> 1) A config.h that has #defines in it that define the operating system
>> specific and user preferences.
>>
>> 2) A config.sh that has variable defined.  I use ". config.sh" in the
>> bash scripts that are part of the package.
>>
>> 3) A ton of make files that are included in the hand coded makefiles.
>>
>> The makefile generator scans the .c files for "#include" then adds the
>> included file to the list of dependencies.
>>
>> It is a home grown system that works well, but it is not mainstream.
>> I want to move to a mainstream scheme.
>
> So, CMake should support what you are trying to do.  Or, at least, it
> will support (1) and (3), though I would recommend having the hand-coded
> makefiles generated automatically.  Keeping a build system simple and
> mainstream is good for long-term maintainability.
>
> (1) can be done with #cmakedefine and similar commands [1].  (2) should
> probably be adapted to use option() and then the user, when calling
> CMake, specifies which options they do and do not want enabled.  I can't
> provide advice for (3) because I am not entirely sure what the Makefiles
> are doing.  If they are just building source files, then it would be
> better to let CMake autogenerate those files.
>
> In addition, CMake does not only output Makefiles but will generate
> projects for Eclipse too [2].  Which is what you are looking for. :)
>
> I hope this is helpful information to at least survey what is out there.
> Let me know if I can help further.
>
> [1] http://www.cmake.org/Wiki/CMake:How_To_Write_Platform_Checks (an example)
> [2] http://www.cmake.org/Wiki/CMake_Generator_Specific_Information
>
> --
> Ryan Curtin       | "Don't fight it son. Confess quickly! If you hold out too
> ryan at igglybob.com | long you could jeopardize your credit rating."  - Guard
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo


More information about the Ale mailing list