add_library(blink STATIC
    blink.c
)

target_include_directories(blink PUBLIC
    ${CMAKE_CURRENT_LIST_DIR}
)

if(NOT UNIT_TESTING)
# The `-ffunction-sections` and `-fdata-sections` need to be used 
# in the compile and linker options otherwise it doesnt't
# correctly remove the unused functions.
    target_compile_options(blink PUBLIC
        -g
        -Os
        -flto
        -ffunction-sections
        -fdata-sections
        -fmessage-length=0
        -msmall-data-limit=8
        -march=rv32ec
        -mabi=ilp32e
        -DCH32V003=1
    )

#    target_link_options(blink PUBLIC
#        -flto
#        -ffunction-sections
#        -fdata-sections
#        -fmessage-length=0
#        -msmall-data-limit=8
#        -march=rv32ec
#        -mabi=ilp32e
#        -static-libgcc
#        -nostdlib
#        -L${CMAKE_SOURCE_DIR}/src
#        -Wl,--print-memory-usage
#        -Wl,-Map=${PROJECT_NAME}.map
#        -Wl,--gc-sections
#        -T${CMAKE_SOURCE_DIR}/src/linker_script.ld
#    )
endif()

