-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
131 lines (98 loc) · 2.87 KB
/
Copy pathCMakeLists.txt
File metadata and controls
131 lines (98 loc) · 2.87 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
# CMakeLists.txt for LittleFS-Toy
#
cmake_minimum_required(VERSION 3.20)
set(CMAKE_C_STANDARD 11)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
#set(BUILD_TAG beta)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, e.g. Debug, Release")
if(CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE Release)
endif()
project(littlefs-toy
VERSION 1.1.1
DESCRIPTION "littlefs-toy - A tool for creating and modifying LittleFS images."
HOMEPAGE_URL https://github.com/tjko/littlefs-toy/
LANGUAGES C
)
include(GNUInstallDirs)
include(CheckIncludeFile)
include(CheckFunctionExists)
check_include_file(unistd.h HAVE_UNISTD_H)
check_include_file(getopt.h HAVE_GETOPT_H)
check_include_file(sys/errno.h HAVE_SYS_ERRNO_H)
check_function_exists(getopt_long HAVE_GETOPT_LONG)
find_package(Python3 COMPONENTS Interpreter Development)
# LittleFS
add_library(littlefs INTERFACE)
target_include_directories(littlefs INTERFACE
libs/littlefs/
)
target_sources(littlefs INTERFACE
libs/littlefs/lfs.c
libs/littlefs/lfs_util.c
)
set_source_files_properties(
libs/littlefs/lfs.c
PROPERTIES
COMPILE_OPTIONS "-Wno-unused-function"
)
add_executable(lfst
src/lfst.c
src/lfs_driver.c
src/lfs_extra.c
src/util.c
)
target_include_directories(lfst PRIVATE src)
configure_file(src/config.h.in config.h)
if (HAVE_GETOPT_LONG)
message("Using getopt_long from the system.")
else()
message("Using included getopt_long.")
target_sources(lfst PRIVATE
src/getopt/getopt.c
src/getopt/getopt1.c
)
endif()
if (MINGW)
message("Building with mingw-w64")
target_link_libraries(lfst -static gcc winpthread littlefs -dynamic)
else()
target_link_libraries(lfst PRIVATE littlefs)
endif()
target_compile_options(lfst PRIVATE
-Wall
-Wextra
-fmacro-prefix-map=${CMAKE_SOURCE_DIR}/=
)
if (NOT MINGW)
target_compile_options(lfst PRIVATE
-fstack-protector-all
)
endif()
target_compile_definitions(lfst PRIVATE
HAVE_CONFIG_H
LFS_DEFINES=lfs_opts.h
LFS_THREADSAFE
LFS_NO_DEBUG
LFS_NO_WARN
# LFS_NO_ERROR
)
install(TARGETS lfst)
install(FILES man/lfst.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
install(FILES README.md LICENSE TYPE DOC)
if (Python3_FOUND)
enable_testing()
add_test(NAME lfs_tests
COMMAND ${Python3_EXECUTABLE} test_lfst.py
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests
)
set_property(TEST lfs_tests PROPERTY ENVIRONMENT "LFS=$<TARGET_FILE:lfst>" "DEBUG=1")
endif()
message("==========================================================")
message(" BUILD_TAG: ${BUILD_TAG}")
message(" CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
message(" CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
message(" CMAKE_SYSTEM_VERSION: ${CMAKE_SYSTEM_VERSION}")
message(" CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
message(" CMAKE_CROSSCOMPILING: ${CMAKE_CROSSCOMPILING}")
message("==========================================================")