From edf22ba723066d80a223b2d04763ff1d22aa3a30 Mon Sep 17 00:00:00 2001 From: Kornel Benko Date: Mon, 8 Dec 2014 17:43:05 +0100 Subject: [PATCH] Cmake build: Detect clang and adapt definition of STD_STRING_USES_COW. --- CMakeLists.txt | 3 --- development/cmake/ConfigureChecks.cmake | 11 +++++++++++ development/cmake/config.h.cmake | 3 +++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8be95c709a..0db64f7341 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -259,13 +259,10 @@ if(UNIX OR MINGW) endif() set(LYX_GCC11_MODE "${CXX11_FLAG}") endif() - set(STD_STRING_USES_COW 1) else() if(MSVC10) set(LYX_USE_TR1 1) #set(LYX_USE_TR1_REGEX 1) #TODO should we use it in ECMAScript mode? - else() - set(STD_STRING_USES_COW 1) endif() endif() diff --git a/development/cmake/ConfigureChecks.cmake b/development/cmake/ConfigureChecks.cmake index 1c0215eeca..d7d3c8baaf 100644 --- a/development/cmake/ConfigureChecks.cmake +++ b/development/cmake/ConfigureChecks.cmake @@ -126,6 +126,17 @@ check_cxx_source_compiles( " LYX_CALLSTACK_PRINTING) +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() + if(LYX_USE_QT MATCHES "QT5") if (Qt5X11Extras_FOUND) get_target_property(_x11extra_prop Qt5::X11Extras IMPORTED_CONFIGURATIONS) diff --git a/development/cmake/config.h.cmake b/development/cmake/config.h.cmake index 51d97b1d4b..d096be750b 100644 --- a/development/cmake/config.h.cmake +++ b/development/cmake/config.h.cmake @@ -60,6 +60,9 @@ // Define if callstack can be printed #cmakedefine LYX_CALLSTACK_PRINTING 1 +// Define if std::string uses copy-on-write +#cmakedefine STD_STRING_USES_COW 1 + #cmakedefine Z_PREFIX 1 ${Include_used_spellchecker}