[prev in list] [next in list] [prev in thread] [next in thread]
List: cmake
Subject: Re: [CMake] Custom compile command?
From: Bill Hoffman <bill.hoffman () kitware ! com>
Date: 2009-06-04 20:57:22
Message-ID: 4A283532.8010305 () kitware ! com
[Download RAW message or body]
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:
>
Cool!
I used to love Xtrek! I wasted many hours playing that at GE in the
early 90's.
>
> 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
>
You could use configure_file to do this.
Something like this:
set(COMMANDS_TYPE DOG)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/commands.c.in
${CMAKE_CURRENT_BINARY_DIR}/commands_mars.c)
set(COMMANDS_TYPE PUCK)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/commands.c.in
${CMAKE_CURRENT_BINARY_DIR}/commands_puck.c)
Where commands.c.in looks like this:
#define ${COMMANDS_TYPE}
#include "${CMAKE_CURRENT_SOURCE_DIR}/commands.c"
add_library(mylib
${CMAKE_CURRENT_BINARY_DIR}/commands_mars.c
${CMAKE_CURRENT_BINARY_DIR}/commands_puck.c)
-Bill
_______________________________________________
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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic