-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
88 lines (67 loc) · 1.96 KB
/
Copy pathCMakeLists.txt
File metadata and controls
88 lines (67 loc) · 1.96 KB
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
cmake_minimum_required(VERSION 3.5)
project(mqtt-forward C)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include(CTest)
enable_testing()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type (default Debug)" FORCE)
endif()
set(TARGET_MQTT_FORWARD mqtt-forward)
set(source_files_mqtt_forward
src/beacon.c
src/log.c
src/mqtt-forward.c
src/protocol.c
src/session.c
src/utils.c
)
add_executable(${TARGET_MQTT_FORWARD} ${source_files_mqtt_forward})
target_include_directories(${TARGET_MQTT_FORWARD} PRIVATE
${CMAKE_INSTALL_PREFIX}/include
${CMAKE_CURRENT_SOURCE_DIR}/src
)
# Optional: Add compile options (if not handled by flags)
target_compile_options(${TARGET_MQTT_FORWARD} PRIVATE -Wall)
# Optional: Override CMake defaults if needed
set(CMAKE_C_FLAGS_DEBUG "-O0 -g3")
set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
find_package(OpenSSL REQUIRED)
target_link_libraries(${TARGET_MQTT_FORWARD} PRIVATE
pthread
mosquitto
OpenSSL::SSL
OpenSSL::Crypto
)
install(TARGETS ${TARGET_MQTT_FORWARD} DESTINATION bin)
if(BUILD_TESTING)
set(TARGET_UNIT_TESTS mqtt-forward-unit-tests)
set(TARGET_TEST_HELPER mqtt-forward-test-helper)
add_executable(${TARGET_UNIT_TESTS}
src/beacon.c
src/log.c
src/protocol.c
src/session.c
src/utils.c
test/unit_tests.c
)
target_include_directories(${TARGET_UNIT_TESTS} PRIVATE
${CMAKE_INSTALL_PREFIX}/include
${CMAKE_CURRENT_SOURCE_DIR}/src
)
target_compile_options(${TARGET_UNIT_TESTS} PRIVATE -Wall)
target_link_libraries(${TARGET_UNIT_TESTS} PRIVATE
pthread
mosquitto
OpenSSL::SSL
OpenSSL::Crypto
)
add_executable(${TARGET_TEST_HELPER}
test/mqtt_forward_test_helper.c
)
target_compile_options(${TARGET_TEST_HELPER} PRIVATE -Wall)
target_link_libraries(${TARGET_TEST_HELPER} PRIVATE
pthread
)
add_test(NAME unit COMMAND ${TARGET_UNIT_TESTS})
endif()
# vim: set ts=4 sw=4 sts=4 et smarttab :