Referencing an OBJECT library

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Referencing an OBJECT library

Edward Diener
According to the CMake docs for an OBJECT library called, let's say,
'xxx', the reference to that OBJECT library is through
$<TARGET_OBJECTS:xxx>. I understand this but I am curious about the
reason for such syntax. After all a STATIC or SHARED library 'xxx' you
can just use xxx to refer to the library. Why the difference in CMake
syntax reference between OBJECT libraries added with the add_library
command and STATIC or SHARED libraries added with the add_library command ?

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Referencing an OBJECT library

Petr Kmoch
Hi Edward.

"the reference to that OBJECT library is through $<TARGET_OBJECTS:xxx>" - that is not quite true. When you're referring to the object library target itself (e.g. reading its properties), you use its name just like with any other target:

  get_property(someVar TARGET xxx PROPERTY TYPE)

However, the genex $<TARGET_OBJECTS:xxx> is used when you're specifying that the sources of another target yyy are to include the objects comprising the object library xxx:

  add_executable(yyy main.cpp $<TARGET_OBJECTS:xxx>)

Here, you're not dealing with the object library xxx itself, but with the objects from which it's composed, so you're referring to these objects explicitly. It's quite similar to how you'd use other properties of a target:

  target_sources(yyy $<TARGET_PROPERTY:xxx,SOURCES>)

would similarly add all sources of target xxx to the target yyy.

Petr

On 20 July 2017 at 22:57, Edward Diener <[hidden email]> wrote:
According to the CMake docs for an OBJECT library called, let's say, 'xxx', the reference to that OBJECT library is through $<TARGET_OBJECTS:xxx>. I understand this but I am curious about the reason for such syntax. After all a STATIC or SHARED library 'xxx' you can just use xxx to refer to the library. Why the difference in CMake syntax reference between OBJECT libraries added with the add_library command and STATIC or SHARED libraries added with the add_library command ?

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake