-
Notifications
You must be signed in to change notification settings - Fork 50
/
CMakeLists.txt
83 lines (73 loc) · 3.85 KB
/
CMakeLists.txt
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
# The following lines of boilerplate have to be in your project's CMakeLists
# in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.13)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# pull in idf specific items, config vars etc.
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(ctag-tbd)
# this is global to all!
#idf_build_set_property(COMPILE_OPTIONS -Wno-unused-local-typedefs -ffast-math APPEND) # -ffast-math -fno-finite-math-only https://stackoverflow.com/questions/22931147/stdisinf-does-not-work-with-ffast-math-how-to-check-for-infinity
idf_build_set_property(COMPILE_DEFINITIONS -DRAPIDJSON_ALLOCATOR_DEFAULT_CHUNK_CAPACITY=4096 APPEND)
idf_build_set_property(COMPILE_DEFINITIONS -DRAPIDJSON_HAS_STDSTRING=1 APPEND)
if(CONFIG_TBD_PLATFORM_STR)
message("Configuring for Strämpler!")
idf_build_set_property(COMPILE_DEFINITIONS -DN_CVS=8 APPEND)
idf_build_set_property(COMPILE_DEFINITIONS -DN_TRIGS=2 APPEND)
set(TBD_HW "Strampler")
elseif(CONFIG_TBD_PLATFORM_MK2)
message("Configuring for MK2!")
idf_build_set_property(COMPILE_DEFINITIONS -DN_CVS=22 APPEND)
idf_build_set_property(COMPILE_DEFINITIONS -DN_TRIGS=12 APPEND)
set(TBD_HW "mk2")
elseif(CONFIG_TBD_PLATFORM_V2)
idf_build_set_property(COMPILE_DEFINITIONS -DN_CVS=4 APPEND)
idf_build_set_property(COMPILE_DEFINITIONS -DN_TRIGS=2 APPEND)
set(TBD_HW "V2")
elseif(CONFIG_TBD_PLATFORM_V1)
idf_build_set_property(COMPILE_DEFINITIONS -DN_CVS=4 APPEND)
idf_build_set_property(COMPILE_DEFINITIONS -DN_TRIGS=2 APPEND)
set(TBD_HW "V1")
elseif(CONFIG_TBD_PLATFORM_AEM)
idf_build_set_property(COMPILE_DEFINITIONS -DN_CVS=4 APPEND)
idf_build_set_property(COMPILE_DEFINITIONS -DN_TRIGS=2 APPEND)
set(TBD_HW "AEM")
elseif(CONFIG_TBD_PLATFORM_BBA)
idf_build_set_property(COMPILE_DEFINITIONS -DN_CVS=90 APPEND)
idf_build_set_property(COMPILE_DEFINITIONS -DN_TRIGS=40 APPEND)
set(TBD_HW "BBA")
endif()
# generate include definitions for hw + fw version
execute_process(
COMMAND bash -c "git describe --tags --abbrev=4"
OUTPUT_VARIABLE TBD_FW)
string(STRIP ${TBD_FW} TBD_FW)
configure_file(${CMAKE_SOURCE_DIR}/version.hpp.in ${CMAKE_BINARY_DIR}/gen_include/version.hpp @ONLY)
idf_build_set_property(INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/gen_include APPEND)
# Create a SPIFFS image from the contents of the 'spiffs_image' directory
# that fits the partition named 'storage'. FLASH_IN_PROJECT indicates that
# the generated image should be flashed when the entire project is flashed to
# the target with 'idf.py -p PORT flash'.
file(GLOB_RECURSE WWW_FILES RELATIVE ${CMAKE_SOURCE_DIR}/spiffs_image ${CMAKE_SOURCE_DIR}/spiffs_image/www/*)
foreach(WWW_FILE ${WWW_FILES})
list(APPEND GZIP_COMMANDS
COMMAND gzip -9 ${CMAKE_BINARY_DIR}/spiffs_image/${WWW_FILE} )
endforeach()
if(NOT CONFIG_TBD_PLATFORM_BBA)
list(APPEND DEL_COMMANDS
COMMAND rm -f ${CMAKE_BINARY_DIR}/spiffs_image/data/sp/*DrumRack.jsn)
list(APPEND DEL_COMMANDS
COMMAND rm -f ${CMAKE_BINARY_DIR}/spiffs_image/dbup/sp/*DrumRack.jsn)
endif()
add_custom_target(copy-files ALL DEPENDS ${CMAKE_SOURCE_DIR}/spiffs_image
# clean up
COMMAND rm -rf ${CMAKE_BINARY_DIR}/spiffs_image
# copy spiffs files to build folder
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/spiffs_image ${CMAKE_BINARY_DIR}/spiffs_image
# create gzip encoded www files
${GZIP_COMMANDS}
# and create backup file structure (sometimes when the ESP's power is interrupted during flash writes, the SPIFFS file gets corrupted)
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/spiffs_image/data ${CMAKE_BINARY_DIR}/spiffs_image/dbup
${DEL_COMMANDS}
)
littlefs_create_partition_image(storage ${CMAKE_BINARY_DIR}/spiffs_image FLASH_IN_PROJECT DEPENDS copy-files)