-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
63 lines (51 loc) · 1.75 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
cmake_minimum_required(VERSION 3.10)
project(emeter-grabber
VERSION 0.1.0
DESCRIPTION "SMA-Emeter to InfluxDB"
LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(USE_CURL OFF CACHE BOOL "Enable curl dependency")
set(USE_BOOST OFF CACHE BOOL "Enable boost dependency")
# This CMake configuration assumes the following directory layout
#
# - sma-emeter-grabber
# - libspeedwire
# - <relative build path>
# - libcurl (windows only; for linux it is installed in /usr/lib64)
# - include
# - lib
# - influxdb-cxx-fork
# - include
# - lib
# - <relative install path>
# determine relative build and install paths
message("CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE}")
message("CMAKE_BINARY_DIR ${CMAKE_BINARY_DIR}")
message("CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}")
# path definitions for InfluxDB (adapt to your needs)
add_subdirectory(influxdb-cxx-fork EXCLUDE_FROM_ALL)
# path definitions for libspeedwire (adapt to your needs)
add_subdirectory(libspeedwire EXCLUDE_FROM_ALL)
# project sources and include path
set(PROJECT_SOURCES
src/InfluxDBProducer.cpp
src/PacketReceiver.cpp
src/HttpClient.cpp
src/Url.cpp
src/main.cpp
src/TagDefinitions.cpp
)
set(PROJECT_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include)
# build configuration
add_executable(${PROJECT_NAME} ${PROJECT_SOURCES} )
add_dependencies(${PROJECT_NAME} speedwire InfluxDB)
target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_INCLUDE_DIR} speedwire InfluxDB)
if (MSVC)
target_link_libraries(${PROJECT_NAME} speedwire InfluxDB ws2_32.lib Iphlpapi.lib)
else()
target_link_libraries(${PROJECT_NAME} speedwire InfluxDB)
endif()
set_target_properties(${PROJECT_NAME}
PROPERTIES OUTPUT_NAME ${PROJECT_NAME}
)
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})