Add cmake files

This commit is contained in:
mbanth
2021-06-22 13:45:24 +01:00
parent bec7111cfd
commit 5c402f26c9
2 changed files with 136 additions and 0 deletions

View File

@@ -0,0 +1,104 @@
cmake_minimum_required(VERSION 3.13)
set(XMOS_TOOLS_PATH $ENV{XMOS_TOOL_PATH}/bin)
#**********************
# Setup XMOS toolchain
#**********************
if(NOT DEFINED ENV{XUA_PATH})
message(FATAL_ERROR "XUA_PATH environment variable not defined")
# some more commands
endif()
include("$ENV{XUA_PATH}/cmake_utils/xmos_toolchain.cmake")
#**********************
# Project
#**********************
# Disable in-source build.
#if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
# message(FATAL_ERROR "In-source build is not allowed! Please specify a build folder.\n\tex:cmake -B build")
#endif()
## Define project
project(xua_unit_tests VERSION 0.1.0)
## Enable languages for project
enable_language(CXX XC C ASM)
message(STATUS "CAME HERE")
add_custom_target("runners" ALL)
add_custom_command(
TARGET runners
COMMAND python generate_unity_runners.py
COMMENT "generate unity runners"
)
message(STATUS "CAME HERE 1")
file( GLOB APP_SOURCES src/test*.xc )
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
foreach( testsourcefile ${APP_SOURCES} )
get_filename_component(ITEM_NAME ${testsourcefile} NAME_WE)
message(STATUS "item_name " ${ITEM_NAME})
add_executable(${ITEM_NAME})
set(APP_COMPILER_FLAGS
"-O2"
"-g"
"-Wall"
"-report"
"-fxscope"
"-target=XCORE-AI-EXPLORER"
"${CMAKE_CURRENT_SOURCE_DIR}/config.xscope"
"-DUNITY_SUPPORT_64"
"-DUNITY_INCLUDE_DOUBLE"
)
set_source_files_properties(
"runners/${ITEM_NAME}/${ITEM_NAME}_Runner.c"
PROPERTIES GENERATED TRUE
)
set(APP_SRCS
${testsourcefile}
"runners/${ITEM_NAME}/${ITEM_NAME}_Runner.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../Unity/src/unity.c"
)
set(APP_INCLUDES
"src"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../Unity/src"
)
set(APP_DEPENDENT_MODULES
"lib_xua(>=1.3.0)"
"lib_logging(>=3.0.0)"
"lib_xassert(>=4.0.0)"
"lib_xud(>=1.0.0)"
"lib_spdif(>=4.0.0)"
"lib_mic_array(>=4.0.0)"
)
include("$ENV{XUA_PATH}/cmake_utils/xua.cmake")
set_target_properties(${ITEM_NAME} PROPERTIES OUTPUT_NAME ${ITEM_NAME}.xe)
target_compile_options(${ITEM_NAME} PRIVATE ${APP_COMPILER_FLAGS})
target_include_directories(${ITEM_NAME}
PRIVATE ${APP_INCLUDES}
PRIVATE ${XUA_INCLUDES_ALL}
)
target_sources(${ITEM_NAME}
PRIVATE ${APP_SRCS}
PRIVATE ${XUA_SRCS_ALL}
)
add_dependencies(${ITEM_NAME} runners)
target_link_options(${ITEM_NAME} PRIVATE ${APP_COMPILER_FLAGS})
## Set any additional flags only for C++
set(CMAKE_CXX_FLAGS "-std=c++11")
endforeach( testsourcefile ${APP_SOURCES} )
message(STATUS ${APP_SOURCES})
message(STATUS "CAME HERE 2")
## Register the application
#XMOS_REGISTER_APP()

View File

@@ -0,0 +1,32 @@
# xua_unit_tests test application
This example builds the xua_unit_tests application for XCORE AI
## Prerequisites for building
[XMOS Toolchain 15.0.3](https://www.xmos.com/software/tools/) or newer.
Install [CMake](https://cmake.org/download/) version 3.13 or newer.
## Building for xCORE
Set environment variable for lib_xua path:
> export XUA_PATH=<path to lib_xua>
cd to lib_xua/tests/xua_unit_tests
Run cmake and build
> cmake .
> make
## Run on hardware
Ensure your XCORE AI EXPLORER board is powered up and connected to the XTAG debugger.
Make sure the input.wav file is copied into the build directory
> pytest -n 1
You should see the tests collected by pytest pass