-
Notifications
You must be signed in to change notification settings - Fork 26
/
CMakeLists.txt
118 lines (97 loc) · 3.58 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# CMakeList.txt : CMake project for GoveeBTTempLogger, include source and define
# project specific logic here.
#
# This set of commands should build the package
# git clone https://github.com/wcbonner/GoveeBTTempLogger.git
# cmake -S GoveeBTTempLogger -B GoveeBTTempLogger/build
# cmake --build GoveeBTTempLogger/build
# pushd GoveeBTTempLogger/build && cpack . && popd
cmake_minimum_required(VERSION 3.12.0)
# Enable Hot Reload for MSVC compilers if supported.
if (POLICY CMP0141)
cmake_policy(SET CMP0141 NEW)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
endif()
if (POLICY CMP0115)
cmake_policy(SET CMP0115 NEW)
endif()
add_compile_definitions(_BLUEZ_HCI_)
project (GoveeBTTempLogger
VERSION 3.20241121.0
DESCRIPTION "Listen and log Govee Thermometer Bluetooth Low Energy Advertisments via BlueZ and DBus"
HOMEPAGE_URL https://github.com/wcbonner/GoveeBTTempLogger
)
configure_file(
goveebttemplogger-version.h.in
goveebttemplogger-version.h)
include( FindPkgConfig )
pkg_check_modules( dbus REQUIRED dbus-1 )
# Add source to this project's executable.
add_executable (goveebttemplogger
goveebttemplogger.cpp
goveebttemplogger-version.h
att-types.h
uuid.c
uuid.h
wimiso8601.cpp
wimiso8601.h
)
target_link_libraries(goveebttemplogger
-lbluetooth
-lstdc++fs
-ldbus-1
)
if (CMAKE_VERSION VERSION_GREATER 3.12)
set_property(TARGET goveebttemplogger PROPERTY CXX_STANDARD 17)
endif()
target_include_directories(goveebttemplogger PUBLIC
"${PROJECT_BINARY_DIR}"
${EXTRA_INCLUDES}
${dbus_INCLUDE_DIRS}
)
if(EXISTS "/etc/rpi-issue")
add_custom_command(TARGET goveebttemplogger POST_BUILD
COMMAND sudo setcap 'cap_net_raw,cap_net_admin+eip' $<TARGET_FILE:goveebttemplogger>
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Setting Raw Priveleges on $<TARGET_FILE:goveebttemplogger>"
)
endif()
add_executable(gvh-organizelogs
gvh-organizelogs.cpp
goveebttemplogger-version.h
wimiso8601.cpp
wimiso8601.h
)
target_link_libraries(gvh-organizelogs
-lbluetooth
-lstdc++fs
)
if (CMAKE_VERSION VERSION_GREATER 3.12)
set_property(TARGET gvh-organizelogs PROPERTY CXX_STANDARD 17)
endif()
target_include_directories(gvh-organizelogs PUBLIC "${PROJECT_BINARY_DIR}" ${EXTRA_INCLUDES} )
# TODO: Add tests and install targets if needed.
include(CTest)
add_test(NAME goveebttemplogger COMMAND goveebttemplogger --help)
add_test(NAME gvh-organizelogs COMMAND gvh-organizelogs --help)
install(TARGETS goveebttemplogger gvh-organizelogs
DESTINATION bin
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
)
install(FILES goveebttemplogger.service
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/systemd/system
COMPONENT "goveebttemplogger"
)
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_CONTACT "[email protected]")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "William C Bonner <${CPACK_PACKAGE_CONTACT}>")
include(InstallRequiredSystemLibraries)
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
set(CPACK_DEBIAN_PACKAGE_SECTION custom)
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/postinst" "${CMAKE_CURRENT_SOURCE_DIR}/prerm" "${CMAKE_CURRENT_SOURCE_DIR}/postrm")
set(CPACK_STRIP_FILES YES)
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS YES)
message(STATUS "Components to pack: ${CPACK_COMPONENTS_ALL}")
include(CPack)