1
+ #-------------------------------------------------------------------------------
2
+ # Copyright (c) 2022-2023, Arm Limited. All rights reserved.
3
+ #
4
+ # SPDX-License-Identifier: BSD-3-Clause
5
+ #
6
+ # See BSD-3-Clause license in README.md
7
+ #-------------------------------------------------------------------------------
8
+
1
9
cmake_minimum_required (VERSION 3.15 )
2
10
3
11
project (qcbor
@@ -14,6 +22,12 @@ set(BUILD_QCBOR_WARN OFF CACHE BOOL "Compile with the warning flags used i
14
22
# IoT OS's don't support them at all.
15
23
set (BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries instead of static ones" )
16
24
25
+ # Configuration:
26
+ # Floating-point support (see README.md for more information)
27
+ set (QCBOR_OPT_DISABLE_FLOAT_HW_USE OFF CACHE BOOL "Eliminate dependency on FP hardware and FP instructions" )
28
+ set (QCBOR_OPT_DISABLE_FLOAT_PREFERRED OFF CACHE BOOL "Eliminate support for half-precision and CBOR preferred serialization" )
29
+ set (QCBOR_OPT_DISABLE_FLOAT_ALL OFF CACHE BOOL "Eliminate floating-point support completely" )
30
+
17
31
if (BUILD_QCBOR_WARN )
18
32
# Compile options applying to all targets in current directory and below
19
33
add_compile_options (-Wall -Wextra -Wpedantic -Wshadow -Wconversion -Wcast-qual )
@@ -37,13 +51,26 @@ target_include_directories(qcbor
37
51
src
38
52
)
39
53
54
+ target_compile_definitions (qcbor
55
+ PRIVATE
56
+ $< $< BOOL:${QCBOR_OPT_DISABLE_FLOAT_HW_USE} > :QCBOR_DISABLE_FLOAT_HW_USE>
57
+ $< $< BOOL:${QCBOR_OPT_DISABLE_FLOAT_PREFERRED} > :QCBOR_DISABLE_PREFERRED_FLOAT>
58
+ $< $< BOOL:${QCBOR_OPT_DISABLE_FLOAT_ALL} > :USEFULBUF_DISABLE_ALL_FLOAT>
59
+ )
60
+
40
61
if (BUILD_SHARED_LIBS )
41
62
target_compile_options (qcbor PRIVATE -Os -fPIC )
42
63
endif ()
43
64
44
65
# The math library is needed for floating-point support.
45
66
# To avoid need for it #define QCBOR_DISABLE_FLOAT_HW_USE
46
- target_link_libraries (qcbor PRIVATE m )
67
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" )
68
+ # Using GCC
69
+ target_link_libraries (qcbor
70
+ PRIVATE
71
+ $< $< NOT:$< BOOL:${QCBOR_OPT_DISABLE_FLOAT_HW_USE} > > :m>
72
+ )
73
+ endif ()
47
74
48
75
if (NOT BUILD_QCBOR_TEST STREQUAL "OFF" )
49
76
add_subdirectory (test )
0 commit comments