[CMake] Using cmake to build a static library

Cristobal Navarro axischire at gmail.com
Thu Sep 15 03:08:48 EDT 2011


have you looked at

"target_link_libraries" command??

not sure but worth giving it a try.

http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:target_link_libraries

best regards
Cristobal




On Thu, Sep 15, 2011 at 3:49 AM, Denis Carniel <
denis.carniel at loginpeople.com> wrote:

> Hi,
>
> I came across cmake few weeks ago as a very interesting way to build
> projects for multiple platforms. It allows us at work to use a common code
> base for multiple platforms without actual duplication which is really neat.
>
> Though we're facing an issue related to the fact cmake isn't the only tool
> involved in our build process. We have split our code between the core logic
> which is compiled in C++ for multiple platforms (windows x86 and x86_64, Mac
> OSX and in the future linux) then based on that core logic we would like to
> produce SDKs for each platform using their specific features (for easier
> integration in projects).
>
> The problem is the following: The core logic is meant to be a static
> library (.lib on windows, .a on Mac / Linux) and then another project should
> pick up that library and include it into an executable. That final project
> is (a) not linked with the original cmake project (b) potentially not even
> built by cmake. For those reasons we'd like that the generated static
> library include its own dependencies in order to avoid dragging a long list
> of dependencies, unfortunately that does not seem to be be case in the
> current state of things.
>
> If I set the type of my output to "SHARED" (through the "ADD_LIBRARY"
> command), I see all dependencies appear in the Visual Studio project and the
> produced DLL seems correct. Though if the type is set to "STATIC" (the one
> we want), the dependencies are simply not passed to the Visual Studio
> project (AdditionalDependencies & AdditionalLibraryDirectories are not set
> for VCLibrarianTool).
>
> Hence my overall question: How can I have cmake produce a static library in
> which dependencies are linked ?
>
> Thanks in advance for your help.
> Denis
>
> PS: I know DLLs work on windows but those are not an option, because of
> deployment constraints we need to produce a single executable file in the
> end.
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110915/a34266c1/attachment.htm>


More information about the CMake mailing list