[CMake] Can two executables share one object file?

Clark J. Wang dearvoid at gmail.com
Fri Jun 8 22:17:01 EDT 2007


Take the followling CMakeLists.txt as an example:

PROJECT(test)
SET(CMAKE_VERBOSE_MAKEFILE ON)
ADD_EXECUTABLE(hello1 main.c hello1.c)
ADD_EXECUTABLE(hello2 main.c hello2.c)

When running make, main.c will be compiled twice which is not neccessary. I
tried to write like this:

PROJECT(test)
SET(CMAKE_VERBOSE_MAKEFILE ON)
ADD_EXECUTABLE(hello1 main.c hello1.c)
ADD_EXECUTABLE(hello2 main.o hello2.c)  # use main.o instead of main.c

but it failed to cmake. So how can I let two executables share one single
object file?

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20070609/ff487c83/attachment.html


More information about the CMake mailing list