Skip to content

Commit

Permalink
chore(cmake): honor CMAKE_BUILD_TYPE while building bundled grpc and …
Browse files Browse the repository at this point in the history
…protobuf.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
  • Loading branch information
FedeDP authored and poiana committed Sep 5, 2024
1 parent 0c67af0 commit 9d2d151
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmake/modules/grpc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ else()
GIT_SUBMODULES "third_party/abseil-cpp"
CMAKE_CACHE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=${GRPC_INSTALL_DIR}
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=${ENABLE_PIC}
-DgRPC_INSTALL:BOOL=OFF
# disable unused stuff
Expand Down
8 changes: 6 additions & 2 deletions cmake/modules/protobuf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,19 @@ else()
else()
set(PROTOBUF_PIC_OPTION "--with-pic=yes")
endif()

if (CMAKE_BUILD_TYPE STREQUAL "Release")
set(PROTOBUF_CXXFLAGS "-O2 -std=c++11 -DNDEBUG")
else()
set(PROTOBUF_CXXFLAGS "-g -std=c++11")
endif()
message(STATUS "Using bundled protobuf in '${PROTOBUF_SRC}'")
ExternalProject_Add(protobuf
PREFIX "${PROJECT_BINARY_DIR}/protobuf-prefix"
DEPENDS zlib
URL "https://github.com/protocolbuffers/protobuf/releases/download/v3.20.3/protobuf-cpp-3.20.3.tar.gz"
URL_HASH "SHA256=e51cc8fc496f893e2a48beb417730ab6cbcb251142ad8b2cd1951faa5c76fe3d"
# TODO what if using system zlib?
CONFIGURE_COMMAND CPPFLAGS=-I${ZLIB_INCLUDE} LDFLAGS=-L${ZLIB_SRC} ./configure --with-zlib ${PROTOBUF_CONFIGURE_FLAGS} ${PROTOBUF_PIC_OPTION} --prefix=${PROTOBUF_INSTALL_DIR}
CONFIGURE_COMMAND CPPFLAGS=-I${ZLIB_INCLUDE} LDFLAGS=-L${ZLIB_SRC} ./configure CXXFLAGS=${PROTOBUF_CXXFLAGS} --with-zlib ${PROTOBUF_CONFIGURE_FLAGS} ${PROTOBUF_PIC_OPTION} --prefix=${PROTOBUF_INSTALL_DIR}
BUILD_COMMAND make
BUILD_IN_SOURCE 1
BUILD_BYPRODUCTS ${PROTOC} ${PROTOBUF_INCLUDE} ${PROTOBUF_LIB}
Expand Down

0 comments on commit 9d2d151

Please sign in to comment.