blob: 0f341040291d700665f3b469998a7c7a3cf45947 [file] [log] [blame]
Dávid Vincze306cfc22022-12-19 20:02:39 +01001cmake_minimum_required(VERSION 3.15)
2
Hannes Tschofenigac5763d2021-04-20 21:12:07 +02003project(qcbor
Dávid Vincze306cfc22022-12-19 20:02:39 +01004 DESCRIPTION "QCBOR"
5 LANGUAGES C
6 VERSION 1.1.0
7)
Hannes Tschofenigac5763d2021-04-20 21:12:07 +02008
Dávid Vincze306cfc22022-12-19 20:02:39 +01009set(BUILD_QCBOR_TEST "OFF" CACHE STRING "Build QCBOR test suite [OFF, LIB, APP]")
10set(BUILD_QCBOR_WARN OFF CACHE BOOL "Compile with the warning flags used in the QCBOR release process")
11# BUILD_SHARED_LIBS is a built-in global CMake flag
12# The shared library is not made by default because of platform
13# variability For example MacOS and Linux behave differently and some
14# IoT OS's don't support them at all.
15set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries instead of static ones")
Hannes Tschofenigac5763d2021-04-20 21:12:07 +020016
Dávid Vincze306cfc22022-12-19 20:02:39 +010017if (BUILD_QCBOR_WARN)
18 # Compile options applying to all targets in current directory and below
19 add_compile_options(-Wall -Wextra -Wpedantic -Wshadow -Wconversion -Wcast-qual)
20endif()
Hannes Tschofenigac5763d2021-04-20 21:12:07 +020021
Dávid Vincze306cfc22022-12-19 20:02:39 +010022add_library(qcbor)
rvanputten165ecfb2022-03-04 20:54:04 +010023
Dávid Vincze306cfc22022-12-19 20:02:39 +010024target_sources(qcbor
25 PRIVATE
26 src/ieee754.c
27 src/qcbor_decode.c
28 src/qcbor_encode.c
29 src/qcbor_err_to_str.c
30 src/UsefulBuf.c
31)
32
33target_include_directories(qcbor
34 PUBLIC
35 inc
36 PRIVATE
37 src
38)
39
40if (BUILD_SHARED_LIBS)
41 target_compile_options(qcbor PRIVATE -Os -fPIC)
42endif()
43
44# The math library is needed for floating-point support.
45# To avoid need for it #define QCBOR_DISABLE_FLOAT_HW_USE
46target_link_libraries(qcbor PRIVATE m)
47
48if (NOT BUILD_QCBOR_TEST STREQUAL "OFF")
49 add_subdirectory(test)
50endif()