[CMake] OBJECT Library Type

Simone Atzeni satzeni at nvidia.com
Fri Feb 16 12:34:48 EST 2018


Hi,

I am trying to merge together two "OBJECT" libraries.
I am following the tutorial at: https://cmake.org/Wiki/CMake/Tutorials/Object_Library

However, in my case I have more level of folder nesting, and at the parent level I would like to merge two "OBJECT" libraries and only at the top I want to create the actual library.

I tried with:

add_library(common OBJECT "$<TARGET_OBJECTS:A> $<TARGET_OBJECTS:B> $<TARGET_OBJECTS:C>")

But I get the following error:

-----------------------------------------------------------------------------------------------------
CMake Error at lib/common/CMakeLists.txt:31 (add_library):
  OBJECT library "common" contains:

    file1.cpp.o
    file2.cpp.o
    file3.cpp.o
    ...

  but may contain only sources that compile, header files, and other files
  that would not affect linking of a normal library.

CMake Error at lib/common/CMakeLists.txt:31 (add_library):
  Only executables and non-OBJECT libraries may reference target objects.

What's the correct way to do this?

Thanks.
Simone


-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180216/fac00c31/attachment.html>


More information about the CMake mailing list