-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
125 lines (104 loc) · 3.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
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
119
120
121
122
123
124
125
CMAKE_MINIMUM_REQUIRED(VERSION 3.8)
PROJECT(edge_devx C)
# AZURE_IOT_SUPPORT Variable can be set to ON or OFF by inheriting CMakeLists.txt
set(AZURE_IOT_SUPPORT ON CACHE BOOL "Enable Azure Cloud support for the project" )
################################################################################
# Source groups
################################################################################
set(Source
"./src/dx_async.c"
"./src/dx_json_serializer.c"
"./src/dx_terminate.c"
"./src/dx_timer.c"
"./src/dx_utilities.c"
"./src/log.c"
"./src/parson.c"
"./src/dx_openai_functions.c"
)
source_group("Source" FILES ${Source})
if(AZURE_IOT_SUPPORT)
message(STATUS "Azure IoT Central/Hub Support Enabled")
set(Cloud
"./src/dx_avnet_iot_connect.c"
"./src/dx_azure_iot.c"
"./src/dx_config.c"
"./src/dx_device_twins.c"
"./src/dx_direct_methods.c"
)
source_group("Cloud" FILES ${Cloud})
endif()
# Support for gpio on Linux
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
message(STATUS "EdgeDevX Linux Peripherals Enabled")
set(LinuxPeripherals
"./src/dx_gpio.c"
)
source_group("LinuxPeripherals" FILES ${LinuxPeripherals})
endif()
set(ALL_FILES
${Source}
${LinuxPeripherals}
${Cloud}
)
################################################################################
# Target
################################################################################
add_library(${PROJECT_NAME} STATIC ${ALL_FILES})
target_include_directories(${PROJECT_NAME} PUBLIC include)
# set(ROOT_NAMESPACE rpi_libs)
# set_target_properties(${PROJECT_NAME} PROPERTIES VS_GLOBAL_KEYWORD "EdgeDevX")
if(AZURE_IOT_SUPPORT)
# Set options for Azure IoT SDK C lib
set(use_amqp OFF CACHE BOOL "Set amqp off" FORCE )
set(use_http OFF CACHE BOOL "Set http off" FORCE )
set(use_mqtt ON CACHE BOOL "Set http off" FORCE )
set(skip_samples ON CACHE BOOL "Skip samples" FORCE )
set(use_prov_client ON CACHE BOOL "Use prov client" FORCE )
# Add Azure IoT SDK C
add_subdirectory(azure-iot-sdk-c out)
target_include_directories(${PROJECT_NAME} PUBLIC azure-iot-sdk-c/iothub_client/inc)
target_include_directories(${PROJECT_NAME} PUBLIC azure-iot-sdk-c/provisioning_client/inc)
target_include_directories(${PROJECT_NAME} PUBLIC azure-iot-sdk-c/c-utility/inc)
target_include_directories(${PROJECT_NAME} PUBLIC azure-iot-sdk-c/deps/umock-c/inc)
target_include_directories(${PROJECT_NAME} PUBLIC azure-iot-sdk-c/deps/azure-macro-utils-c/inc)
target_link_libraries (${PROJECT_NAME}
aziotsharedutil
hsm_security_client
iothub_client
parson
prov_auth_client
prov_device_ll_client
prov_mqtt_transport
umqtt
)
endif()
#
# The following config was required for macOS homebrew installed UV, UUID and SSL libs
# Install brew
# /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
#
# Install required libraries
# brew install mosquitto libuv openssl ossp-uuid
#
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# macOS on Apple silicon (arm64)
if (${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "arm64")
target_include_directories(${PROJECT_NAME} PUBLIC /opt/homebrew/include)
target_link_directories(${PROJECT_NAME} PUBLIC /opt/homebrew/lib)
else()
# macOS on Intel
target_include_directories(${PROJECT_NAME} PUBLIC /usr/local/include)
target_link_directories(${PROJECT_NAME} PUBLIC /usr/local/lib)
endif()
endif()
# required for dx_gpio on linux support
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
target_link_libraries (${PROJECT_NAME} gpiod)
endif()
target_link_libraries (${PROJECT_NAME}
curl
m
pthread
uuid
uv
)