<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I am trying to obey modern CMake target-based practices, with a twist that everything is available as an OBJECT library if desired. I have this working and can explain why if desired, but I feel it is extraneous for this question. What I create:<div class=""><br class=""></div><div class="">- mylib <- the main library</div><div class=""> - mylib_obj <- contains all of the actual objects for the library (OBJECT library)</div><div class=""> - mylib_interface <- linked with mylib</div><div class=""><br class=""></div><div class="">So it looks like this:<br class=""><div class=""><br class=""></div><div class=""> add_library(<b class="">mylib_obj OBJECT</b> "")</div><div class=""><b class=""> </b>add_library(<b class="">mylib_interface INTERFACE</b>)</div><div class=""><br class=""></div><div class="">Based on various options / settings, <b class="">target_sources(mylib_obj)</b> will be set and all of the various compiler operations etc. At the end, I have</div><div class=""><br class=""></div><div class=""> # MYLIB_LIBRARY_TYPE is either SHARED or STATIC</div><div class=""> add_library(<b class="">mylib</b> ${MYLIB_LIBRARY_TYPE} <b class="">$<TARGET_OBJECTS:mylib_obj></b>)</div><div class=""> target_link_libraries(<b class="">mylib mylib_interface</b>)</div><div class=""><br class=""></div><div class="">This works nicely, but internally I have to do the same operations for both <b class="">mylib_obj</b> and <b class="">mylib_interface</b>.</div><div class=""><br class=""></div><div class=""> target_include_directories(<b class="">mylib_obj PUBLIC</b> ${SomeLib_INCLUDE_DIRS})</div><div class=""> target_include_directories(<b class="">mylib_interface INTERFACE</b> ${SomeLib_INCLUDE_DIRS})</div><div class=""> target_link_libraries(<b class="">mylib_interface INTERFACE</b> ${SomeLib_LIBRARIES})</div><div class=""><b class=""><br class=""></b></div><div class="">Without <b class="">mylib_interface</b>, I cannot include the future linking information as well as include / compiler directive information will not be propagated with <b class="">target_link_libraries(something mylib)</b>. But <b class="">mylib_obj</b> also needs include information, etc. <b class="">But</b> I can’t do</div><div class=""><br class=""></div><div class=""> target_link_libraries(<b class="">mylib_obj mylib_interface</b>)</div><div class=""><b class=""><br class=""></b></div><div class="">because <b class="">mylib_obj</b> is an object library.</div><div class=""><br class=""></div><div class="">Is there a way to avoid having to set the same thing for both <b class="">mylib_obj</b> and <b class="">mylib_interface</b> given the requirement that <b class="">mylib_obj</b> is intended to house all of the actual objects?</div><div class=""><br class=""></div><div class="">Thank you for any guidance, I’m sorry if this question doesn’t make much sense. I’m trying to unlearn all of my outdated self-taught CMake!</div><div class=""><br class=""></div><div class="">-Stephen</div><div class=""><br class=""></div></div></body></html>