Improve llvm libc++ detection

The old detection did only work if CFLAGS contained -std=c++11, since ciso646
was only included for __cplusplus > 199711.
Thanks to Koernel for the cmake part.
This commit is contained in:
Georg Baum 2014-12-21 17:23:56 +01:00
parent 57941c83ea
commit 7796ad3a36
5 changed files with 27 additions and 20 deletions

View File

@ -185,6 +185,10 @@ AC_LANG_POP(C++)
if test $lyx_cv_lib_stdcxx = "yes" ; then
AC_DEFINE(STD_STRING_USES_COW, 1, [std::string uses copy-on-write])
else
if test $lyx_cv_prog_clang = "yes" ; then
AC_DEFINE(USE_LLVM_LIBCPP, 1, [use libc++ provided by llvm instead of GNU libstdc++])
fi
fi
### We might want to get or shut warnings.

View File

@ -139,16 +139,24 @@ check_cxx_source_compiles(
"
STD_STRING_USES_COW)
#get_filename_component(cxx_base "${CMAKE_CXX_COMPILER}" NAME_WE)
#if(cxx_base MATCHES "^clang(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\+\\+)?$")
# set(STD_STRING_USES_COW)
#else()
# if("${MINGW}")
# set(STD_STRING_USES_COW)
# else()
# set(STD_STRING_USES_COW 1)
# endif()
#endif()
check_cxx_source_compiles(
"
#ifndef __clang__
this is not clang
#endif
int main() {
return(0);
}
"
lyx_cv_prog_clang)
set(USE_LLVM_LIBCPP)
if(NOT STD_STRING_USES_COW)
if(lyx_cv_prog_clang)
# use libc++ provided by llvm instead of GNU libstdc++
set(USE_LLVM_LIBCPP 1)
endif()
endif()
if(LYX_USE_QT MATCHES "QT5")
if (Qt5X11Extras_FOUND)

View File

@ -63,6 +63,9 @@
// Define if std::string uses copy-on-write
#cmakedefine STD_STRING_USES_COW 1
// use libc++ provided by llvm instead of GNU libstdc++
#cmakedefine USE_LLVM_LIBCPP 1
#cmakedefine Z_PREFIX 1
${Include_used_spellchecker}

View File

@ -20,7 +20,7 @@
// Forward definitions do not work with libc++
// but ios_base has already been defined in strfwd
// if compiling with it
#ifndef _LIBCPP_VERSION
#ifndef USE_LLVM_LIBCPP
namespace std {
class ios_base;

View File

@ -13,14 +13,6 @@
#ifndef STRFWD_H
#define STRFWD_H
// This includes does nothing but defining _LIBCPP_VERSION
// if libc++ is used (rather than libstdc++) - we first
// check if we have at least a c++03 standard before
// including the file
#if (__cplusplus > 199711L)
#include <ciso646>
#endif
#ifdef USE_WCHAR_T
// Prefer this if possible because GNU libstdc++ has usable
@ -37,7 +29,7 @@ namespace lyx { typedef boost::uint32_t char_type; }
#endif
// Forward definitions do not work with libc++
#ifdef _LIBCPP_VERSION
#ifdef USE_LLVM_LIBCPP
#include <string>
#else