Skip to content

Commit 7f728db

Browse files
committed
Merge pull request cpp-netlib#219 from skystrife/master-integration
Add ability to compile with clang without libc++.
2 parents a7e3c10 + 9c4fd2a commit 7f728db

File tree

5 files changed

+29
-10
lines changed

5 files changed

+29
-10
lines changed

CMakeLists.txt

+9-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ option( CPP-NETLIB_BUILD_TESTS "Build the unit tests." ON )
1212
option( CPP-NETLIB_BUILD_EXAMPLES "Build the examples using cpp-netlib." ON )
1313
option( CPP-NETLIB_ALWAYS_LOGGING "Allow cpp-netlib to log debug messages even in non-debug mode." OFF )
1414
option( CPP-NETLIB_DISABLE_LOGGING "Disable logging definitely, no logging code will be generated or compiled." OFF )
15+
option( CPP-NETLIB_DISABLE_LIBCXX "Disable using libc++ when compiling with clang." OFF )
1516

1617

1718
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
@@ -51,8 +52,13 @@ elseif(${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
5152
INCLUDE(CheckCXXCompilerFlag)
5253
CHECK_CXX_COMPILER_FLAG(-std=c++11 HAVE_STD11)
5354
if (HAVE_STD11)
54-
list(APPEND CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ -Wall")
55-
list(APPEND CMAKE_CXX_LINK_FLAGS "-std=c++11 -stdlib=libc++")
55+
if (CPP-NETLIB_DISABLE_LIBCXX)
56+
list(APPEND CMAKE_CXX_FLAGS "-std=c++11 -Wall")
57+
list(APPEND CMAKE_CXX_LINK_FLAGS "-std=c++11")
58+
else()
59+
list(APPEND CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ -Wall")
60+
list(APPEND CMAKE_CXX_LINK_FLAGS "-std=c++11 -stdlib=libc++")
61+
endif()
5662
else()
5763
message(FATAL_ERROR "No C++11 support for Clang version. Please upgrade Clang to a version supporting C++11.")
5864
endif()
@@ -81,6 +87,7 @@ message(STATUS " CPP-NETLIB_BUILD_TESTS: ${CPP-NETLIB_BUILD_TESTS}\t(Buil
8187
message(STATUS " CPP-NETLIB_BUILD_EXAMPLES: ${CPP-NETLIB_BUILD_EXAMPLES}\t(Build the examples using cpp-netlib: ON, OFF)")
8288
message(STATUS " CPP-NETLIB_ALWAYS_LOGGING: ${CPP-NETLIB_ALWAYS_LOGGING}\t(Allow cpp-netlib to log debug messages even in non-debug mode: ON, OFF)")
8389
message(STATUS " CPP-NETLIB_DISABLE_LOGGING: ${CPP-NETLIB_DISABLE_LOGGING}\t(Disable logging definitely, no logging code will be generated or compiled: ON, OFF)")
90+
message(STATUS " CPP-NETLIB_DISABLE_LIBCXX: ${CPP-NETLIB_DISABLE_LIBCXX}\t(Disable using libc++ when building with clang: ON, OFF)")
8491
message(STATUS "CMake build options selected:")
8592

8693
############################################################################

concurrency/src/CMakeLists.txt

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
99
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11")
1010
elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
1111
CHECK_CXX_COMPILER_FLAG(-std=c++11 HAVE_STD11)
12-
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11 -stdlib=libc++")
13-
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11 -stdlib=libc++")
12+
if (CPP-NETLIB_DISABLE_LIBCXX)
13+
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11")
14+
else()
15+
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11 -stdlib=libc++")
16+
endif()
1417
endif()
1518

1619
set(CPP-NETLIB_CONCURRENCY_SRCS thread_pool.cpp)

http/src/CMakeLists.txt

+5-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
2626
endif()
2727
elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
2828
CHECK_CXX_COMPILER_FLAG(-std=c++11 HAVE_STD11)
29-
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11 -stdlib=libc++")
30-
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11 -stdlib=libc++")
29+
if (CPP-NETLIB_DISABLE_LIBCXX)
30+
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11")
31+
else()
32+
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11 -stdlib=libc++")
33+
endif()
3134
endif()
3235

3336
set(CPP-NETLIB_HTTP_MESSAGE_SRCS http/request.cpp http/response.cpp)

logging/src/CMakeLists.txt

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
77
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11")
88
elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
99
CHECK_CXX_COMPILER_FLAG(-std=c++11 HAVE_STD11)
10-
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11 -stdlib=libc++")
11-
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11 -stdlib=libc++")
10+
if (CPP-NETLIB_DISABLE_LIBCXX)
11+
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11")
12+
else()
13+
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11 -stdlib=libc++")
14+
endif()
1215
endif()
1316

1417
include_directories(${CPP-NETLIB_SOURCE_DIR}/logging/src)

message/src/CMakeLists.txt

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
77
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11")
88
elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
99
CHECK_CXX_COMPILER_FLAG(-std=c++11 HAVE_STD11)
10-
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11 -stdlib=libc++")
11-
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11 -stdlib=libc++")
10+
if (CPP-NETLIB_DISABLE_LIBCXX)
11+
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11")
12+
else()
13+
set(CPP-NETLIB_CXXFLAGS "-Wall -std=c++11 -stdlib=libc++")
14+
endif()
1215
endif()
1316

1417
include_directories(${CPP-NETLIB_SOURCE_DIR}/uri/src ${CPP-NETLIB_SOURCE_DIR}/message/src)

0 commit comments

Comments
 (0)