zephyr/modules/lz4/CMakeLists.txt
Miika Karanki d851bb9e86 modules: lz4: add configurability
- Add possibility to disable functions that use heap. This is to
  reduce code size and prevent accidental use of heap.

- Add possibility to compile xxhash library, "Extremely Fast Hash
  algorithm" in. It might be sometimes needed as a standalone,
  but especially lz4frame requires it.

- Add possibility to compile also hc and lz4frame modules. The
  config options include possibility to configure will heap or
  stack be used. Defaults are set according to lz4's current
  defaults.

Signed-off-by: Miika Karanki <miika.karanki@vaisala.com>
2024-11-22 22:46:59 +00:00

46 lines
1 KiB
CMake

# Copyright (c) 2020 Linumiz
# SPDX-License-Identifier: Apache-2.0
if(CONFIG_LZ4)
set(LZ4_DIR ${ZEPHYR_CURRENT_MODULE_DIR})
zephyr_library()
zephyr_include_directories(${LZ4_DIR}/lib)
zephyr_library_compile_definitions_ifdef(CONFIG_LZ4_HEAPMODE_STACK
LZ4_HEAPMODE=0
)
zephyr_library_compile_definitions_ifdef(CONFIG_LZ4_DISABLE_DYNAMIC_MEMORY_ALLOCATION
LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION
)
zephyr_library_compile_definitions(
LZ4_MEMORY_USAGE=${CONFIG_LZ4_MEMORY_USAGE}
)
zephyr_library_sources(
${LZ4_DIR}/lib/lz4.c
)
zephyr_library_sources_ifdef(CONFIG_LZ4_HIGH_COMPRESSION_VARIANT
${LZ4_DIR}/lib/lz4hc.c
)
zephyr_library_compile_definitions_ifdef(CONFIG_LZ4HC_HEAPMODE_STACK
LZ4HC_HEAPMODE=0
)
zephyr_library_sources_ifdef(CONFIG_LZ4_XX_HASH
${LZ4_DIR}/lib/xxhash.c
)
zephyr_library_sources_ifdef(CONFIG_LZ4_FRAME_SUPPORT
${LZ4_DIR}/lib/lz4frame.c
)
zephyr_library_compile_definitions_ifdef(CONFIG_LZ4F_HEAPMODE_HEAP
LZ4F_HEAPMODE=1
)
endif()