66 lines
2.0 KiB
CMake
66 lines
2.0 KiB
CMake
set(PROJECT "rpsdk-mix-c-rs-zig")
|
|
|
|
option(PICO_NO_FLASH "Disable writing the compiled program to flash, and only load it to RAM. Useful for testing, but not much else (ON by default)." OFF)
|
|
option(PICO_COPY_TO_RAM "Run all code in RAM, while the program is also stored on flash. On bootup, everything will be copied to RAM (OFF by default)." OFF)
|
|
|
|
cmake_minimum_required(VERSION 3.11)
|
|
|
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/pico_sdk_import.cmake)
|
|
|
|
project(${PROJECT})
|
|
|
|
pico_sdk_init()
|
|
|
|
add_executable(${PROJECT})
|
|
|
|
pico_enable_stdio_uart(${PROJECT} 0)
|
|
pico_enable_stdio_usb(${PROJECT} 1)
|
|
|
|
target_sources(${PROJECT} PUBLIC
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src/clib.c
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
|
|
)
|
|
|
|
target_include_directories(${PROJECT} PUBLIC
|
|
${CMAKE_CURRENT_SOURCE_DIR}/inc/
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src/
|
|
)
|
|
|
|
target_link_libraries(${PROJECT}
|
|
pico_stdlib pico_unique_id hardware_pio hardware_dma hardware_uart
|
|
hardware_pwm cmsis_core pico_multicore
|
|
pico_stdlib
|
|
)
|
|
|
|
pico_add_extra_outputs(${PROJECT})
|
|
|
|
### hacks start here
|
|
|
|
set(RUST_TARGET thumbv6m-none-eabi)
|
|
set(RUST_CPU cortex-m0plus)
|
|
list(APPEND BINDGEN_CFLAGS "--use-core" "--rust-edition=2021")
|
|
list(APPEND RUST_CFLAGS "--edition=2021")
|
|
include(cmake/rust-obj.cmake)
|
|
add_rust_object(${PROJECT}
|
|
# rust top level module
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src/rustcode.rs
|
|
# optional: path to header file to use for c2rs bindgen stuff (currently limited to one, sorry)
|
|
${CMAKE_CURRENT_SOURCE_DIR}/inc/clib.h
|
|
)
|
|
|
|
set(ZIG_TARGET thumb-freestanding-gnueabi)
|
|
set(ZIG_CPU cortex_m0plus)
|
|
list(APPEND ZIG_CFLAGS "-ffunction-sections" "-fdata-sections")
|
|
include(cmake/zig-obj.cmake)
|
|
add_zig_object(${PROJECT}
|
|
# zig top level module
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src/zigcode.zig
|
|
)
|
|
|
|
### hacks end here
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror=implicit-function-declaration -Werror=return-type -Werror=aggressive-loop-optimizations")
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--cref")
|
|
|