From a146d10bcf166f55299c7a55728abaaea52cb0e5 Mon Sep 17 00:00:00 2001 From: Yinxiu Jia <48558845+kenneth-jia@users.noreply.github.com> Date: Tue, 25 Apr 2023 18:09:46 +0800 Subject: [PATCH] Re-organize tools --- tools/BUILD.bazel | 30 ------------ tools/CMakeLists.txt | 49 +------------------ tools/console_clients/BUILD.bazel | 30 ++++++++++++ tools/console_clients/CMakeLists.txt | 48 ++++++++++++++++++ .../KafkaConsoleConsumer.cc | 0 .../KafkaConsoleProducer.cc | 0 tools/{ => console_clients}/KafkaTopics.cc | 0 7 files changed, 79 insertions(+), 78 deletions(-) create mode 100644 tools/console_clients/BUILD.bazel create mode 100644 tools/console_clients/CMakeLists.txt rename tools/{ => console_clients}/KafkaConsoleConsumer.cc (100%) rename tools/{ => console_clients}/KafkaConsoleProducer.cc (100%) rename tools/{ => console_clients}/KafkaTopics.cc (100%) diff --git a/tools/BUILD.bazel b/tools/BUILD.bazel index c798b2882..e69de29bb 100644 --- a/tools/BUILD.bazel +++ b/tools/BUILD.bazel @@ -1,30 +0,0 @@ -cc_binary( - name = "kafka-topics", - - srcs = ["KafkaTopics.cc"], - - linkopts = ["-lboost_program_options", "-lrdkafka"], - - deps = ["//:modern-cpp-kafka-api"], -) - -cc_binary( - name = "kafka-console-consumer", - - srcs = ["KafkaConsoleConsumer.cc"], - - linkopts = ["-lboost_program_options", "-lrdkafka"], - - deps = ["//:modern-cpp-kafka-api"], -) - -cc_binary( - name = "kafka-console-producer", - - srcs = ["KafkaConsoleProducer.cc"], - - linkopts = ["-lboost_program_options", "-lrdkafka"], - - deps = ["//:modern-cpp-kafka-api"], -) - diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 710cc353b..560b0a1e3 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,48 +1 @@ -project("kafka-tools") - - -#--------------------------- -# boost -#--------------------------- -if (DEFINED ENV{BOOST_ROOT}) - set(Boost_INCLUDE_DIRS $ENV{BOOST_ROOT}/include) - set(Boost_LIBRARY_DIRS $ENV{BOOST_ROOT}/lib) -else () - find_package(Boost COMPONENTS program_options REQUIRED) - if (NOT Boost_FOUND) - message(FATAL_ERROR "Boost not found!") - endif () -endif () - -message(STATUS "boost include directory: ${Boost_INCLUDE_DIRS}") -message(STATUS "boost library directory: ${Boost_LIBRARY_DIRS}") - -include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) -link_directories(${Boost_LIBRARY_DIRS}) - - -# Target: kafka-topics -set(KafkaTopics kafka-topics) - -add_executable("${KafkaTopics}" "KafkaTopics.cc") -target_link_libraries("${KafkaTopics}" modern-cpp-kafka-api boost_program_options) - -install(TARGETS "${KafkaTopics}" DESTINATION tools) - - -# Target: kafka-console-consumer -set(KafkaConsoleConsumer kafka-console-consumer) - -add_executable("${KafkaConsoleConsumer}" "KafkaConsoleConsumer.cc") -target_link_libraries("${KafkaConsoleConsumer}" modern-cpp-kafka-api boost_program_options) - -install(TARGETS "${KafkaConsoleConsumer}" DESTINATION tools) - - -# Target: kafka-console-producer -set(KafkaConsoleProducer kafka-console-producer) - -add_executable("${KafkaConsoleProducer}" "KafkaConsoleProducer.cc") -target_link_libraries("${KafkaConsoleProducer}" modern-cpp-kafka-api boost_program_options) - -install(TARGETS "${KafkaConsoleProducer}" DESTINATION tools) +add_subdirectory(console_clients) diff --git a/tools/console_clients/BUILD.bazel b/tools/console_clients/BUILD.bazel new file mode 100644 index 000000000..c798b2882 --- /dev/null +++ b/tools/console_clients/BUILD.bazel @@ -0,0 +1,30 @@ +cc_binary( + name = "kafka-topics", + + srcs = ["KafkaTopics.cc"], + + linkopts = ["-lboost_program_options", "-lrdkafka"], + + deps = ["//:modern-cpp-kafka-api"], +) + +cc_binary( + name = "kafka-console-consumer", + + srcs = ["KafkaConsoleConsumer.cc"], + + linkopts = ["-lboost_program_options", "-lrdkafka"], + + deps = ["//:modern-cpp-kafka-api"], +) + +cc_binary( + name = "kafka-console-producer", + + srcs = ["KafkaConsoleProducer.cc"], + + linkopts = ["-lboost_program_options", "-lrdkafka"], + + deps = ["//:modern-cpp-kafka-api"], +) + diff --git a/tools/console_clients/CMakeLists.txt b/tools/console_clients/CMakeLists.txt new file mode 100644 index 000000000..710cc353b --- /dev/null +++ b/tools/console_clients/CMakeLists.txt @@ -0,0 +1,48 @@ +project("kafka-tools") + + +#--------------------------- +# boost +#--------------------------- +if (DEFINED ENV{BOOST_ROOT}) + set(Boost_INCLUDE_DIRS $ENV{BOOST_ROOT}/include) + set(Boost_LIBRARY_DIRS $ENV{BOOST_ROOT}/lib) +else () + find_package(Boost COMPONENTS program_options REQUIRED) + if (NOT Boost_FOUND) + message(FATAL_ERROR "Boost not found!") + endif () +endif () + +message(STATUS "boost include directory: ${Boost_INCLUDE_DIRS}") +message(STATUS "boost library directory: ${Boost_LIBRARY_DIRS}") + +include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) +link_directories(${Boost_LIBRARY_DIRS}) + + +# Target: kafka-topics +set(KafkaTopics kafka-topics) + +add_executable("${KafkaTopics}" "KafkaTopics.cc") +target_link_libraries("${KafkaTopics}" modern-cpp-kafka-api boost_program_options) + +install(TARGETS "${KafkaTopics}" DESTINATION tools) + + +# Target: kafka-console-consumer +set(KafkaConsoleConsumer kafka-console-consumer) + +add_executable("${KafkaConsoleConsumer}" "KafkaConsoleConsumer.cc") +target_link_libraries("${KafkaConsoleConsumer}" modern-cpp-kafka-api boost_program_options) + +install(TARGETS "${KafkaConsoleConsumer}" DESTINATION tools) + + +# Target: kafka-console-producer +set(KafkaConsoleProducer kafka-console-producer) + +add_executable("${KafkaConsoleProducer}" "KafkaConsoleProducer.cc") +target_link_libraries("${KafkaConsoleProducer}" modern-cpp-kafka-api boost_program_options) + +install(TARGETS "${KafkaConsoleProducer}" DESTINATION tools) diff --git a/tools/KafkaConsoleConsumer.cc b/tools/console_clients/KafkaConsoleConsumer.cc similarity index 100% rename from tools/KafkaConsoleConsumer.cc rename to tools/console_clients/KafkaConsoleConsumer.cc diff --git a/tools/KafkaConsoleProducer.cc b/tools/console_clients/KafkaConsoleProducer.cc similarity index 100% rename from tools/KafkaConsoleProducer.cc rename to tools/console_clients/KafkaConsoleProducer.cc diff --git a/tools/KafkaTopics.cc b/tools/console_clients/KafkaTopics.cc similarity index 100% rename from tools/KafkaTopics.cc rename to tools/console_clients/KafkaTopics.cc