Skip to content

Commit

Permalink
use libc++ if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
skypjack committed Feb 28, 2018
1 parent e822a5f commit 7a09f8a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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<type_traits> int main() { static_assert(std::is_same<int, int>::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")
Expand Down

0 comments on commit 7a09f8a

Please sign in to comment.