#project(bsp)

# create bsp library
FILE(GLOB_RECURSE LIB_SRC_NOASM
        "${CMAKE_CURRENT_LIST_DIR}/*.cpp"
        "${CMAKE_CURRENT_LIST_DIR}/*.c"
        )

FILE(GLOB_RECURSE ASSEMBLY_FILES
        "${CMAKE_CURRENT_LIST_DIR}/*.s"
        "${CMAKE_CURRENT_LIST_DIR}/*.S"
        )
SET(LIB_SRC ${LIB_SRC_NOASM} ${ASSEMBLY_FILES})

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_LIST_DIR}/include)

SET_PROPERTY(SOURCE ${ASSEMBLY_FILES} PROPERTY LANGUAGE C)
SET_SOURCE_FILES_PROPERTIES(${ASSEMBLY_FILES} PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp -D __riscv64")

ADD_LIBRARY(posix STATIC ${LIB_SRC})
SET_TARGET_PROPERTIES(posix PROPERTIES LINKER_LANGUAGE C)
TARGET_LINK_LIBRARIES(posix PRIVATE freertos)
TARGET_INCLUDE_DIRECTORIES(posix PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)