blob: 76e31ef35b29cab610846c96d3977826a6d7e840 (
plain)
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
|
# CMakeLists.txt - Main per-platform build script for sbc-harness project
#
# Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
# SPDX-License-Identifier: AGPL-3.0-or-later
cmake_minimum_required(VERSION 3.30)
if (NOT PICO_PLATFORM)
message(FATAL_ERROR "PICO_PLATFORM must be specified; use the GNUmakefile to set this")
endif()
set(PICO_SDK_PATH "${CMAKE_SOURCE_DIR}/3rd-party/pico-sdk")
if (PICO_PLATFORM STREQUAL "rp2040")
set(PICO_CLIB "picolibc")
add_library(pico_cxx_options INTERFACE)
endif()
include("${PICO_SDK_PATH}/external/pico_sdk_import.cmake")
project(sbc_harness)
pico_sdk_init()
add_compile_options(-Wall -Wextra -Werror)
function(target_embed_sources arg_target arg_hdrname)
set(embed_objs)
foreach(embed_src IN LISTS ARGN)
add_custom_command(
OUTPUT "${embed_src}.obj"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMAND mkdir -p -- "$<PATH:GET_PARENT_PATH,${CMAKE_CURRENT_BINARY_DIR}/${embed_src}>" &&
${CMAKE_LINKER} -r -b binary -o "${CMAKE_CURRENT_BINARY_DIR}/${embed_src}.obj" "${embed_src}"
DEPENDS "${embed_src}"
)
list(APPEND embed_objs "${embed_src}.obj")
endforeach()
set_source_files_properties("${embed_objs}" PROPERTIES
EXTERNAL_OBJECT true
GENERATED true
)
set_source_files_properties("${arg_hdrname}" PROPERTIES
GENERATED true
)
add_custom_command(
OUTPUT "${arg_hdrname}"
COMMAND "${CMAKE_SOURCE_DIR}/build-aux/embed-sources.h.gen" "${embed_objs}" >"${arg_hdrname}"
COMMAND_EXPAND_LISTS
DEPENDS "${embed_objs}" "${CMAKE_SOURCE_DIR}/build-aux/embed-sources.h.gen"
)
target_sources("${arg_target}" PRIVATE "${embed_objs}" "${arg_hdrname}")
endfunction()
function(add_stack_analysis arg_outfile arg_objlib_target)
target_compile_options("${arg_objlib_target}" PUBLIC "-fcallgraph-info=su,da")
set_source_files_properties("${arg_outfile}" PROPERTIES
GENERATED true
)
add_custom_command(
OUTPUT "${arg_outfile}"
COMMAND "${CMAKE_SOURCE_DIR}/build-aux/stack.c.gen" "$<TARGET_OBJECTS:${arg_objlib_target}>" >"${arg_outfile}"
COMMAND_EXPAND_LISTS
DEPENDS "$<TARGET_OBJECTS:${arg_objlib_target}>" "${CMAKE_SOURCE_DIR}/build-aux/stack.c.gen"
COMMENT "Calculating ${arg_objlib_target} required stack sizes"
)
endfunction()
if (PICO_PLATFORM STREQUAL "rp2040")
set(TESTS ON)
add_subdirectory(3rd-party/picolibc)
foreach(lib IN ITEMS pico_clib_interface)
# cpp
target_include_directories(${lib} INTERFACE ${CMAKE_BINARY_DIR}/3rd-party/picolibc/picolibc/include)
target_compile_definitions(${lib} INTERFACE
PICO_RUNTIME_NO_INIT_PER_CORE_TLS_SETUP=1
PICO_RUNTIME_SKIP_INIT_PER_CORE_TLS_SETUP=1
)
# cc
target_compile_options(${lib} INTERFACE --specs=${CMAKE_BINARY_DIR}/3rd-party/picolibc/picolibc.specs)
target_compile_options(${lib} INTERFACE -nolibc)
# ld
target_link_options( ${lib} INTERFACE --specs=${CMAKE_BINARY_DIR}/3rd-party/picolibc/picolibc.specs)
target_link_options( ${lib} INTERFACE -nolibc -lgcc)
target_link_libraries( ${lib} INTERFACE c)
endforeach()
target_link_options( bs2_default PRIVATE --specs=${CMAKE_BINARY_DIR}/3rd-party/picolibc/picolibc.specs -nolibc -lgcc)
target_link_libraries( bs2_default c)
endif()
add_subdirectory(libcr)
add_subdirectory(libcr_ipc)
add_subdirectory(libmisc)
add_subdirectory(libhw)
add_subdirectory(libdhcp)
add_subdirectory(libusb)
add_subdirectory(lib9p)
add_subdirectory(cmd/sbc_harness)
add_subdirectory(cmd/srv9p)
|