Re: [CMake] include directories not found for object library

2018-05-16 Thread Robert Maynard
That is exactly how it will look.

On Wed, May 16, 2018 at 4:19 AM Miklos Espak  wrote:

> That's awesome, thanks a lot!
>
> So, it would look like this in my case then:
>
> target_link_libraries(baseapp PUBLIC dcmjpeg mylib1 mylib2)
>
> And the object library has to be added to the sources of the app1 and
> app2, like now. With other words, object libraries would be allowed on the
> left hand side of "target_link_libraries".
>
> This looks the most intuitive way, indeed.
>
> Cheers,
> Miklos
>
>
> On Tue, 15 May 2018 at 16:51, Robert Maynard 
> wrote:
>
>> This is scheduled to be fixed in the next release by allowing OBJECT
>> libraries to be used in target_link_libraries.
>>
>>
>>
>> On Tue, May 8, 2018 at 7:46 PM Miklos Espak  wrote:
>>
>>> Hi,
>>>
>>> I have an abstract class that I want to compile into many applications.
>>> Something like this:
>>>
>>> baseapp.h
>>> baseapp.cpp
>>> app1.h
>>> app1.cpp
>>> app2.h
>>> app2.cpp
>>> ...
>>>
>>> I thought of making an object library from baseapp because I want to
>>> compile it only once and it is used only internally.
>>>
>>> However, baseapp depends on other libraries, e.g. dcmjpeg, mylib1 and
>>> mylib2, and the include directories of these of these libraries are not
>>> found. For regular libraries and executables, the include directories are
>>> picked up from the target property of the linked libraries, but for object
>>> libraries you cannot specify target link libraries.
>>>
>>> I came up with this:
>>>
>>> add_library(baseapp OBJECT baseapp.h baseapp.cpp)
>>> target_include_directories(baseapp PUBLIC
>>>   $
>>>   $
>>>   $)
>>>
>>> This works, but it does not look too pretty to me.
>>>
>>> I am wondering if there is a more elegant way.
>>>
>>> E.g. would it be a good idea to propagate the include dirs with the
>>> add_dependencies command? E.g. instead of the above, one could write:
>>>
>>> add_dependencies(baseapp dcmjpeg mylib1 mylib2)
>>>
>>> Cheers,
>>> Miklos
>>>
>>> --
>>>
>>> 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:
>>> https://cmake.org/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:
> https://cmake.org/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:
https://cmake.org/mailman/listinfo/cmake


Re: [CMake] include directories not found for object library

2018-05-16 Thread Miklos Espak
That's awesome, thanks a lot!

So, it would look like this in my case then:

target_link_libraries(baseapp PUBLIC dcmjpeg mylib1 mylib2)

And the object library has to be added to the sources of the app1 and app2,
like now. With other words, object libraries would be allowed on the left
hand side of "target_link_libraries".

This looks the most intuitive way, indeed.

Cheers,
Miklos


On Tue, 15 May 2018 at 16:51, Robert Maynard 
wrote:

> This is scheduled to be fixed in the next release by allowing OBJECT
> libraries to be used in target_link_libraries.
>
>
>
> On Tue, May 8, 2018 at 7:46 PM Miklos Espak  wrote:
>
>> Hi,
>>
>> I have an abstract class that I want to compile into many applications.
>> Something like this:
>>
>> baseapp.h
>> baseapp.cpp
>> app1.h
>> app1.cpp
>> app2.h
>> app2.cpp
>> ...
>>
>> I thought of making an object library from baseapp because I want to
>> compile it only once and it is used only internally.
>>
>> However, baseapp depends on other libraries, e.g. dcmjpeg, mylib1 and
>> mylib2, and the include directories of these of these libraries are not
>> found. For regular libraries and executables, the include directories are
>> picked up from the target property of the linked libraries, but for object
>> libraries you cannot specify target link libraries.
>>
>> I came up with this:
>>
>> add_library(baseapp OBJECT baseapp.h baseapp.cpp)
>> target_include_directories(baseapp PUBLIC
>>   $
>>   $
>>   $)
>>
>> This works, but it does not look too pretty to me.
>>
>> I am wondering if there is a more elegant way.
>>
>> E.g. would it be a good idea to propagate the include dirs with the
>> add_dependencies command? E.g. instead of the above, one could write:
>>
>> add_dependencies(baseapp dcmjpeg mylib1 mylib2)
>>
>> Cheers,
>> Miklos
>>
>> --
>>
>> 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:
>> https://cmake.org/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:
https://cmake.org/mailman/listinfo/cmake


Re: [CMake] include directories not found for object library

2018-05-15 Thread Robert Maynard
This is scheduled to be fixed in the next release by allowing OBJECT
libraries to be used in target_link_libraries.



On Tue, May 8, 2018 at 7:46 PM Miklos Espak  wrote:

> Hi,
>
> I have an abstract class that I want to compile into many applications.
> Something like this:
>
> baseapp.h
> baseapp.cpp
> app1.h
> app1.cpp
> app2.h
> app2.cpp
> ...
>
> I thought of making an object library from baseapp because I want to
> compile it only once and it is used only internally.
>
> However, baseapp depends on other libraries, e.g. dcmjpeg, mylib1 and
> mylib2, and the include directories of these of these libraries are not
> found. For regular libraries and executables, the include directories are
> picked up from the target property of the linked libraries, but for object
> libraries you cannot specify target link libraries.
>
> I came up with this:
>
> add_library(baseapp OBJECT baseapp.h baseapp.cpp)
> target_include_directories(baseapp PUBLIC
>   $
>   $
>   $)
>
> This works, but it does not look too pretty to me.
>
> I am wondering if there is a more elegant way.
>
> E.g. would it be a good idea to propagate the include dirs with the
> add_dependencies command? E.g. instead of the above, one could write:
>
> add_dependencies(baseapp dcmjpeg mylib1 mylib2)
>
> Cheers,
> Miklos
>
> --
>
> 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:
> https://cmake.org/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:
https://cmake.org/mailman/listinfo/cmake