67 lines
1.5 KiB
CMake
67 lines
1.5 KiB
CMake
# preamble
|
|
cmake_minimum_required(VERSION 3.14)
|
|
|
|
project(telemetry VERSION 0.1)
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
# add_compile_options(-fdiagnostics-color) # does not goes well with default VsCode console
|
|
add_compile_options(-pedantic)
|
|
add_compile_options(-Wall)
|
|
add_compile_options(-Wextra)
|
|
add_compile_options(-Wpedantic)
|
|
add_compile_options(-Wno-unused-local-typedefs)
|
|
|
|
include_directories(${PROJECT_SOURCE_DIR})
|
|
|
|
## Libraries
|
|
add_library(datapoint
|
|
datapoint/analytics_event.cpp
|
|
datapoint/temperature_reading.cpp
|
|
)
|
|
|
|
add_library(mock_log_sources
|
|
demo/mocks/mock_temperature_source.cpp
|
|
demo/mocks/mock_analytics_source.cpp
|
|
)
|
|
|
|
add_subdirectory(telemetry)
|
|
|
|
# Device executable (simulation)
|
|
add_executable(device
|
|
demo/main.cpp
|
|
demo/device.cpp
|
|
)
|
|
|
|
target_link_libraries(device
|
|
PRIVATE
|
|
mock_log_sources
|
|
datapoint
|
|
telemetry
|
|
)
|
|
|
|
# Download googletest
|
|
include(FetchContent)
|
|
FetchContent_Declare(
|
|
googletest
|
|
URL https://github.com/google/googletest/archive/refs/tags/release-1.12.1.zip
|
|
)
|
|
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
|
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
|
FetchContent_MakeAvailable(googletest)
|
|
|
|
# Add tests
|
|
enable_testing()
|
|
|
|
add_executable(test_temperature_reading
|
|
tests/data/test_temperature_reading.cpp
|
|
tests/data/test_telemetry.cpp
|
|
)
|
|
target_link_libraries(test_temperature_reading
|
|
GTest::gtest_main
|
|
datapoint
|
|
telemetry
|
|
)
|
|
|
|
include(GoogleTest)
|
|
gtest_discover_tests(test_temperature_reading)
|