[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cmake
Subject:    [CMake] OBJECT libraries and INTERFACE_SOURCES
From:       Giovanni Funchal <gio () cloudnc ! co ! uk>
Date:       2016-12-08 16:43:25
Message-ID: CACs7uvZYuYw4PKdjogt588+p+Gkj3OjkLZCd=QsOYx2z=4vSaQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi,

The help page [1] mentions that:

> Although object libraries may not be named directly in calls to the
> target_link_libraries() command, they can be "linked" indirectly by
> using an Interface Library whose INTERFACE_SOURCES target property
> is set to name $<TARGET_OBJECTS:objlib>.

However, I was unable to get this to work. Doing this:

add_library(lib-obj OBJECT test.cpp)
add_library(lib INTERFACE)
add_dependencies(lib lib-obj)
set_target_properties(lib PROPERTIES INTERFACE_SOURCES
$<TARGET_OBJECTS:lib-obj>)

And then trying to specify lib in link_libraries of an executable yields an
error message "Cannot find source file: ... Tried extensions:... ".

Am I doing something wrong?

Thanks,
-- Giovanni

[1]
https://cmake.org/cmake/help/v3.6/manual/cmake-buildsystem.7.html#object-libraries

[Attachment #5 (text/html)]

<div dir="ltr"><div>Hi,</div><div><br></div><div>The help page [1] mentions \
that:</div><div><br></div><div>&gt; Although object libraries may not be named \
directly in calls to the</div><div>&gt; target_link_libraries() command, they can be \
"linked" indirectly by</div><div>&gt; using an Interface Library whose \
INTERFACE_SOURCES target property</div><div>&gt; is set to name \
$&lt;TARGET_OBJECTS:objlib&gt;.</div><div><br></div><div>However, I was unable to get \
this to work. Doing this:</div><div><br></div><div>add_library(lib-obj OBJECT \
test.cpp)</div><div>add_library(lib INTERFACE)</div><div>add_dependencies(lib \
lib-obj)</div><div>set_target_properties(lib PROPERTIES INTERFACE_SOURCES \
$&lt;TARGET_OBJECTS:lib-obj&gt;)</div><div><br></div><div>And then trying to specify \
lib in link_libraries of an executable yields an</div><div>error message &quot;Cannot \
find source file: ... Tried extensions:... &quot;.</div><div><br></div><div>Am I \
doing something wrong?</div><div><br></div><div>Thanks,</div><div>-- \
Giovanni</div><div><br></div><div>[1] <a \
href="https://cmake.org/cmake/help/v3.6/manual/cmake-buildsystem.7.html#object-librari \
es">https://cmake.org/cmake/help/v3.6/manual/cmake-buildsystem.7.html#object-libraries</a></div></div>




-- 

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



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic