[CMake] Including an external object file (.o) into static shared library using MS Visual Studio generator

David Cole david.cole at kitware.com
Thu Feb 17 13:22:41 EST 2011


This was a known bug, and has been fixed in CMake 2.8.4.

See here for details if you want:
http://public.kitware.com/Bug/view.php?id=11459

Upgrade to CMake 2.8.4 and try again. Should work....


Cheers,
David


On Thu, Feb 17, 2011 at 12:59 PM, Chatterjee, Shash
<schatterjee at camber.com> wrote:
> Hi!
>
>
>
> I need to include a 3rd-party API, which comes without source, as an object
> (.o) file into a static library using CMake 2.8.3.  I know it is possible to
> add the .o when executables are linked, but that is not the preferred
> method.
>
>
>
> I have simply defined the .o file in the ADD_LIBRARY command.  This works
> under linux, and nmake (MS Visual Studio 10 /2010).  If I look in the
> cmake-generated build.make, CMake correctly recognizes the .o as an external
> dependency and defines a <libname>_EXTERNAL_OBJECTS variable in there, and
> it is listed at the tail end of objects1.rsp.  So far, so good!
>
>
>
> When using the “Visual Studio 10” generator, CMake adds the object file as a
> <ClInclude Include=”…..”/> XML element under a <ItemGroup> element that also
> lists all the source files as <ClCompile> elements for the static library
> project.  Of course the .o is not include in the lib when the project is
> built.  I can manually go into the project properties, and add it as an
> “Additional Dependencies” dependency for the Librarian, and that works.  Is
> there a way to get CMake to do this automatically?
>
>
>
> Thanks,
>
> Shash
>
> _______________________________________________
> 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
>


More information about the CMake mailing list