Re: [CMake] object-libraries and compile-dependencies to other target

2016-07-21 Thread Robert Maynard
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
 wrote:
> On Wed, 20 Jul 2016 13:49:52 -0400
> Robert Maynard  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 )
> 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
>$)
> # and the same for target_compile_features and
> # the INTERFACE_COMPILE_FEATURES property - for all libraries.
>
> add_executable(exe exe1.cpp exe2.cpp $)
> 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


Re: [CMake] object-libraries and compile-dependencies to other target

2016-07-21 Thread Patrick Boettcher
On Wed, 20 Jul 2016 13:49:52 -0400
Robert Maynard  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 )
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
   $)
# and the same for target_compile_features and
# the INTERFACE_COMPILE_FEATURES property - for all libraries.

add_executable(exe exe1.cpp exe2.cpp $)
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


Re: [CMake] object-libraries and compile-dependencies to other target

2016-07-20 Thread Robert Maynard
Hi Patrick,

Can you provide a simple example of what you are trying to do, and
where it is failing?

On Wed, Jul 20, 2016 at 8:29 AM, Patrick Boettcher
 wrote:
> Hi list,
>
> I'm using an object-library to generate a list of .o-files instead of
> archives which I use to link into several executable.
>
> Even though it is only an object-library it has compile-dependencies to
> other targets - this includes include-paths, compile-definitions and
> compile-features.
>
> I can't (or I don't know how) use target_link_libraries() with my
> object-library.
>
> What can I do to make it work? I'm exploring generator-expressions, but
> this seems redundant as I need to list all dependencies again.
>
> best 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
-- 

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