[CMake] Why are object files built several times?
Dizzy
dizzy at roedu.net
Wed Sep 26 08:13:38 EDT 2007
On Wednesday 26 September 2007 14:55:52 Joachim Ziegler wrote:
> Hello,
>
> I have two targets that have nearly the same sources:
>
> ADD_EXECUTABLE(startCompletionServer StartCompletionServer.cpp
> ${BASEFILES}) ADD_EXECUTABLE(test-adler32 test-adler32.cpp ${BASEFILES})
>
> I wonder why every object file belonging to the BASEFILES is built
> twice, once for the first target, once again for the second. This
> doubles my compile time!?
You will notice that cmake is building files inside a build directory
different for each target. So it is ment to be that way (normally you may
have different compile flags for different targets so you want that). If you
do not want that then just put your BASEFILES in a "convenience library" and
reuse it from both targets such as:
add_library(base ${BASEFILES})
add_executable(target1 target1.cpp)
target_link_libraries(target1 base)
add_executable(target2 target2.cpp)
target_link_libraries(target2 base)
--
Mihai RUSU Email: dizzy at roedu.net
"Linux is obsolete" -- AST
More information about the CMake
mailing list