[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cmake
Subject:    Re: [CMake] [cmake-developers]  libc++ usage in CMake with Clang?
From:       Craig Scott <craig.scott () crascit ! com>
Date:       2018-08-21 23:40:36
Message-ID: CA+dygYmMo9WWR11y98QVBnc7+k-qooYgsUtk+F_WdqW_p__CxQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


On Wed, Aug 22, 2018 at 7:18 AM, Robert Dailey <rcdailey.lists@gmail.com>
wrote:

> On Tue, Aug 21, 2018 at 3:47 PM Craig Scott <craig.scott@crascit.com>
> wrote:
> > Excuse the brevity, but it sounds like you might be looking for the
> CXX_EXTENSIONS target property (sorry if I've misunderstood your problem,
> let me know why it isn't appropriate if so). See the following article for
> a more complete overview of this and related properties:
> >
> > https://crascit.com/2015/03/28/enabling-cxx11-in-cmake/
>
> Unfortunately that's not the same. Extensions manage C++ language
> features and STL capabilities, but -stdlib is for selecting an STL
> implementation, AFAIK. Such as GNU STL and LLVM STL (which is libc++
> to clang).
>

Sorry, yes I misunderstood your problem. After a little digging, it seems
like you probably shouldn't be using the -stdlib option on Linux
<https://stackoverflow.com/a/50407611/1938798> anyway. FWIW, for Android,
the roadmap
<https://android.googlesource.com/platform/ndk/+/master/docs/Roadmap.md> is
converging on a single STL implementation too.

Regarding your earlier comment:

I'll explain a bit why I'm asking. I noticed that for code bases that
> work on Android plus other UNIX platforms, they unconditionally
> specify `-stdlib=libc++`, however this doesn't work on Ubuntu by
> default, which uses gnu stl + gcc/clang. So  you get compiler errors.
> There's no way for me to "search" a platform to see if it is eligible
> for the libc++ flag, I simply have to either disable it completely or
> conditionally include it based on target platform and/or toolchain.
> None of these really address the root cause.

If you are trying to control which STL to use for Android builds,
CMake variables like CMAKE_ANDROID_STL_TYPE are probably the more
appropriate way to do that rather than hard-coding compiler flags.
This would also mean that non-Android builds won't be affected since
they would simply ignore that variable (and target properties it may
affect) and should then pick up the right STL implementation
automatically.The Android-specific variable would ideally be set in a
toolchain file rather than in the project itself.


-- 

Craig Scott
Melbourne, Australia
https://crascit.com

New book released: Professional CMake: A Practical Guide
<https://crascit.com/professional-cmake/>

[Attachment #5 (text/html)]

<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug \
22, 2018 at 7:18 AM, Robert Dailey <span dir="ltr">&lt;<a \
href="mailto:rcdailey.lists@gmail.com" \
target="_blank">rcdailey.lists@gmail.com</a>&gt;</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">On \
Tue, Aug 21, 2018 at 3:47 PM Craig Scott &lt;<a \
href="mailto:craig.scott@crascit.com">craig.scott@crascit.com</a>&gt; wrote:<br> &gt; \
Excuse the brevity, but it sounds like you might be looking for the CXX_EXTENSIONS \
target property (sorry if I&#39;ve misunderstood your problem, let me know why it \
isn&#39;t appropriate if so). See the following article for a more complete overview \
of this and related properties:<br> &gt;<br>
&gt; <a href="https://crascit.com/2015/03/28/enabling-cxx11-in-cmake/" \
rel="noreferrer" target="_blank">https://crascit.com/2015/03/<wbr>28/enabling-cxx11-in-cmake/</a><br>
 <br>
Unfortunately that&#39;s not the same. Extensions manage C++ language<br>
features and STL capabilities, but -stdlib is for selecting an STL<br>
implementation, AFAIK. Such as GNU STL and LLVM STL (which is libc++<br>
to clang).<br>
</blockquote></div><br>Sorry, yes I misunderstood your problem. After a little \
digging, it seems like you probably <a \
href="https://stackoverflow.com/a/50407611/1938798">shouldn&#39;t be using the \
-stdlib option on Linux</a> anyway. FWIW, for Android, the <a \
href="https://android.googlesource.com/platform/ndk/+/master/docs/Roadmap.md">roadmap</a> \
is converging on a single STL implementation too.</div><div \
class="gmail_extra"><br></div><div class="gmail_extra">Regarding your earlier \
comment:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><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">I&#39;ll \
explain a bit why I&#39;m asking. I noticed that for code bases that<br>work on \
Android plus other UNIX platforms, they unconditionally<br>specify `-stdlib=libc++`, \
however this doesn&#39;t work on Ubuntu by<br>default, which uses gnu stl + \
gcc/clang. So   you get compiler errors.<br>There&#39;s no way for me to \
&quot;search&quot; a platform to see if it is eligible<br>for the libc++ flag, I \
simply have to either disable it completely or<br>conditionally include it based on \
target platform and/or toolchain.<br>None of these really address the root \
cause.</blockquote><pre><font face="arial, helvetica, sans-serif">If you are trying \
to control which STL to use for Android builds, CMake variables like \
CMAKE_ANDROID_STL_TYPE are probably the more appropriate way to do that rather than \
hard-coding compiler flags. This would also mean that non-Android builds won&#39;t be \
affected since they would simply ignore that variable (and target properties it may \
affect) and should then pick up the right STL implementation automatically.The \
Android-specific variable would ideally be set in a toolchain file rather than in the \
project itself.</font></pre><pre><font face="arial, helvetica, \
sans-serif"><br></font><span \
style="font-family:arial,sans-serif;white-space:pre-wrap">-- </span><br></pre><div \
class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><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><br></div><div>New book \
released:  <a href="https://crascit.com/professional-cmake/" \
target="_blank">Professional CMake: A Practical \
Guide</a><br></div></div></div></div></div></div></div> </div></div>



-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: \
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information \
on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at \
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic