-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMakeLists.txt
122 lines (95 loc) · 3.44 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
cmake_minimum_required(VERSION 3.9...3.31)
project(aws-c-iot C)
option(USE_EXTERNAL_DEPS_SOURCES "Use dependencies provided by add_subdirectory command" OFF)
if (USE_EXTERNAL_DEPS_SOURCES)
set(IN_SOURCE_BUILD ON)
if (NOT aws-c-common_SOURCE_DIR)
message(FATAL_ERROR "USE_EXTERNAL_DEPS_SOURCES option is set, but aws-c-common project is not configured."
" aws-c-common must be added using add_subdirectory command (or one of the higher-level commands that"
" uses add_subdirectory, like FetchContent)")
endif()
list(APPEND CMAKE_MODULE_PATH "${aws-c-common_SOURCE_DIR}/cmake")
endif()
if (NOT IN_SOURCE_BUILD)
# this is required so we can use aws-c-common's CMake modules
find_package(aws-c-common REQUIRED)
endif()
include(AwsCFlags)
include(AwsCheckHeaders)
include(AwsSharedLibSetup)
include(AwsSanitizers)
include(CheckCCompilerFlag)
include(AwsFindPackage)
include(GNUInstallDirs)
# Platform specific includes and source
if (WIN32)
file(GLOB AWS_IOT_OS_SRC
"source/windows/*.c"
)
elseif (APPLE)
file(GLOB AWS_IOT_OS_SRC
"source/apple/*.c"
)
elseif (UNIX AND NOT APPLE)
file(GLOB AWS_IOT_OS_SRC
"source/linux/*.c"
)
endif()
file(GLOB AWS_IOT_HEADERS
"include/aws/iotdevice/*.h"
)
file(GLOB AWS_IOT_PRIV_HEADERS
"include/aws/iotdevice/private/*.h"
)
file(GLOB AWS_IOT_PRIV_EXPOSED_HEADERS
"include/aws/iotdevice/private/serializer.h"
"include/aws/iotdevice/private/secure_tunneling_impl.h"
)
file(GLOB AWS_IOT_SRC
"source/*.c"
)
file(GLOB IOT_HEADERS
${AWS_IOT_HEADERS}
${AWS_IOT_PRIV_HEADERS}
)
file(GLOB IOT_SRC
${AWS_IOT_SRC}
${AWS_IOT_OS_SRC}
${AWS_IOT_PRIV_HEADERS}
)
add_library(${PROJECT_NAME} ${IOT_HEADERS} ${IOT_SRC})
aws_set_common_properties(${PROJECT_NAME})
aws_prepare_symbol_visibility_args(${PROJECT_NAME} "AWS_IOTDEVICE")
aws_check_headers(${PROJECT_NAME} ${AWS_IOT_HEADERS})
aws_add_sanitizers(${PROJECT_NAME})
# We are not ABI stable yet
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION 1.0.0)
set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION 0unstable)
target_compile_definitions(${PROJECT_NAME} PRIVATE -DCJSON_HIDE_SYMBOLS)
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
aws_use_package(aws-c-mqtt)
target_link_libraries(${PROJECT_NAME} PUBLIC ${DEP_AWS_LIBS})
aws_prepare_shared_lib_exports(${PROJECT_NAME})
install(FILES ${AWS_IOT_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/aws/iotdevice" COMPONENT Development)
install(FILES ${AWS_IOT_PRIV_EXPOSED_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/aws/iotdevice/private" COMPONENT Development)
if (BUILD_SHARED_LIBS)
set (TARGET_DIR "shared")
else()
set (TARGET_DIR "static")
endif()
install(EXPORT "${PROJECT_NAME}-targets"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/${TARGET_DIR}"
NAMESPACE AWS::
COMPONENT Development)
configure_file("cmake/${PROJECT_NAME}-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
@ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/"
COMPONENT Development)
include(CTest)
if (BUILD_TESTING)
add_subdirectory(tests)
endif ()