On Jun 4, 2009, at 4:18 PM, Bob Tanner wrote:
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 <tan...@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
Off the top of my head I might try the following flow:
configure_file( commands.c ${CURRENT_BINARY_DIR}/commands_mars.c
COPYONLY )
set_source_files_properties ({CURRENT_BINARY_DIR}/commands_mars.c
PROPERTIES
GENERATED TRUE
COMPILE_FLAGS("-DDOG") )
set (SRCS ${SRCS} {CURRENT_BINARY_DIR}/commands_mars.c )
... Repeat for other files
add_library (Foo ${SRCS} )
That might work (off the top of my head).
Using the configure_file command will make sure that any new changes
to commands.c will force a recopy of the file into the build directory.
HTH
Mike Jackson
endfor()
_______________________________________________
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://www.cmake.org/mailman/listinfo/cmake