2007/12/3, Hendrik Sattler <[EMAIL PROTECTED]>: > Quoting Oliver Dole <[EMAIL PROTECTED]>: > > The problem is that I use pkg-config (and stuff like that) to retrieve > > my libraries. So CMake does not know wether it is static or shared > > libraries to use. Nonetheless I have found a workaround thanks to this > > thread: http://www.cmake.org/pipermail/cmake/2006-September/011096.html > > So I have just added the following in my CMakeFiles: > > IF (NOT BUILD_SHARED_LIBS) > > SET (LIBRARIES_TO_LINK ${LIBRARIES_TO_LINK} -Wl,-Bstatic > > ${LIBXSLT_LIBS}) > > ELSE (NOT BUILD_SHARED_LIBS) > > SET (LIBRARIES_TO_LINK ${LIBRARIES_TO_LINK} ${LIBXSLT_LIBS}) > > ENDIF (NOT BUILD_SHARED_LIBS) > > Unfortunately I still have a problem, but which is not due to cmake. > > My application indirectly needs to link with -lgcc_s and I do not have > > the static library for that, so I get an error :'( > > Why do you try to work around that? Instead, do it properly by using > find_library: > pkg_check_modules ( PKGCONFIG_MYPREFIX something ) > foreach ( i ${PKGCONFIG_MYPREFIX_STATIC_LIBRARIES} ) > find_library ( ${i}_LIBRARY > NAMES ${i} > PATHS ${PKGCONFIG_MYPREFIX_LIBRARY_DIRS} > ) > list ( APPEND MYPREFIX_LIBRARIES ${i}_LIBRARY ); > endforeach ( i) > Actually, FindPkgConfig.cmake should be changed to give full paths to > libraries. > Also note, that you MUST use the pkgconfig variables for static > linking, not the ones for dynamic linking (see module help of > FindPkgConfig) > Ok thanks, I will have a look at this.
> I am sure that somehow this can be made to find only the static libs, > if not then that should be fixed. > OTOH, you may want to reconsider if you really want to give your users > so much pain :-/ RAM is cheap but not available for free. > > Additionally, building a static library does NOT mean that you have to > link everything statically. You'll regret such a decision sooner or > later. > Yes I know that static linking has more drawbacks than advantages. A typical example is that if someone fix a bug in a library my application is linked with, I will have to rebuild my whole application to have this fix propagate. Of course from my point of view static link is only a feature. But if that can be a real working feature, that's better. > HS > > > _______________________________________________ > CMake mailing list > CMake@cmake.org > http://www.cmake.org/mailman/listinfo/cmake > -- Olivier DOLE _______________________________________________ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake