[CMake] Creating a library
David Doria
daviddoria at gmail.com
Wed Feb 18 12:30:29 EST 2009
If I have many executables in the same project (ie same CMakeLists.txt
file), it seems like I shouldn't have to do this:
set(Sources File1.cpp File1.cpp )
ADD_EXECUTABLE(Test1 Test1.cpp ${Sources})
ADD_EXECUTABLE(Test2 Test2.cpp ${Sources})
because it is compiling File1 and File2 twice when that is unnecessary.
So I tried to do this:
ADD_LIBRARY(MyLibs ${Sources})
ADD_EXECUTABLE(Test1 Test1.cpp)
TARGET_LINK_LIBRARIES(Test1 ${MyLibs})
ADD_EXECUTABLE(Test2 Test2.cpp)
TARGET_LINK_LIBRARIES(Test2 ${MyLibs})
But I get a whole bunch of linker errors - "Undefined reference to ..."
Have I done something wrong / how would I do this?
Thanks,
David
More information about the CMake
mailing list