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.
On Tue, 15 May 2018 at 16:51, Robert Maynard <robert.mayn...@kitware.com>
> 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 <esp...@gmail.com> wrote:
>> I have an abstract class that I want to compile into many applications.
>> Something like this:
>> 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)
>> Powered by www.kitware.com
>> Please keep messages on-topic and check the CMake FAQ at:
>> 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
>> Follow this link to subscribe/unsubscribe:
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
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
Follow this link to subscribe/unsubscribe: