]> git.lyx.org Git - features.git/commitdiff
Improve llvm libc++ detection
authorGeorg Baum <baum@lyx.org>
Sun, 21 Dec 2014 16:23:56 +0000 (17:23 +0100)
committerGeorg Baum <baum@lyx.org>
Sun, 21 Dec 2014 16:26:21 +0000 (17:26 +0100)
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.

config/lyxinclude.m4
development/cmake/ConfigureChecks.cmake
development/cmake/config.h.cmake
src/support/debug.h
src/support/strfwd.h

index 815abab3e3d2a7acf2b2234415785d8ec2f315a0..33c59794162ebb9c0eff9e290876755ab6eb541a 100644 (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.
index ab9c820eb8f27d1fd6f9f10af0a5172865e9e8a0..0290c4d9e7ce83b16e98c916c0af8b7e65077de3 100644 (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)
index d096be750b0eee3e9bb554987f28ad6b89370618..ab95cfa4fb41b4236c70f459760d7df4458c2b29 100644 (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}
index 34258073b9bd7e64b26d25fc65ed40b7b6e3cdb1..f8ee6591b197e688c62b02d8d9db7ddbb9cc4a60 100644 (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;
index 94f2136403c121d25bf09ebd94eeb199426a2322..ee4888abd44e0dd05557571b1db91226e11fed29 100644 (file)
 #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