1# SPDX-License-Identifier: Apache-2.0
2
3if(CONFIG_FILE_SYSTEM_LIB_LINK)
4  zephyr_interface_library_named(FS)
5
6  if(CONFIG_FILE_SYSTEM)
7    zephyr_library()
8    zephyr_library_include_directories(${CMAKE_CURRENT_SOURCE_DIR})
9    zephyr_library_sources(fs.c fs_impl.c)
10    zephyr_library_sources_ifdef(CONFIG_FAT_FILESYSTEM_ELM   fat_fs.c)
11    zephyr_library_sources_ifdef(CONFIG_FILE_SYSTEM_LITTLEFS littlefs_fs.c)
12    zephyr_library_sources_ifdef(CONFIG_FILE_SYSTEM_SHELL    shell.c)
13
14    zephyr_library_compile_definitions_ifdef(CONFIG_FILE_SYSTEM_LITTLEFS
15                                            LFS_CONFIG=zephyr_lfs_config.h
16    )
17  endif()
18
19  add_subdirectory_ifdef(CONFIG_FILE_SYSTEM_EXT2 ext2)
20
21  zephyr_library_link_libraries(FS)
22
23  target_link_libraries_ifdef(CONFIG_FAT_FILESYSTEM_ELM   FS INTERFACE ELMFAT)
24  target_link_libraries_ifdef(CONFIG_FILE_SYSTEM_LITTLEFS FS INTERFACE LITTLEFS)
25  target_link_libraries_ifdef(CONFIG_FILE_SYSTEM_EXT2     FS INTERFACE EXT2)
26endif()
27
28add_subdirectory_ifdef(CONFIG_FCB  ./fcb)
29add_subdirectory_ifdef(CONFIG_NVS  ./nvs)
30add_subdirectory_ifdef(CONFIG_ZMS  ./zms)
31
32if(CONFIG_FUSE_FS_ACCESS)
33  zephyr_library_named(FS_FUSE)
34  find_package(PkgConfig REQUIRED)
35  pkg_search_module(FUSE REQUIRED fuse)
36  zephyr_include_directories(${FUSE_INCLUDE_DIRS})
37  if (CONFIG_NATIVE_LIBRARY)
38    target_link_options(native_simulator INTERFACE "-l${FUSE_LIBRARIES}")
39  else()
40    zephyr_link_libraries(${FUSE_LIBRARIES})
41  endif()
42  zephyr_library_compile_definitions(_FILE_OFFSET_BITS=64)
43  zephyr_library_sources(fuse_fs_access.c)
44endif()
45