From 7a09f8a9ab8714a92cdb6199737bdc4ac3261b70 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Wed, 28 Feb 2018 13:18:31 +0100 Subject: [PATCH] use libc++ if possible --- CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9da56005bc..66f31246ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,6 +45,16 @@ if(NOT MSVC) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DRELEASE") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g -DDEBUG") + include(CheckCXXSourceCompiles) + + set(CURR_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + check_cxx_source_compiles("#include int main() { static_assert(std::is_same::value, \"!\"); }" LIBCPP_FOUND) + + if(NOT LIBCPP_FOUND) + set(CMAKE_CXX_FLAGS "${CURR_CMAKE_CXX_FLAGS}") + endif() + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") # it seems that -O3 ruins the performance when using clang ... set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")