<div dir="ltr"><div>The documentation states that OBJECT libraries "may not be [...] used in the</div><div>right hand side of target_link_libraries()".</div><div><br></div><div>However it turns out that they can't be used on the left hand side either:</div><div><br></div><div>    add_library(objlib OBJECT ...)</div><div>    target_link_libraries(objlib dep-of-objlib)</div><div><br></div><div>Result:</div><div><br></div><div>    CMake Error at CMakeLists.txt:13 (target_link_libraries):</div><div>      Object library target "objlib" may not link to anything.</div><div><br></div><div>This makes it impossible to concisely specify if an OBJECT library has a</div><div>dependency which is an IMPORTED library.</div><div><br></div><div>Only the legacy way works:</div><div><br></div><div>    add_library(objlib OBJECT ...)</div><div>    target_include_directories(objlib ${ZLIB_INCLUDE_DIRS})</div><div>    ...</div><div>    add_executable(maintarget $<TARGET_OBJECTS:objlib>)</div><div>    target_link_libraries(maintarget ${ZLIB_LIBRARIES})</div><div><br></div><div>But it would be convenient if this would also work:</div><div><br></div><div>    add_library(objlib OBJECT ...)</div><div>    target_link_libraries(objlib ZLIB::ZLIB)</div><div><br></div><div><br></div><div>Question:</div><div><br></div><div>Is this restriction, that an OBJECT library can't be on the left hand side of</div><div>target_link_libraries, is it a hard, final decision? Or is this issue</div><div>open for a possible improvement which would allow this and would forward</div><div>the link dependencies to the main target the OBJECT library is incorporated</div><div>into?</div><div><br></div><div>Tamas</div><div><br></div></div>