Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 2 additions & 25 deletions libraries/protobuf/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
project(userver-protobuf CXX)

add_subdirectory(tests)

userver_module(
protobuf
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
Expand All @@ -10,28 +12,3 @@ userver_module(
"${CMAKE_CURRENT_SOURCE_DIR}/tests/json/*.cpp"
UTEST_LINK_LIBRARIES userver-protobuf-unittest-proto
)

if(USERVER_BUILD_TESTS)
set(_PROTO_SRC "${CMAKE_CURRENT_SOURCE_DIR}/tests/proto/proto_json/messages.proto")
set(_PROTO_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/tests/proto")
set(_PROTO_GEN "${CMAKE_CURRENT_BINARY_DIR}/proto")

# protoc requires its output directory to already exist.
file(MAKE_DIRECTORY "${_PROTO_GEN}")

add_library(userver-protobuf-unittest-proto STATIC "${_PROTO_SRC}")
protobuf_generate(
TARGET userver-protobuf-unittest-proto
LANGUAGE cpp
IMPORT_DIRS
"${_PROTO_ROOT}"
"${Protobuf_INCLUDE_DIR}"
PROTOC_OUT_DIR "${_PROTO_GEN}"
)

target_compile_options(userver-protobuf-unittest-proto PUBLIC -Wno-unused-parameter)
target_include_directories(userver-protobuf-unittest-proto SYSTEM PUBLIC
$<BUILD_INTERFACE:${_PROTO_GEN}>
)
target_link_libraries(userver-protobuf-unittest-proto PUBLIC protobuf::libprotobuf)
endif()
24 changes: 24 additions & 0 deletions libraries/protobuf/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
if(USERVER_BUILD_TESTS)
set(_PROTO_SRC "${CMAKE_CURRENT_SOURCE_DIR}/proto/proto_json/messages.proto")
set(_PROTO_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/proto")
set(_PROTO_GEN "${CMAKE_CURRENT_BINARY_DIR}/proto")

# protoc requires its output directory to already exist.
file(MAKE_DIRECTORY "${_PROTO_GEN}")

add_library(userver-protobuf-unittest-proto STATIC "${_PROTO_SRC}")
protobuf_generate(
TARGET userver-protobuf-unittest-proto
LANGUAGE cpp
IMPORT_DIRS
"${_PROTO_ROOT}"
"${Protobuf_INCLUDE_DIR}"
PROTOC_OUT_DIR "${_PROTO_GEN}"
)

target_compile_options(userver-protobuf-unittest-proto PUBLIC -Wno-unused-parameter)
target_include_directories(userver-protobuf-unittest-proto SYSTEM PUBLIC
$<BUILD_INTERFACE:${_PROTO_GEN}>
)
target_link_libraries(userver-protobuf-unittest-proto PUBLIC protobuf::libprotobuf)
endif()
Loading