[cmake-developers] [CMake] libc++ usage in CMake with Clang?

Craig Scott craig.scott at crascit.com
Tue Aug 21 16:47:56 EDT 2018


On Tue, Aug 21, 2018 at 11:41 PM, Robert Dailey <rcdailey.lists at gmail.com>
wrote:

> 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.
>
> I'm not even really sure what a find module for this would do... but
> typically find modules don't provide compiler flags, so I'm not sure
> if that's the right tool for the job. Would love to hear from the
> developers on this, so I've cross posted to the dev mailing list in
> this reply.
>


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/





> On Mon, Aug 20, 2018 at 10:05 PM Thompson, KT <kgt at lanl.gov> wrote:
> >
> > I'm also interested in the answer to Robert's question.  I've been using
> >
> >   set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -stdlib=libc++")
> >
> > but it seems like there should be a more elegant approach.
> >
> > -tk
> >
> > -----Original Message-----
> > From: CMake <cmake-bounces at cmake.org> On Behalf Of Robert Dailey
> > Sent: Monday, August 20, 2018 11:48 AM
> > To: CMake <cmake at cmake.org>
> > Subject: [CMake] libc++ usage in CMake with Clang?
> >
> > Is the only way to use libc++ to muck with compile flags? Or is there a
> proper find module for this or something? Is there a more CMake-esque way
> of specifying the STL library to use with the toolchain?
> > --
> >
> > 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
> --
>
> 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-developers
>



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

New book released: Professional CMake: A Practical Guide
<https://crascit.com/professional-cmake/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake-developers/attachments/20180822/c8a53c05/attachment-0001.html>


More information about the cmake-developers mailing list