| cmake_minimum_required(VERSION 3.13.4) | |
| #------------------------------------------------------------------------------- | |
| # Project configuration | |
| #------------------------------------------------------------------------------- | |
| project(iree-riscv32) | |
| set_property(GLOBAL PROPERTY USE_FOLDERS ON) | |
| list(APPEND CMAKE_MODULE_PATH | |
| ${CMAKE_CURRENT_LIST_DIR}/cmake/ | |
| ) | |
| set(BUILD_INTERNAL_MODELS OFF CACHE BOOL "Build applications from internal models (default: OFF)") | |
| set(IREE_SOURCE_DIR "$ENV{ROOTDIR}/toolchain/iree" CACHE PATH | |
| "IREE source code path. (default: $ENV{ROOTDIR}/toolchain/iree)") | |
| # Use nano spec header and libraries. | |
| include_directories(BEFORE SYSTEM "${RISCV_TOOLCHAIN_ROOT}/riscv32-unknown-elf/include/newlib-nano/") | |
| link_directories(BEFORE "${RISCV_TOOLCHAIN_ROOT}/riscv32-unknown-elf/lib/newlib-nano/") | |
| #------------------------------------------------------------------------------- | |
| # Springbok-specific settings | |
| #------------------------------------------------------------------------------- | |
| set(DTCM_LENGTH "16M" CACHE STRING "DTCM Length (default: 16M)") | |
| add_link_options("LINKER:--defsym=__dtcm_length__=${DTCM_LENGTH}") | |
| set(ITCM_LENGTH "512K" CACHE STRING "ITCM (I-mem) Length (default: 512K)") | |
| add_link_options("LINKER:--defsym=__itcm_length__=${ITCM_LENGTH}") | |
| set(STACK_SIZE "10K" CACHE STRING "Stack size (default: 10K)") | |
| add_link_options("LINKER:--defsym=__stack_size__=${STACK_SIZE}") | |
| set(SPRINGBOK_LINKER_SCRIPT "$ENV{ROOTDIR}/sw/vec/springbok/springbok.ld" CACHE PATH "Springbok linker script path (default: springbok.ld)") | |
| set(BUILD_WITH_SPRINGBOK ON CACHE BOOL "Build the target with springbok BSP (default: ON)") | |
| set(BUILD_ISP_WITH_RVV ON CACHE BOOL "Build the ISP pipeline with RVV (default: ON)") | |
| #------------------------------------------------------------------------------- | |
| # IREE-specific settings | |
| #------------------------------------------------------------------------------- | |
| set(IREE_BUILD_COMPILER OFF) | |
| set(IREE_ENABLE_MLIR OFF) | |
| set(IREE_BUILD_SAMPLES OFF) | |
| set(IREE_ENABLE_THREADING OFF) | |
| set(IREE_BUILD_TESTS OFF) | |
| set(IREE_BUILD_BINDINGS_TFLITE OFF) | |
| set(IREE_HAL_DRIVER_LOCAL_SYNC ON CACHE BOOL "" FORCE) | |
| set(IREE_HAL_EXECUTABLE_LOADER_DEFAULTS OFF CACHE BOOL "" FORCE) | |
| set(IREE_HAL_DRIVER_DEFAULTS OFF CACHE BOOL "" FORCE) | |
| #------------------------------------------------------------------------------- | |
| # IREE-specific definitions | |
| #------------------------------------------------------------------------------- | |
| set(SPRINGBOK_CONFIG_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/springbok_config.h") | |
| add_definitions(-DFLATCC_USE_GENERIC_ALIGNED_ALLOC) | |
| add_definitions(-DIREE_PLATFORM_GENERIC) | |
| add_definitions(-DIREE_SYNCHRONIZATION_DISABLE_UNSAFE=1) | |
| add_definitions(-DIREE_FILE_IO_ENABLE=0) | |
| add_definitions(-DIREE_USER_CONFIG_H="${SPRINGBOK_CONFIG_HEADER}") | |
| # The project does a cmake hack here -- at the executable linkage stage, we | |
| # append the logging library (and springbok BSP). Any logging library update | |
| # (libspringbok.a or libnative_log.a) only gets rebuilt during executable | |
| # linkage, but not during library compilation. | |
| # | |
| # However, an explicit include path gets added here across all targets so the | |
| # header files can be found during compilation. | |
| if(${BUILD_WITH_SPRINGBOK}) | |
| # Springbok BSP-related setting | |
| add_subdirectory($ENV{ROOTDIR}/sw/vec/springbok springbok) | |
| include(riscv_springbok) | |
| include_directories($ENV{ROOTDIR}/sw/vec/springbok/include) | |
| else() | |
| # Add the springbok printout support. | |
| add_subdirectory(native_log) | |
| include(riscv_native_log) | |
| include_directories(native_log) | |
| endif() | |
| message(STATUS "Include IREE source at ${IREE_SOURCE_DIR}") | |
| # Build IREE runtime libraries. | |
| add_subdirectory(${IREE_SOURCE_DIR} iree) | |
| # Apply IREE's CMake variables and build options so we can use IREE build | |
| # functions properly in this project. | |
| include(${IREE_SOURCE_DIR}/build_tools/cmake/iree_copts.cmake) | |
| include(springbok_bytecode_module) | |
| include(springbok_c_module) | |
| include(springbok_modules) | |
| include(iree_model_input) | |
| # softmax op (and mfcc) requires floorf implementation in libm. Use the nano | |
| # version. | |
| find_library(m m | |
| PATHS | |
| "${RISCV_TOOLCHAIN_ROOT}/riscv32-unknown-elf/lib/newlib-nano/" | |
| REQUIRED) | |
| link_libraries(m) | |
| # Apply hacks to avoid adding the `iree::` prefix to the out-of-tree | |
| # `iree_cc_library` function usage | |
| function(add_library library) | |
| cmake_parse_arguments(AL "ALIAS;IMPORTED" "" "" ${ARGN}) | |
| _add_library(${library} ${ARGN}) | |
| if(AL_ALIAS) | |
| string(FIND "${library}" "iree::samples::" _AL_IREE_SAMPLES) | |
| if(_AL_IREE_SAMPLES EQUAL 0) | |
| string(REPLACE "iree::" "" _AL_IREE_SAMPLES_ALIAS "${library}") | |
| string(REPLACE "ALIAS;" "" _AL_IREE_REAL_TARGET "${ARGN}") | |
| # Add an alias target starting with the iree:: prefix removed | |
| _add_library(${_AL_IREE_SAMPLES_ALIAS} ALIAS ${_AL_IREE_REAL_TARGET}) | |
| endif() | |
| endif() | |
| endfunction() | |
| # Add the included directory here. | |
| add_subdirectory(samples) | |
| # Add pigweed support | |
| include($ENV{ROOTDIR}/sw/pigweed/pw_build/pigweed.cmake) | |
| pw_set_backend(pw_log pw_log_basic) | |
| pw_set_backend(pw_assert pw_assert_log) | |
| pw_set_backend(pw_sys_io pw_sys_io_stdio) | |
| add_subdirectory($ENV{ROOTDIR}/sw/pigweed pw) |