[CMake] static & shared library

William A. Hoffman billlist at nycap.rr.com
Wed Aug 3 14:04:35 EDT 2005


At 01:51 PM 8/3/2005, Brad King wrote:

>In CMake 2.2 this will probably not work.  The link line generated by the makefile generator now removes all possible names for a library (shared, static, versioned shared, etc.) before linking the final library.  The reason is that if someone using BUILD_SHARED_LIBS switches from shared to static then the static library will get built but unless the shared is removed then linking to the library will choose the out-of-date shared one.
It will work as long as you don't set LIBRARY_OUTPUT_PATH.   However, that being said,
if you are on windows it is impossible to have a shared and static with the same name
go into the same directory.   For the shared case foo.dll and foo.lib are created, and
for the static case foo.lib is created.  The two foo.lib files are very different.

-Bill



More information about the CMake mailing list