<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 18, 2017, at 5:58 AM, Ben Boeckel <<a href="mailto:ben.boeckel@kitware.com" class="">ben.boeckel@kitware.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">On Wed, Jan 18, 2017 at 10:14:26 +0100, Nils Gladitz wrote:<br class=""><blockquote type="cite" class="">On 17.01.2017 23:25, Chris Bieneman wrote:<br class=""><blockquote type="cite" class="">Hello CMake-developers!<br class=""><br class="">In one of the LLVM sub-projects we have a problem where we need to <br class="">install object files, which doesn't seem like a particularly easy <br class="">task. I'm curious if anyone has any advice on how to approach this <br class="">problem.<br class=""><br class="">The patch is currently being reviewed here:<br class=""><a href="https://reviews.llvm.org/D28791" class="">https://reviews.llvm.org/D28791</a><br class=""><br class="">Since the object files have fairly simple compile commands our current <br class="">approach is to compile the files in custom commands, then use <br class="">install(FILES...). This is workable, but I'm wondering if there is a <br class="">better way. They do need to be object files, static archives would not <br class="">work because these specially named files are handled by linkers and <br class="">other tools that we don't control.<br class=""></blockquote><br class="">Also more of a workaround but perhaps you could create static libraries <br class="">but extract them with e.g. CMAKE_AR (toolchain specific) during either <br class="">installation e.g. install(CODE|SCRIPT) or as a POST_BUILD custom command.<br class=""></blockquote></div></div></blockquote><div><br class=""></div><div>We could consider this, but I'm not sure that this is really any simpler than what we're doing.</div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><br class="">This issue might be the best way to go:<br class=""><br class="">    <a href="https://gitlab.kitware.com/cmake/cmake/issues/15226" class="">https://gitlab.kitware.com/cmake/cmake/issues/15226</a><br class=""></div></div></blockquote><div><br class=""></div><div>If this allowed TARGET_OBJECTS to be used in the install(FILES ...) command, then we could create an object library and a custom install rule for the objects, which would be a lot cleaner.</div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><br class=""><blockquote type="cite" class="">An OBJECT library might be better suited in theory but I don't think it <br class="">currently allows installation and the location of the object files is <br class="">generator specific (and afair not always known to cmake).<br class="">By doing a manual extraction of the archive you'd be in control over <br class="">where the objects go.<br class=""></blockquote><br class="">Plus our plan for installing OBJECT libraries was to install them as<br class="">INTERFACE libraries, leaving the objects themselves behind. The idea is<br class="">to allow object libraries into target_link_libraries() for usage<br class="">requirements and to support exporting them as part of the build system<br class="">(an explicit $<TARGET_OBJECTS> would still be required to use their<br class="">objects due to issues with transitive linking causing duplicate symbols<br class="">if target_sources were used).<br class=""></div></div></blockquote><div><br class=""></div><div>Ah... that wouldn't work for us because we actually need the objects to be installed in the final product.</div><div><br class=""></div><div>Thanks!</div><div>-Chris</div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><br class="">--Ben<br class=""></div></div></blockquote></div><br class=""></body></html>