Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
251cc249
Commit
251cc249
authored
Jan 07, 2018
by
zhujiashun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support C++11 in low version of cmake & fix compatibility problem in cmake2.8
parent
0506a9d0
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
4 deletions
+21
-4
CMakeLists.txt
CMakeLists.txt
+18
-2
CMakeLists.txt
test/CMakeLists.txt
+2
-1
bthread_mutex_unittest.cpp
test/bthread_mutex_unittest.cpp
+1
-1
No files found.
CMakeLists.txt
View file @
251cc249
...
@@ -55,8 +55,6 @@ execute_process(
...
@@ -55,8 +55,6 @@ execute_process(
COMMAND bash -c
"git rev-parse --short HEAD | tr -d '
\n
'"
COMMAND bash -c
"git rev-parse --short HEAD | tr -d '
\n
'"
OUTPUT_VARIABLE BRPC_REVISION
OUTPUT_VARIABLE BRPC_REVISION
)
)
set
(
CMAKE_CXX_STANDARD 11
)
set
(
CMAKE_CXX_STANDARD_REQUIRED ON
)
set
(
CMAKE_CPP_FLAGS
"-DBRPC_WITH_GLOG=
${
WITH_GLOG_VAL
}
-DGFLAGS_NS=
${
GFLAGS_NS
}
"
)
set
(
CMAKE_CPP_FLAGS
"-DBRPC_WITH_GLOG=
${
WITH_GLOG_VAL
}
-DGFLAGS_NS=
${
GFLAGS_NS
}
"
)
set
(
CMAKE_CPP_FLAGS
"
${
CMAKE_CPP_FLAGS
}
-DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__= -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DBRPC_REVISION=
\\\"
${
BRPC_REVISION
}
\\\"
-D__STRICT_ANSI__"
)
set
(
CMAKE_CPP_FLAGS
"
${
CMAKE_CPP_FLAGS
}
-DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__= -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DBRPC_REVISION=
\\\"
${
BRPC_REVISION
}
\\\"
-D__STRICT_ANSI__"
)
...
@@ -64,6 +62,22 @@ set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} ${DEBUG_SYMBOL}")
...
@@ -64,6 +62,22 @@ set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} ${DEBUG_SYMBOL}")
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CPP_FLAGS
}
-O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CPP_FLAGS
}
-O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer"
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_CPP_FLAGS
}
-O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-unused-parameter -fno-omit-frame-pointer"
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_CPP_FLAGS
}
-O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-unused-parameter -fno-omit-frame-pointer"
)
macro
(
use_cxx11
)
if
(
CMAKE_VERSION VERSION_LESS
"3.1.3"
)
if
(
CMAKE_CXX_COMPILER_ID STREQUAL
"GNU"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=gnu++11"
)
endif
()
if
(
CMAKE_CXX_COMPILER_ID STREQUAL
"Clang"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=gnu++11"
)
endif
()
else
()
set
(
CMAKE_CXX_STANDARD 11
)
set
(
CMAKE_CXX_STANDARD_REQUIRED ON
)
endif
()
endmacro
(
use_cxx11
)
use_cxx11
()
if
(
CMAKE_CXX_COMPILER_ID STREQUAL
"GNU"
)
if
(
CMAKE_CXX_COMPILER_ID STREQUAL
"GNU"
)
#required by butil/crc32.cc to boost performance for 10x
#required by butil/crc32.cc to boost performance for 10x
if
(
NOT
(
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4
))
if
(
NOT
(
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4
))
...
@@ -75,6 +89,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
...
@@ -75,6 +89,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
endif
()
endif
()
include
(
FindProtobuf
)
include
(
FindProtobuf
)
include
(
FindThreads
)
find_path
(
LEVELDB_HEADER NAMES leveldb/db.h
)
find_path
(
LEVELDB_HEADER NAMES leveldb/db.h
)
find_library
(
LEVELDB_LIB NAMES leveldb
)
find_library
(
LEVELDB_LIB NAMES leveldb
)
...
@@ -98,6 +113,7 @@ set(DYNAMIC_LIB
...
@@ -98,6 +113,7 @@ set(DYNAMIC_LIB
${
PROTOBUF_LIBRARIES
}
${
PROTOBUF_LIBRARIES
}
${
LEVELDB_LIB
}
${
LEVELDB_LIB
}
${
PROTOC_LIB
}
${
PROTOC_LIB
}
${
CMAKE_THREAD_LIBS_INIT
}
rt
rt
ssl
ssl
crypto
crypto
...
...
test/CMakeLists.txt
View file @
251cc249
...
@@ -17,8 +17,9 @@ find_library(GTEST_LIB NAMES gtest)
...
@@ -17,8 +17,9 @@ find_library(GTEST_LIB NAMES gtest)
find_library
(
GTEST_MAIN_LIB NAMES gtest_main
)
find_library
(
GTEST_MAIN_LIB NAMES gtest_main
)
set
(
CMAKE_CPP_FLAGS
"-DBRPC_WITH_GLOG=
${
WITH_GLOG_VAL
}
-DGFLAGS_NS=
${
GFLAGS_NS
}
"
)
set
(
CMAKE_CPP_FLAGS
"-DBRPC_WITH_GLOG=
${
WITH_GLOG_VAL
}
-DGFLAGS_NS=
${
GFLAGS_NS
}
"
)
set
(
CMAKE_CPP_FLAGS
"
${
CMAKE_CPP_FLAGS
}
-DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__= -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DUNIT_TEST -Dprivate=public -Dprotected=public -DBVAR_NOT_LINK_DEFAULT_VARIABLES -include
${
CMAKE_SOURCE_DIR
}
/test/sstream_workaround.h"
)
set
(
CMAKE_CPP_FLAGS
"
${
CMAKE_CPP_FLAGS
}
-DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__= -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DUNIT_TEST -Dprivate=public -Dprotected=public -DBVAR_NOT_LINK_DEFAULT_VARIABLES -
D__STRICT_ANSI__ -
include
${
CMAKE_SOURCE_DIR
}
/test/sstream_workaround.h"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CPP_FLAGS
}
-O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CPP_FLAGS
}
-O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer"
)
use_cxx11
()
if
(
CMAKE_CXX_COMPILER_ID STREQUAL
"GNU"
)
if
(
CMAKE_CXX_COMPILER_ID STREQUAL
"GNU"
)
#required by butil/crc32.cc to boost performance for 10x
#required by butil/crc32.cc to boost performance for 10x
...
...
test/bthread_mutex_unittest.cpp
View file @
251cc249
...
@@ -166,7 +166,7 @@ void PerfTest(Mutex* mutex,
...
@@ -166,7 +166,7 @@ void PerfTest(Mutex* mutex,
g_started
=
false
;
g_started
=
false
;
g_stopped
=
false
;
g_stopped
=
false
;
ThreadId
threads
[
thread_num
];
ThreadId
threads
[
thread_num
];
PerfArgs
<
Mutex
>
args
[
thread_num
]
;
std
::
vector
<
PerfArgs
<
Mutex
>
>
args
(
thread_num
)
;
for
(
int
i
=
0
;
i
<
thread_num
;
++
i
)
{
for
(
int
i
=
0
;
i
<
thread_num
;
++
i
)
{
args
[
i
].
mutex
=
mutex
;
args
[
i
].
mutex
=
mutex
;
create_fn
(
&
threads
[
i
],
NULL
,
add_with_mutex
<
Mutex
>
,
&
args
[
i
]);
create_fn
(
&
threads
[
i
],
NULL
,
add_with_mutex
<
Mutex
>
,
&
args
[
i
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment