Hi Patrick,

This looks to be another permutation on issue #14778
(https://gitlab.kitware.com/cmake/cmake/issues/14778). Unfortunately
currently you will need to manually propagate  the include/flags/etc
to the OBJECT library.

On Thu, Jul 21, 2016 at 5:30 AM, Patrick Boettcher
<patrick.boettc...@posteo.de> wrote:
> On Wed, 20 Jul 2016 13:49:52 -0400
> Robert Maynard <robert.mayn...@kitware.com> wrote:
>
>> Hi Patrick,
>>
>> Can you provide a simple example of what you are trying to do, and
>> where it is failing?
>
> -----
> add_library(lib1 STATIC <files>)
> target_include_directories(lib1 PUBLIC lib1-dir)
> target_compile_features(lib1 PUBLIC cxx_nonstatic_member_init)
> target_compile_definitions(lib1 PUBLIC FLAG)
>
> * lib2 and lib3 like lib1 *
>
> # runtime needs include-dirs of lib2 and lib3
> add_library(runtime OBJECT file1.cpp)
> target_link_libraries(runtime INTERFACE lib2 lib3) # fails
>
> # so I manually add them:
>
> target_include_directories(runtime PRIVATE
>    $<TARGET_PROPERTY:lib2,INTERFACE_INCLUDE_DIRECTORIES>)
> # and the same for target_compile_features and
> # the INTERFACE_COMPILE_FEATURES property - for all libraries.
>
> add_executable(exe exe1.cpp exe2.cpp $<TARGET_OBJECTS:runtime>)
> target_link_libraries(exe lib1 lib2 lib3)
>
> -----
>
> You might ask, why I need to make an object-library here. This is
> because of a problem I encounter on some platforms where the linking
> fails when runtime is a static library. In runtime there is a function
> which is required by lib2, on the problematic platforms the only way to
> be sure that the linker is not throwing away this function before it has
> been referenced, is by passing it as .o-file to the link-line.
>
> regards,
> --
> Patrick.
-- 

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 via email to