[CMake] Custom compile command?

Bob Tanner tanner at real-time.com
Thu Jun 4 16:18:25 EDT 2009


I'm moving an open source project (netrek) to cmake. Things are going 
great except for 1 fairly convoluted Makefile snippet listed below:


commands_mars.o: $(PMAKE) ${srcdir}/../ntserv/commands.c
        $(CC) $(CFLAGS) $(DEP) -DDOG -c ${srcdir}/../ntserv/commands.c 
-o commands_mars.o

commands_puck.o: $(PMAKE) ${srcdir}/../ntserv/commands.c
        $(CC) $(CFLAGS) $(DEP) -DPUCK -c ${srcdir}/../ntserv/commands.c 
-o commands_puck.o

commands.o: $(PMAKE) ${srcdir}/../ntserv/commands.c
        $(CC) $(CFLAGS) $(DEP) -c ${srcdir}/../ntserv/commands.c -o commands.o

commands_basep.o: $(PMAKE) ${srcdir}/../ntserv/commands.c
        $(CC) $(CFLAGS) $(DEP) -DBASEP -c 
${srcdir}/../ntserv/commands.c -o commands_basep.o


The Makefile takes the same .c file (../ntserv/commands.c) and compiles 
it multiple times passing in a different -D (-DDOG, -DPUCK) and 
outputting a different object file (-o commands_mars,
-o commands_puck).

How would I do this in cmake?

I looked at the ADD_CUSTOM_COMMAND but that doesn't seem the way to go.

Any advise?

Thanks.

-- 
Bob Tanner <tanner at real-time.com>                  | Phone : (952 943-8700
http://www.real-time.com, Linux, OSX, VMware | Fax   : (952)943-8500
Key fingerprint = F785 DDFC CF94 7CE8 AA87 3A9D 3895 26F1 0DDB E378




More information about the CMake mailing list