<div dir="ltr">Can you create a small, self-contained example that reproduces the problem? A bit more than trivial since imported targets are involved, but give it a go, it will help narrow down the problem. If you're able to do that, please then report this in the issue tracker and attach that example. Also include the build output highlighting where you believe the commands used are incorrect.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 8, 2017 at 3:40 PM, Robin Verschueren <span dir="ltr"><<a href="mailto:robin.verschueren@gmail.com" target="_blank">robin.verschueren@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I use the "Unix Makefiles" generator (on macOS), with clang and clang++ as compilers (XCode version 9).<br></div></div><div class="HOEnZb"><div class="h5"><br><div class="gmail_quote"><div dir="ltr">On Wed, 8 Nov 2017 at 03:47 Craig Scott <<a href="mailto:craig.scott@crascit.com" target="_blank">craig.scott@crascit.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 8, 2017 at 7:29 AM, Robin Verschueren <span dir="ltr"><<a href="mailto:robin.verschueren@gmail.com" target="_blank">robin.verschueren@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi there,<div><br></div><div>I'm building some C code into a library. The library needs to link to a C++ static library (IMPORTED target). I'm puzzled by the following:</div><div><ul><li>with BUILD_SHARED_LIBS=OFF (default), everything works as expected and CMake sees the C library as a "C++ library" (i.e. it uses the C++ compiler/linker to link the two libraries together into a static library).</li><li>with BUILD_SHARED_LIBS=ON however, CMake tries to link the C library to the C++ library with cc (clang in my case), and I get linker errors.</li></ul><div>My questions:</div></div><div><b><br></b></div><div><b>What mechanism does CMake use to determine the linker language, and why is it different in these two cases?</b> Is it because I want to link a shared library against a static library as opposed to two static ones? Or is BUILD_SHARED_LIBS a red herring? Does CMake have a notion of what linker language to use for IMPORTED targets?</div><div><br></div><div></div></div></blockquote></div><div class="gmail_extra"><br></div></div></div><div dir="ltr"><div class="gmail_extra">Can you confirm which CMake generator type you are using? If it is the Xcode generator, do you get the same behaviour building at the command line as you do from within the IDE? I only ask because your symptoms sound eerily familiar to a problem I've seen before where linking used a different launcher from the command line compared to the IDE (see the Xcode section of <a href="https://crascit.com/2016/04/09/using-ccache-with-cmake/" target="_blank">this article</a>).</div></div><div dir="ltr"><div class="gmail_extra"><br><br clear="all"><div><br></div>-- <br><div class="m_-8432578996169694162m_1937013971115122821gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Craig Scott<br><div>Melbourne, Australia</div><div><a href="https://crascit.com" target="_blank">https://crascit.com</a><br></div></div></div></div></div></div></div>
</div></div></blockquote></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Craig Scott<br><div>Melbourne, Australia</div><div><a href="https://crascit.com" target="_blank">https://crascit.com</a><br></div></div></div></div></div></div></div>
</div>