<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">Le mer. 5 sept. 2018 à 11:00, Daniel Eiband <<a href="mailto:daniel.eiband@brainlab.com">daniel.eiband@brainlab.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div lang="EN-US">
<div class="gmail-m_-7396755252699689645WordSection1">
<p class="MsoNormal"><span style="font-size:9pt;font-family:Arial,sans-serif;color:black">Hi,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9pt;font-family:Arial,sans-serif;color:black"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:9pt;font-family:Arial,sans-serif;color:black">I managed to solve the presentation of object libraries by renaming the targets and hiding certain targets in folders. I think this solution is acceptable.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9pt;font-family:Arial,sans-serif;color:black"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:9pt;font-family:Arial,sans-serif;color:black">The issue with the display of header only libraries in IDEs, which are implemented as interface libraries, is still unsolved. The add_library() command doesn’t accept
any sources. </span></p></div></div></blockquote><div><br></div><div>For an interface library you can add sources with</div><div><br></div><div>target_sources(yourlib INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/whatever.h)</div><div><br></div><div>You need the INTERFACE keyword though: <a href="https://cmake.org/cmake/help/latest/command/add_library.html#interface-libraries">https://cmake.org/cmake/help/latest/command/add_library.html#interface-libraries</a></div><div><br></div><div>is this not working for you?</div><div><br></div><div>Could you provide a strip-down archive which exhibit this issue I may try it on my side?</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="EN-US"><div class="gmail-m_-7396755252699689645WordSection1"><p class="MsoNormal"><span style="font-size:9pt;font-family:Arial,sans-serif;color:black">Also setting the SOURCES property of an interface library target is rejected by CMake. </span></p></div></div></blockquote><div><br></div><div>This is because you can only populate INTERFACE_SOURCES on an INTERFACE target:</div><div><a href="https://cmake.org/cmake/help/latest/prop_tgt/INTERFACE_SOURCES.html">https://cmake.org/cmake/help/latest/prop_tgt/INTERFACE_SOURCES.html</a><br></div><div><a href="https://cmake.org/cmake/help/latest/command/target_sources.html#command:target_sources">https://cmake.org/cmake/help/latest/command/target_sources.html#command:target_sources</a><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="EN-US"><div class="gmail-m_-7396755252699689645WordSection1"><p class="MsoNormal"><span style="font-size:9pt;font-family:Arial,sans-serif;color:black">I haven’t found any other way of adding the files to the interface library so that they are presented in the IDE.</span></p></div></div></blockquote><div><br></div><div>Like I said in a previous email on my side, interface library (INTERFACE) sources are displayed in vscode and qtcreator, may be the fact that they are not displayed by Visual Studio</div><div>is a Visual Studio bug?</div><div><br></div><div>By the way there is an old issue on this subject:</div><div><div><a href="https://gitlab.kitware.com/cmake/cmake/issues/15234">https://gitlab.kitware.com/cmake/cmake/issues/15234</a><br></div><br class="gmail-Apple-interchange-newline"></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="EN-US"><div class="gmail-m_-7396755252699689645WordSection1"><p class="MsoNormal"><span style="font-size:9pt;font-family:Arial,sans-serif;color:black"> I know the workaround of adding an empty custom
target. This is however not really satisfying, because Visual Studio for example displays them with a completely different icon and the suffix “(utility target)”. Doesn’t look like a C++ library any longer. It also sort of highlights the library because of
the non-C++ icon and I have to hide even more targets (the real interface libraries).<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9pt;font-family:Arial,sans-serif;color:black"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:9pt;font-family:Arial,sans-serif;color:black">From a CMake interface perspective this is also an asymmetry: Why can I add arbitrary files to executable and static/shared library targets being displayed in IDEs
without contributing to the build artifact while this is not possible for interface libraries? I think, the restriction on interface libraries should not be that they don’t have any source files. Interface libraries must not have source files which produce
build artifacts.</span></p></div></div></blockquote><div><br></div><div>Agreed and I think it would more "natural" to be able to simply</div><div>target_sources / add_library "as usual" and promote SOURCES to INTERFACE_SOURCES automatically since the target is an INTERFACE lib.<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="EN-US"><div class="gmail-m_-7396755252699689645WordSection1"><p class="MsoNormal"><span style="font-size:9pt;font-family:Arial,sans-serif;color:black"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9pt;font-family:Arial,sans-serif;color:black"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:9pt;font-family:Arial,sans-serif;color:black">Is this worth an enhancement bug or has this already been discussed?</span></p></div></div></blockquote><div><br></div><div>The only one I am aware of is this one:</div><div><a href="https://gitlab.kitware.com/cmake/cmake/issues/15234">https://gitlab.kitware.com/cmake/cmake/issues/15234</a></div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Eric<br></div></div></div></div></div></div>