-
-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
84 lines (68 loc) · 2.51 KB
/
CMakeLists.txt
File metadata and controls
84 lines (68 loc) · 2.51 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
cmake_minimum_required (VERSION 3.5)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
option(EXAMPLES "Build examples and tiny_loopback" OFF)
option(UNITTEST "Build unit tests" OFF)
option(CUSTOM "Do not use built-in HAL, but use Custom instead" OFF)
option(ENABLE_FD_LOGS "Enable full duplex protocol logs" OFF)
# set(LOG_LEVEL "0" CACHE STRING "Logging level option" FORCE)
file(GLOB_RECURSE SOURCE_FILES src/*.cpp src/*.c)
file(GLOB_RECURSE HEADER_FILES src/*.h)
if (NOT DEFINED COMPONENT_DIR)
project (tinyproto)
add_library(tinyproto STATIC ${HEADER_FILES} ${SOURCE_FILES})
target_include_directories(tinyproto PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include/tinyproto>)
if(APPLE)
target_link_libraries(tinyproto PRIVATE
"-framework IOKit"
"-framework CoreFoundation"
)
endif()
if (EXAMPLES)
add_subdirectory(examples/linux/loopback)
add_subdirectory(examples/linux/hdlc_demo)
add_subdirectory(examples/linux/hdlc_demo_multithread)
endif()
if (UNITTEST)
add_subdirectory(unittest)
endif()
# Install the library and headers
install(DIRECTORY src/ DESTINATION include/tinyproto
FILES_MATCHING
PATTERN "*.h"
PATTERN "*.hpp"
PATTERN "src/hal/single_core" EXCLUDE)
install(TARGETS tinyproto
EXPORT tinyprotoTargets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include)
install(EXPORT tinyprotoTargets
FILE TinyProtoTargets.cmake
NAMESPACE TinyProto::
DESTINATION lib/cmake/tinyproto)
include(CMakePackageConfigHelpers)
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/TinyProtoConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/TinyProtoConfig.cmake
INSTALL_DESTINATION lib/cmake/tinyproto)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/TinyProtoConfig.cmake
DESTINATION lib/cmake/tinyproto)
else()
idf_component_register(SRCS ${SOURCE_FILES}
INCLUDE_DIRS "src" PRIV_REQUIRES esp_timer)
endif()
if (CUSTOM)
add_definitions("-DTINY_CUSTOM_PLATFORM=1")
endif()
if (ENABLE_FD_LOGS)
add_definitions("-DTINY_DEBUG=1")
add_definitions("-DTINY_FD_DEBUG=1")
if (LOG_LEVEL)
add_definitions("-DTINY_LOG_LEVEL_DEFAULT=${LOG_LEVEL}")
endif()
endif()