Skip to content

Commit bc15dfb

Browse files
committed
Simplify clang support.
Cherry-pick: 2f6c9dc
1 parent c9961c9 commit bc15dfb

File tree

7 files changed

+12
-40
lines changed

7 files changed

+12
-40
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,4 @@ env:
1616
- BUILD_TYPE=debug
1717
- BUILD_TYPE=release
1818
script:
19-
- if [ "$CXX" == "clang++" ]; then patch -p1 < clang.diff; fi
2019
- ./build.sh

CMakeLists.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ if(NOT CMAKE_BUILD_TYPE)
88
set(CMAKE_BUILD_TYPE "Release")
99
endif()
1010

11+
option(MUDUO_BUILD_EXAMPLES ON)
12+
1113
set(CXX_FLAGS
1214
-g
1315
# -DVALGRIND
@@ -32,9 +34,16 @@ set(CXX_FLAGS
3234
if(CMAKE_BUILD_BITS EQUAL 32)
3335
list(APPEND CXX_FLAGS "-m32")
3436
endif()
37+
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
38+
list(APPEND CXX_FLAGS "-Wno-null-dereference")
39+
list(APPEND CXX_FLAGS "-Wno-sign-conversion")
40+
list(APPEND CXX_FLAGS "-Wno-unused-local-typedef")
41+
list(APPEND CXX_FLAGS "-Wno-unused-private-field")
42+
list(APPEND CXX_FLAGS "-Wthread-safety")
43+
list(REMOVE_ITEM CXX_FLAGS "-rdynamic")
44+
endif()
3545
string(REPLACE ";" " " CMAKE_CXX_FLAGS "${CXX_FLAGS}")
3646

37-
set(CMAKE_CXX_COMPILER "g++")
3847
set(CMAKE_CXX_FLAGS_DEBUG "-O0")
3948
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
4049
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
@@ -96,7 +105,7 @@ message(STATUS "CXX_FLAGS = " ${CMAKE_CXX_FLAGS} " " ${CMAKE_CXX_FLAGS_${BUILD_T
96105
add_subdirectory(muduo/base)
97106
add_subdirectory(muduo/net)
98107

99-
if(NOT MUDUO_BUILD_NO_EXAMPLES)
108+
if(MUDUO_BUILD_EXAMPLES)
100109
add_subdirectory(contrib)
101110
add_subdirectory(examples)
102111
else()

build.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ SOURCE_DIR=`pwd`
66
BUILD_DIR=${BUILD_DIR:-../build}
77
BUILD_TYPE=${BUILD_TYPE:-release}
88
INSTALL_DIR=${INSTALL_DIR:-../${BUILD_TYPE}-install-cpp11}
9-
BUILD_NO_EXAMPLES=${BUILD_NO_EXAMPLES:-0}
9+
CXX=${CXX:-g++}
1010

1111
ln -sf $BUILD_DIR/$BUILD_TYPE-cpp11/compile_commands.json
1212

@@ -15,7 +15,6 @@ mkdir -p $BUILD_DIR/$BUILD_TYPE-cpp11 \
1515
&& cmake \
1616
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
1717
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \
18-
-DMUDUO_BUILD_NO_EXAMPLES=$BUILD_NO_EXAMPLES \
1918
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
2019
$SOURCE_DIR \
2120
&& make $*

clang.diff

Lines changed: 0 additions & 35 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)