[CMake] MSVC7.1 static link question

Philip Lowman philip at yhbt.com
Thu Feb 12 22:36:51 EST 2009


On Thu, Feb 12, 2009 at 11:43 AM, Luigi Calori <l.calori at cineca.it> wrote:

> Philip Lowman ha scritto:
>
>>    add_library(baz STATIC IMPORTED)
>>    set_target_properties(baz PROPERTIES
>>       IMPORTED_LOCATION_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/libbaz.a
>>       IMPORTED_LOCATION_DEBUG   ${CMAKE_CURRENT_SOURCE_DIR}/libbazd.a)
>>
>>    add_library(bar STATIC IMPORTED)
>>    set_target_properties(bar PROPERTIES
>>       IMPORTED_LOCATION_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/libbar.a
>>       IMPORTED_LOCATION_DEBUG   ${CMAKE_CURRENT_SOURCE_DIR}/libbard.a
>>       IMPORTED_LINK_INTERFACE_LIBRARIES baz) # <-- dependency is here
>>
>>  I' ma bit confused, just to make clear: the proposed import method  are
> used in the  final projects that USES the libraries.
> by install(EXPORT) the needed code is hidden in a config--baz--cmake file
> that is evaluated inby the final project tha so does not have to rely on
> FindBAZ script.
> But effectively this is just a way to hide the fact that  the final project
>  links to both libbaz and libbar
>
> The specification of dependency lib as a STATIC_LIBRARY_FLAGS produce a
> bigger library tha has both baz and bar, and can be used straight, at least
> under VS7.1
>
> I appreciate the IMPORT and EXPORT stuff and will try to use that (could we
> use that also for the whole OpenSceneGraph itself ? what do you think
> Philip?)
> Nevertheless the STATIC_LIBRARY_FLAGS seems much simpler


Not to take things too off-topic, but I actually like the idea of building
libjpeg, libtiff, libpng, and even libfreetype within the OSG itself just
like VTK does, but building them only on Windows platforms (especially since
Kitware has already "CMakeified" them).  If Robert has concerns about
tarball size these could always be located in a separate tarball for
releases that Windows users would have to download separately.  For Linux,
though, I think it would be a mistake to build these libraries since 99% of
distributions have them anyways and they are well maintained with bugfixes
and security patches.

This would get you what you want on WIN32 anyways which is being able to use
the libraries statically while at the same time it would reduce the burden
on maintaining the 3rdPartyDeps solution for OSG for every possible way of
compiling with Visual Studio 7.1, 8.0, or 9.0 (and by the way, would you
like /MT or /MD with that?).

In regards to your question though,

IMPORT/EXPORT looks very interesting for CMake projects, but I really
haven't used it in this context yet or for importing external dependencies
(other than "bar" and "baz") to have an opinion on the matter.  :)   I think
Bill has some good points about portability.  I didn't completely understand
what you needed STATIC_LIBRARY_FLAGS for.  In fact part of me still doesn't
as I've never needed to clump static libraries together for convenience in
any of the projects I work on.

-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090212/bf18a122/attachment.htm>


More information about the CMake mailing list