diff options
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 72 |
1 files changed, 61 insertions, 11 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 74197cb..b9d9691 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,14 +1,12 @@ cmake_minimum_required(VERSION 3.2) project(mqtt_cassandra_bridge) -find_package(Boost COMPONENTS regex system program_options REQUIRED) - -add_executable(mqtt_cassandra_bridge main.cpp cassandra_support.h) -target_link_libraries(mqtt_cassandra_bridge PUBLIC ${Boost_LIBRARIES}) -target_compile_options(mqtt_cassandra_bridge PUBLIC "-std=c++14") +find_package(Boost COMPONENTS system program_options unit_test_framework REQUIRED) include(ExternalProject) +set(SHARED_COMPILE_OPTIONS "-std=c++14") + # Cassandra set(CPP_DRIVER ${CMAKE_CURRENT_BINARY_DIR}/cpp-driver) ExternalProject_Add(cpp-driver @@ -17,9 +15,6 @@ ExternalProject_Add(cpp-driver PREFIX ${CPP_DRIVER} CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> ) -target_include_directories(mqtt_cassandra_bridge PRIVATE ${CPP_DRIVER}/include) -target_link_libraries(mqtt_cassandra_bridge PRIVATE ${CPP_DRIVER}/lib/libcassandra.so) -add_dependencies(mqtt_cassandra_bridge cpp-driver) # ble-toys set(BLE_TOYS ${CMAKE_CURRENT_BINARY_DIR}/ble-toys) @@ -27,13 +22,68 @@ ExternalProject_Add(ble-toys GIT_REPOSITORY https://trygvis.io/git/2015/02/ble-toys.git GIT_TAG 650fb016ce36cfda2e8073764196655ee6a50567 GIT_SUBMODULES json - BUILD_ALWAYS 0 PREFIX ${BLE_TOYS} CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> ) + +# nghttp2 +set(NGHTTP2 ${CMAKE_CURRENT_BINARY_DIR}/nghttp2) +ExternalProject_Add(nghttp2 + URL https://github.com/tatsuhiro-t/nghttp2/releases/download/v1.0.5/nghttp2-1.0.5.tar.xz + URL_MD5 ff25d732d79128c4fa426393a635c21e + PREFIX ${NGHTTP2} + BUILD_ALWAYS 0 + CONFIGURE_COMMAND cd <SOURCE_DIR> && autoreconf -i && automake && autoconf && ./configure --prefix=<INSTALL_DIR> --enable-asio-lib + BUILD_COMMAND cd <SOURCE_DIR> && make + INSTALL_COMMAND cd <SOURCE_DIR> && make install +) + +# Mosquitto +# TODO: proper discovery + +# OpenSSL +# TODO: proper discovery + +# mqtt_cassandra_bridge +add_executable(mqtt_cassandra_bridge main.cpp cassandra_support.h) +add_dependencies(mqtt_cassandra_bridge cpp-driver) +## Boost +target_link_libraries(mqtt_cassandra_bridge PRIVATE ${Boost_LIBRARIES}) +## Cassandra +target_include_directories(mqtt_cassandra_bridge PRIVATE ${CPP_DRIVER}/include) +target_link_libraries(mqtt_cassandra_bridge PRIVATE ${CPP_DRIVER}/lib/libcassandra.so) +## Mosquitto +target_compile_options(mqtt_cassandra_bridge PUBLIC ${SHARED_COMPILE_OPTIONS}) +target_link_libraries(mqtt_cassandra_bridge PRIVATE mosquitto mosquittopp) +## Ble toys add_dependencies(mqtt_cassandra_bridge ble-toys) target_include_directories(mqtt_cassandra_bridge PRIVATE ${BLE_TOYS}/include) target_link_libraries(mqtt_cassandra_bridge PRIVATE ${BLE_TOYS}/lib/trygvis/libtrygvis-sensor.a) -# Mosquitto -target_link_libraries(mqtt_cassandra_bridge PRIVATE mosquitto mosquittopp) +# sm_web_server +add_executable(sm_web_server sm_web_server.cpp cassandra_support.h http_support.h) +target_compile_options(sm_web_server PUBLIC ${SHARED_COMPILE_OPTIONS}) +## Boost +target_link_libraries(sm_web_server PRIVATE ${Boost_LIBRARIES}) +## Cassandra +add_dependencies(sm_web_server cpp-driver) +target_include_directories(sm_web_server PRIVATE ${CPP_DRIVER}/include) +target_link_libraries(sm_web_server PRIVATE ${CPP_DRIVER}/lib/libcassandra.so) +## Nghttp2 +add_dependencies(sm_web_server nghttp2) +target_include_directories(sm_web_server PRIVATE ${NGHTTP2}/include) +target_link_libraries(sm_web_server PRIVATE ${NGHTTP2}/lib/libnghttp2_asio.a ${NGHTTP2}/lib/libnghttp2.a) +## Misc +target_link_libraries(sm_web_server PRIVATE ssl crypto pthread) + +enable_testing() +add_executable(http-tests http-tests.cpp http_support.h) +target_compile_options(http-tests PUBLIC ${SHARED_COMPILE_OPTIONS}) +add_dependencies(http-tests nghttp2) +target_include_directories(http-tests PRIVATE ${NGHTTP2}/include) +target_link_libraries(http-tests PRIVATE ${NGHTTP2}/lib/libnghttp2_asio.a ${NGHTTP2}/lib/libnghttp2.a) +target_link_libraries(http-tests PRIVATE ssl crypto pthread) +target_link_libraries(http-tests PRIVATE ${Boost_LIBRARIES}) +target_compile_definitions(http-tests PUBLIC -DBOOST_TEST_DYN_LINK) + +add_test(NAME http-tests COMMAND http-tests) |