Skip to content

Commit

Permalink
fix compile
Browse files Browse the repository at this point in the history
  • Loading branch information
Dongsheng He committed Sep 27, 2023
1 parent bdc662d commit a4a51af
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 29 deletions.
7 changes: 3 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ set(CMAKE_C_FLAGS "${CMAKE_CPP_FLAGS} -O2 -pipe -Wall -W -fPIC -fstrict-aliasing
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=c++17")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
else()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
endmacro(use_cxx11)
Expand Down Expand Up @@ -241,7 +241,6 @@ if(WITH_BORINGSSL)
list(APPEND DYNAMIC_LIB ${BORINGSSL_CRYPTO_LIBRARY})
else()
list(APPEND DYNAMIC_LIB ${OPENSSL_CRYPTO_LIBRARY})

if(WITH_MESALINK)
list(APPEND DYNAMIC_LIB ${MESALINK_LIB})
else()
Expand Down
34 changes: 16 additions & 18 deletions example/http_c++/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@ find_library(THRIFT_LIB NAMES thrift)
if (NOT THRIFT_LIB)
set(THRIFT_LIB "")
endif()
find_library(THRIFTNB_LIB NAMES thriftnb)
if (NOT THRIFTNB_LIB)
set(THRIFTNB_LIB "")
endif()

find_path(GPERFTOOLS_INCLUDE_DIR NAMES gperftools/heap-profiler.h PATHS /home/gperftools/src)
find_library(GPERFTOOLS_LIBRARIES NAMES tcmalloc_and_profiler PATHS /home/gperftools/build)
find_path(GPERFTOOLS_INCLUDE_DIR NAMES gperftools/heap-profiler.h)
find_library(GPERFTOOLS_LIBRARIES NAMES tcmalloc_and_profiler)
include_directories(${GPERFTOOLS_INCLUDE_DIR})
message("---- ${GPERFTOOLS_LIBRARIES}")

find_path(BRPC_INCLUDE_PATH NAMES brpc/server.h)
if(LINK_SO)
Expand Down Expand Up @@ -88,13 +91,13 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBRPC_ENABLE_CPU_PROFILER")

if(CMAKE_VERSION VERSION_LESS "3.1.3")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
else()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

Expand All @@ -105,19 +108,13 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
endif()
include_directories(${LEVELDB_INCLUDE_PATH})

#if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
# set(OPENSSL_ROOT_DIR
# "/usr/local/opt/openssl" # Homebrew installed OpenSSL
# )
#endif()

#find_package(OpenSSL)


set(OPENSSL_INCLUDE_DIR /home/boringssl/include)
find_library(OPENSSL_CRYPTO_LIBRARY NAMES libcrypto.a PATHS /home/boringssl/build/crypto)
find_library(OPENSSL_SSL_LIBRARY NAMES libssl.a PATHS /home/boringssl/build/ssl)
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(OPENSSL_ROOT_DIR
"/usr/local/opt/openssl" # Homebrew installed OpenSSL
)
endif()

find_package(OpenSSL)
include_directories(${OPENSSL_INCLUDE_DIR})


Expand All @@ -129,6 +126,7 @@ set(DYNAMIC_LIB
${OPENSSL_CRYPTO_LIBRARY}
${OPENSSL_SSL_LIBRARY}
${THRIFT_LIB}
${THRIFTNB_LIB}
dl
)

Expand Down
2 changes: 1 addition & 1 deletion src/brpc/details/ssl_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ SSL* CreateSSLSession(SSL_CTX* ctx, SocketId id, int fd, bool server_mode) {
}

void AddBIOBuffer(SSL* ssl, int fd, int bufsize) {
#if OPENSSL_IS_BORINGSSL
#if defined(OPENSSL_IS_BORINGSSL)
BIO *rbio = BIO_new(BIO_s_mem());
BIO *wbio = BIO_new(BIO_s_mem());
#else
Expand Down
4 changes: 3 additions & 1 deletion src/butil/iobuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
#include "butil/fd_guard.h" // butil::fd_guard
#include "butil/iobuf.h"

#if defined (OPENSSL_IS_BORINGSSL)
#include "butil/ssl_compat.h" // BIO_fd_non_fatal_error
#endif

namespace butil {
namespace iobuf {
Expand Down Expand Up @@ -2153,7 +2155,7 @@ bool IOBufBytesIterator::forward_one_block(const void** data, size_t* size) {
return true;
}

} // namespace butil
} // namespace butil

void* fast_memcpy(void *__restrict dest, const void *__restrict src, size_t n) {
return butil::iobuf::cp(dest, src, n);
Expand Down
2 changes: 1 addition & 1 deletion src/butil/ssl_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ BRPC_INLINE int EVP_PKEY_base_id(const EVP_PKEY *pkey) {
#endif /* OPENSSL_VERSION_NUMBER < 0x0090801fL || OPENSSL_IS_BORINGSSL */

#if defined(OPENSSL_IS_BORINGSSL)
[[maybe_unused]] static int BIO_fd_non_fatal_error(int err) {
BRPC_INLINE int BIO_fd_non_fatal_error(int err) {
if (
#ifdef EWOULDBLOCK
err == EWOULDBLOCK ||
Expand Down
5 changes: 1 addition & 4 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
# specific language governing permissions and limitations
# under the License.

find_path(GPERFTOOLS_INCLUDE_DIR NAMES gperftools/heap-profiler.h PATHS /home/gperftools/src)
find_library(GPERFTOOLS_LIBRARIES NAMES tcmalloc_and_profiler PATHS /home/gperftools/build)
include_directories(${GPERFTOOLS_INCLUDE_DIR})

find_package(Gperftools)
include_directories(${GPERFTOOLS_INCLUDE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})

Expand Down

0 comments on commit a4a51af

Please sign in to comment.