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

Chatterjee, Shash schatterjee at camber.com
Thu Feb 17 12:59:54 EST 2011


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110217/525707f1/attachment.htm>


More information about the CMake mailing list