From 481f09124ac1eae81dc56945ef4ce5b855be427d Mon Sep 17 00:00:00 2001 From: bbbgan <2893129936@qq.com> Date: Sat, 28 Oct 2023 19:32:28 +0800 Subject: [PATCH] make clang use libc++ instead of stdlibc++ --- CMakeLists.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ecaa43b2..a4cb530f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,15 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++20") add_compile_options(/utf-8) ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) else() -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pthread -g") + +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pthread -g -stdlib=libc++") +message(STATUS "link libc++") +else() +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pthread -g ") +message(STATUS "link libstdc++") +endif() + set(CMAKE_CXX_FLAGS_RELEASE "-O3") endif(MSVC) set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -ldl")