diff --git a/libraries/protobuf/CMakeLists.txt b/libraries/protobuf/CMakeLists.txt index 5af7a207c369..fee6f0fd46df 100644 --- a/libraries/protobuf/CMakeLists.txt +++ b/libraries/protobuf/CMakeLists.txt @@ -1,5 +1,7 @@ project(userver-protobuf CXX) +add_subdirectory(tests) + userver_module( protobuf SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" @@ -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 - $ - ) - target_link_libraries(userver-protobuf-unittest-proto PUBLIC protobuf::libprotobuf) -endif() diff --git a/libraries/protobuf/tests/CMakeLists.txt b/libraries/protobuf/tests/CMakeLists.txt new file mode 100644 index 000000000000..93d5e8a53624 --- /dev/null +++ b/libraries/protobuf/tests/CMakeLists.txt @@ -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 + $ + ) + target_link_libraries(userver-protobuf-unittest-proto PUBLIC protobuf::libprotobuf) +endif()