Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
145 lines (129 loc) · 5.74 KB
/
Copy pathCMakeLists.txt
File metadata and controls
145 lines (129 loc) · 5.74 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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#
# Copyright (c) 2019-2026 Siddharth Chandrasekaran <sidcha.dev@gmail.com>
#
# SPDX-License-Identifier: Apache-2.0
#
# ESP-IDF pulls this directory in as a component (with add_subdirectory), so it
# must not run project()/install()/CPack. ESP_PLATFORM is set by ESP-IDF's build
# system before any component is added; hand over to the component definition and
# return before the standalone host build below is even parsed.
#
# The branch lives here, at the repo root, because ESP-IDF resolves a component
# to the directory containing CMakeLists.txt -- it cannot be pointed at a
# subdirectory. Keeping the root as the component root is also what makes the
# component publishable: `idf.py upload-component` packs the component directory,
# so a component rooted at esp-idf/ could never carry src/ and utils/.
if(ESP_PLATFORM)
include("${CMAKE_CURRENT_LIST_DIR}/esp-idf/component.cmake")
return()
endif()
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_policy(SET CMP0063 NEW)
# Generate compile_commands.json for IDE support
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
project(libosdp VERSION 4.0.0)
# Pre-release marker: "dev" while the next release is prepared but unpublished,
# empty once published. Kept separate from the numeric project() version (which
# SOVERSION/CPack/pkg-config derive from) — it only decorates the human-visible
# version string composed in cmake/GitInfo.cmake. Owned by scripts/make_release.py.
set(LIBOSDP_PRERELEASE "dev")
set(PROJECT_AUTHOR "Siddharth Chandrasekaran")
set(PROJECT_AUTHOR_EMAIL "sidcha.dev@gmail.com")
set(PROJECT_YEAR "2019")
set(PROJECT_ORG "osdp-dev")
set(PROJECT_URL "https://github.com/osdp-dev/libosdp/")
set(PROJECT_HOMEPAGE "https://doc.osdp.dev/")
set(PROJECT_DESCRIPTION "Open Supervised Device Protocol (OSDP) Library")
set(PROJECT_LICENSE "Apache License, Version 2.0 (Apache-2.0)")
## Options
option(OPT_OSDP_PACKET_TRACE "Enable raw packet trace for diagnostics" OFF)
option(OPT_OSDP_DATA_TRACE "Enable command/reply data buffer tracing" OFF)
option(OPT_OSDP_SKIP_MARK_BYTE "Don't send the leading mark byte (0xFF)" OFF)
option(OPT_OSDP_RX_ZERO_COPY "Enable zero-copy RX buffers (requires recv_pkt/release_pkt)" OFF)
option(OPT_OSDP_LOG_MINIMAL "Minimize logger RAM/stack usage for embedded targets" OFF)
option(OPT_DISABLE_PRETTY_LOGGING "Don't colorize log ouputs" OFF)
option(OPT_BUILD_SANITIZER "Enable different sanitizers during build" OFF)
option(OPT_BUILD_STATIC "Build static library" ON)
option(OPT_BUILD_SHARED "Build shared library" ON)
option(OPT_OSDP_STATIC "Build without dynamic memory allocation" OFF)
option(OPT_OSDP_LIB_ONLY "Only build the library" OFF)
option(OPT_BUILD_BARE_METAL "Build library for bare metal targets" OFF)
option(OPT_USE_32BIT_TICK_T "Use uint32_t tick_t on bare-metal targets" OFF)
option(OPT_BUILD_OSDP_TRS "Enable Transparent Reader Support" OFF)
set(OPT_OSDP_CRYPTO_BACKEND "auto" CACHE STRING
"Crypto backend selection: auto, openssl, mbedtls, or tinyaes")
set_property(CACHE OPT_OSDP_CRYPTO_BACKEND PROPERTY STRINGS
auto openssl mbedtls tinyaes)
## Includes
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(AddCCompilerFlag)
include(GitInfo)
include(BuildType)
## Global settings
if(NOT MSVC)
add_compile_options(-Wall -Wextra)
else()
# MSVC's legacy preprocessor mis-handles the token-paste + rescan used
# by IS_ENABLED() in utils/include/utils/utils.h, silently returning 0
# for every defined-as-1 flag. /Zc:preprocessor switches to the
# C99/C11-conformant preprocessor (VS 2019 16.5+). /std:c11 is also
# required so _Static_assert (used by the IS_ENABLED self-test in
# utils/src/utils.c) is recognised as a keyword.
add_compile_options(/Zc:preprocessor /std:c11)
endif()
if (OPT_BUILD_BARE_METAL)
# __BARE_METAL__ enables bare-metal paths. To use uint32_t tick_t,
# also enable OPT_USE_32BIT_TICK_T. Verify your tick source and counter width
# can safely represent the longest delay/timeout in your target project.
add_compile_options(-D__BARE_METAL__)
if (OPT_USE_32BIT_TICK_T)
add_compile_options(-DUSE_32BIT_TICK_T)
endif()
else()
include(GNUInstallDirs)
endif()
## Optional external tooling — informational only, never required.
find_package(Python3 COMPONENTS Interpreter QUIET)
if(Python3_Interpreter_FOUND)
message(STATUS "Python bindings: build with 'pip install ./python' (interpreter ${Python3_EXECUTABLE})")
else()
message(STATUS "Python bindings: skipped (no Python 3 interpreter found)")
endif()
find_program(DOXYGEN_EXECUTABLE doxygen)
if(DOXYGEN_EXECUTABLE)
set(DOXYGEN_OUTPUT_DIR "${CMAKE_BINARY_DIR}/doxygen")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Doxyfile.in"
"${CMAKE_CURRENT_BINARY_DIR}/Doxyfile"
@ONLY
)
add_custom_target(doxygen_xml
COMMAND "${DOXYGEN_EXECUTABLE}" "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Generating Doxygen XML"
VERBATIM
)
else()
message(STATUS "Doxygen not found; doxygen_xml target unavailable")
endif()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_WARN_DEPRECATED ON)
# Each subdirectory has it's own CMakeLists.txt
include(GitSubmodules)
add_subdirectory(src)
if (NOT OPT_OSDP_STATIC AND NOT OPT_OSDP_LIB_ONLY AND NOT MSVC)
enable_testing()
add_subdirectory(utils)
add_subdirectory(tests/unit-tests)
add_subdirectory(examples/c)
add_subdirectory(examples/cpp)
endif()
## uninstall target. Dedupe the manifest and tolerate already-removed
## entries so re-runs (or future install rule changes) stay green.
add_custom_target(uninstall
COMMAND sort -u ${CMAKE_BINARY_DIR}/install_manifest.txt | xargs rm -f
)
## include package rules at last
include(CreatePackages)