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
3f734296
Commit
3f734296
authored
Jan 06, 2018
by
zhujiashun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make example/echo_c++/CMakeLists.txt compiled alone
parent
55ca0ff0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
7 deletions
+58
-7
CMakeLists.txt
CMakeLists.txt
+0
-2
CMakeLists.txt
example/echo_c++/CMakeLists.txt
+58
-5
No files found.
CMakeLists.txt
View file @
3f734296
...
...
@@ -283,8 +283,6 @@ set(SOURCES
${
PROTO_SRCS
}
)
message
(
"SOURCES=
${
SOURCES
}
"
)
add_subdirectory
(
src
)
if
(
BUILD_EXAMPLE
)
add_subdirectory
(
example
)
...
...
example/echo_c++/CMakeLists.txt
View file @
3f734296
cmake_minimum_required
(
VERSION 2.8.10
)
project
(
echo_c++ C CXX
)
# if you want to specify the path of brpc header and lib,
# set the following two variables.
#set(CMAKE_INCLUDE_PATH /home/zjs/gitrepo/brpc/build)
#set(CMAKE_LIBRARY_PATH /home/zjs/gitrepo/brpc/build/lib)
option
(
EXAMPLE_LINK_SO
"Whether examples are linked dynamically"
OFF
)
set
(
CMAKE_CXX_STANDARD 11
)
set
(
CMAKE_CXX_STANDARD_REQUIRED ON
)
include
(
FindThreads
)
include
(
FindProtobuf
)
protobuf_generate_cpp
(
PROTO_SRC PROTO_HEADER echo.proto
)
get_filename_component
(
HEADER_DIR
${
PROTO_HEADER
}
DIRECTORY
)
include_directories
(
${
HEADER_DIR
}
)
set
(
CMAKE_CPP_FLAGS
"-DBRPC_WITH_GLOG=
${
WITH_GLOG_VAL
}
-DGFLAGS_NS=
${
GFLAGS_NS
}
"
)
find_path
(
BRPC_HEADER NAMES brpc/server.h
)
if
(
EXAMPLE_LINK_SO
)
find_library
(
BRPC_LIB NAMES brpc
)
else
()
find_library
(
BRPC_LIB NAMES libbrpc_static.a brpc
)
endif
()
include_directories
(
${
BRPC_HEADER
}
)
message
(
"BRPC_HEADER=
${
BRPC_HEADER
}
"
)
message
(
"BRPC_LIB=
${
BRPC_LIB
}
"
)
find_path
(
GFLAGS_INCLUDE_PATH gflags/gflags.h
)
find_library
(
GFLAGS_LIBRARY NAMES gflags libgflags
)
include_directories
(
${
GFLAGS_INCLUDE_PATH
}
)
execute_process
(
COMMAND bash -c
"grep
\"
namespace [_A-Za-z0-9]
\\
+ {
\"
${
GFLAGS_INCLUDE_PATH
}
/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '
\n
'"
OUTPUT_VARIABLE GFLAGS_NS
)
if
(
${
GFLAGS_NS
}
STREQUAL
"GFLAGS_NAMESPACE"
)
execute_process
(
COMMAND bash -c
"grep
\"
#define GFLAGS_NAMESPACE [_A-Za-z0-9]
\\
+
\"
${
GFLAGS_INCLUDE_PATH
}
/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '
\n
'"
OUTPUT_VARIABLE GFLAGS_NS
)
endif
()
set
(
CMAKE_CPP_FLAGS
"-DGFLAGS_NS=
${
GFLAGS_NS
}
"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CPP_FLAGS
}
-DNDEBUG -O2 -D__const__= -pipe -W -Wall -Wno-unused-parameter -fPIC -fno-omit-frame-pointer"
)
find_path
(
LEVELDB_HEADER NAMES leveldb/db.h
)
find_library
(
LEVELDB_LIB NAMES leveldb
)
include_directories
(
${
LEVELDB_HEADER
}
)
add_executable
(
echo_client client.cpp
${
PROTO_SRC
}
${
PROTO_HEADER
}
)
add_executable
(
echo_server server.cpp
${
PROTO_SRC
}
${
PROTO_HEADER
}
)
set
(
DYNAMIC_LIB
${
CMAKE_THREAD_LIBS_INIT
}
${
GFLAGS_LIBRARY
}
${
PROTOBUF_LIBRARIES
}
${
LEVELDB_LIB
}
ssl
crypto
dl
)
if
(
EXAMPLE_LINK_SO
)
target_link_libraries
(
echo_client
brpc
)
target_link_libraries
(
echo_server
brpc
)
target_link_libraries
(
echo_client
${
BRPC_LIB
}
${
DYNAMIC_LIB
}
)
target_link_libraries
(
echo_server
${
BRPC_LIB
}
${
DYNAMIC_LIB
}
)
else
()
target_link_libraries
(
echo_client
brpc_static
${
DYNAMIC_LIB
}
)
target_link_libraries
(
echo_server
brpc_static
${
DYNAMIC_LIB
}
)
target_link_libraries
(
echo_client
${
BRPC_LIB
}
${
DYNAMIC_LIB
}
)
target_link_libraries
(
echo_server
${
BRPC_LIB
}
${
DYNAMIC_LIB
}
)
endif
()
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