mirror of
https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka.git
synced 2025-11-01 19:18:04 +00:00
Improve build system a bit
This commit is contained in:
@@ -6,23 +6,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
|
||||
|
||||
include_directories(${CMAKE_SOURCE_DIR}/include/cppkafka)
|
||||
|
||||
set(GOOGLETEST_ROOT ${CMAKE_SOURCE_DIR}/third_party/googletest)
|
||||
set(GOOGLETEST_INCLUDE ${GOOGLETEST_ROOT}/googletest/include)
|
||||
set(GOOGLETEST_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/googletest)
|
||||
set(GOOGLETEST_LIBRARY ${GOOGLETEST_BINARY_DIR}/googletest)
|
||||
|
||||
include(ExternalProject)
|
||||
|
||||
ExternalProject_Add(
|
||||
googletest
|
||||
DOWNLOAD_COMMAND ""
|
||||
SOURCE_DIR ${GOOGLETEST_ROOT}
|
||||
BINARY_DIR ${GOOGLETEST_BINARY_DIR}
|
||||
CMAKE_CACHE_ARGS "-DBUILD_GTEST:bool=ON" "-DBUILD_GMOCK:bool=OFF"
|
||||
"-Dgtest_force_shared_crt:bool=ON"
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
|
||||
# Look for Boost (just need boost.optional headers here)
|
||||
find_package(Boost REQUIRED)
|
||||
include_directories(${Boost_INCLUDE_DIRS})
|
||||
@@ -47,8 +30,31 @@ configure_file(
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(include)
|
||||
# Make sure we build googletest before anything else
|
||||
add_dependencies(cppkafka googletest)
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
|
||||
add_subdirectory(examples)
|
||||
|
||||
set(GOOGLETEST_ROOT ${CMAKE_SOURCE_DIR}/third_party/googletest)
|
||||
if(EXISTS "${GOOGLETEST_ROOT}/CMakeLists.txt")
|
||||
set(GOOGLETEST_INCLUDE ${GOOGLETEST_ROOT}/googletest/include)
|
||||
set(GOOGLETEST_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/googletest)
|
||||
set(GOOGLETEST_LIBRARY ${GOOGLETEST_BINARY_DIR}/googletest)
|
||||
|
||||
include(ExternalProject)
|
||||
|
||||
ExternalProject_Add(
|
||||
googletest
|
||||
DOWNLOAD_COMMAND ""
|
||||
SOURCE_DIR ${GOOGLETEST_ROOT}
|
||||
BINARY_DIR ${GOOGLETEST_BINARY_DIR}
|
||||
CMAKE_CACHE_ARGS "-DBUILD_GTEST:bool=ON" "-DBUILD_GMOCK:bool=OFF"
|
||||
"-Dgtest_force_shared_crt:bool=ON"
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
# Make sure we build googletest before anything else
|
||||
add_dependencies(cppkafka googletest)
|
||||
else()
|
||||
message(STATUS "Disabling tests")
|
||||
endif()
|
||||
@@ -1,8 +1,13 @@
|
||||
find_package(Boost REQUIRED COMPONENTS program_options)
|
||||
find_package(Boost COMPONENTS program_options)
|
||||
|
||||
link_libraries(${Boost_LIBRARIES} cppkafka ${RDKAFKA_LIBRARY} ${ZOOKEEPER_LIBRARY})
|
||||
if (Boost_PROGRAM_OPTIONS_FOUND)
|
||||
link_libraries(${Boost_LIBRARIES} cppkafka ${RDKAFKA_LIBRARY} ${ZOOKEEPER_LIBRARY})
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../include)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../include)
|
||||
|
||||
add_executable(kafka_producer kafka_producer.cpp)
|
||||
add_executable(kafka_consumer kafka_consumer.cpp)
|
||||
add_executable(kafka_producer kafka_producer.cpp)
|
||||
add_executable(kafka_consumer kafka_consumer.cpp)
|
||||
add_custom_target(examples DEPENDS kafka_producer kafka_consumer)
|
||||
else()
|
||||
message(STATUS "Disabling examples since boost.program_options was not found")
|
||||
endif()
|
||||
|
||||
@@ -10,9 +10,12 @@ set(KAFKA_TEST_INSTANCE "kafka-vm:9092"
|
||||
set(ZOOKEEPER_TEST_INSTANCE "kafka-vm:2181"
|
||||
CACHE STRING "The zookeeper instance to which to connect to run tests")
|
||||
|
||||
add_custom_target(tests)
|
||||
|
||||
macro(create_test test_name)
|
||||
add_executable(${test_name}_test "${test_name}_test.cpp")
|
||||
add_executable(${test_name}_test EXCLUDE_FROM_ALL "${test_name}_test.cpp")
|
||||
add_test(${test_name} ${test_name}_test)
|
||||
add_dependencies(tests ${test_name}_test)
|
||||
endmacro()
|
||||
|
||||
add_definitions("-DKAFKA_TEST_INSTANCE=\"${KAFKA_TEST_INSTANCE}\"")
|
||||
|
||||
Reference in New Issue
Block a user