[CMake] shared and static libs with same rootname

Jorge Rodriguez jrodriguez at xvt.com
Mon Aug 14 16:57:56 EDT 2006


Brandon J. Van Every wrote:
> In any event, the *target* names must be unique.  For instance my 
> actual targets are chicken, libchicken, and libchicken-static.  You 
> use SET_TARGET_PROPERTIES to change what the OUTPUT_NAME name will 
> be.  I've attached the relevant sections of Chicken's CMakeLists.txt, 
> as they are a fairly clear example of CMake 2.4.3 naming problems and 
> workarounds on Windows.

I'm not building Cygwin or MinGW. So, I would have to do something like 
this?

ADD_LIBRARY(foo SHARED ${FooSources})
ADD_LIBRARY(foos STATIC ${FooSources})

SET_TARGET_PROPERTIES(foos PROPERTIES OUTPUT_NAME foo)

Won't that build all the sources twice?  That's not really optimal when 
there's no difference between the resulting object files. I'd rather it 
ran the linker twice, once for shared and once for static, with the same 
object files. Or maybe that's me being too optimistic?

Also, what if I turned around and did this:

ADD_EXECUTABLE(bar ${BarSources})
TARGET_LINK_LIBRARIES(bar foo)

Would it link against foo or foos?

-- 
Jorge Rodriguez
XVT Software Development
Email: jrodriguez at xvt.com
Phone: (919) 854-1800 x222




More information about the CMake mailing list