-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
115 lines (99 loc) · 2.92 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
# Configurable options
set(TARGET_ESPIDF FALSE CACHE BOOL "Build for the espidf platform")
option(ATSDK_BUILD_TESTS "Build tests for atsdk ON | \"unit\" | \"func\" " OFF)
# to avoid caching issues
if(ATSDK_BUILD_TESTS STREQUAL "func")
message("FUNCTIONAL TESTING ENABLED")
set(ATSDK_BUILD_UNIT_TESTS OFF)
set(ATSDK_BUILD_FUNCTIONAL_TESTS ON)
elseif(ATSDK_BUILD_TESTS STREQUAL "unit")
message("UNIT TESTING ENABLED")
set(ATSDK_BUILD_UNIT_TESTS ON)
set(ATSDK_BUILD_FUNCTIONAL_TESTS OFF)
elseif(ATSDK_BUILD_TESTS)
message("ALL TESTING ENABLED")
set(ATSDK_BUILD_FUNCTIONAL_TESTS ON)
set(ATSDK_BUILD_UNIT_TESTS ON)
else()
message("TESTING DISABLED")
set(ATSDK_BUILD_UNIT_TESTS OFF)
set(ATSDK_BUILD_FUNCTIONAL_TESTS OFF)
endif()
# Basic project setup
cmake_minimum_required(VERSION 3.24)
set(CMAKE_C_STANDARD 99)
cmake_policy(SET CMP0135 NEW)
include(GNUInstallDirs)
project(
atsdk
VERSION 0.0.1
DESCRIPTION "Atsign's atSDK library"
HOMEPAGE_URL https://atsign.com
LANGUAGES C
)
# Determine if atchops is being built as a subproject using add_subdirectory()
if(NOT DEFINED ATSDK_AS_SUBPROJECT)
set(ATSDK_AS_SUBPROJECT ON)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(ATSDK_AS_SUBPROJECT OFF)
endif()
endif()
message(STATUS "[ATSDK] ATSDK_AS_SUBPROJECT: ${ATSDK_AS_SUBPROJECT}")
# install each package
message(STATUS "Building atlogger")
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/packages/atlogger)
message(STATUS "Building atchops")
set(ATCHOPS_BUILD_TESTS ${ATSDK_BUILD_UNIT_TESTS})
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/packages/atchops)
message(STATUS "Building atclient")
set(ATCLIENT_BUILD_TESTS ${ATSDK_BUILD_UNIT_TESTS})
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/packages/atclient)
message(STATUS "Building atauth")
set(ATAUTH_BUILD_TESTS ${ATSDK_BUILD_UNIT_TESTS})
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/packages/atauth)
if(NOT ESP_PLATFORM)
# install dependencies
set(
ATSDK_TARGETS
mbedtls
mbedx509
mbedcrypto
everest
p256m
atchops
cjson
atlogger
atclient
atcommons
atauth
)
install(
TARGETS ${ATSDK_TARGETS}
EXPORT ${PROJECT_NAME}-config
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
# export dependencies
if(NOT ATSDK_AS_SUBPROJECT)
export(PACKAGE ${PROJECT_NAME})
# install as a config.cmake
install(
EXPORT ${PROJECT_NAME}-config
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
FILE ${PROJECT_NAME}-config.cmake
)
# export the config.cmake
export(
EXPORT ${PROJECT_NAME}-config
NAMESPACE ${PROJECT_NAME}::
FILE "cmake/${PROJECT_NAME}-config.cmake"
)
endif()
endif()
if(ATSDK_BUILD_FUNCTIONAL_TESTS)
message(STATUS "Building functional tests")
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/tests/functional_tests)
endif()
if(ATSDK_BUILD_UNIT_TESTS OR ATSDK_BUILD_FUNCTIONAL_TESTS)
enable_testing()
endif()