build: add more tests to build system

This commit is contained in:
xinyangli 2024-07-09 17:42:46 +08:00
parent 2f559823a6
commit 9d41ac2f7b
Signed by: xin
SSH key fingerprint: SHA256:qZ/tzd8lYRtUFSrfBDBMcUqV4GHKxqeqRA3huItgvbk
12 changed files with 107 additions and 17 deletions

View file

@ -0,0 +1,14 @@
add_executable(hello
hello.c
)
target_include_directories(hello PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include)
target_link_libraries(hello PRIVATE am-${ARCH} klib npcgcc)
target_compile_options(hello PRIVATE -nostdlib -nodefaultlibs)
target_link_options(hello PRIVATE -nostdlib -nodefaultlibs)
# -- Extract binary file from ELF
add_custom_command(TARGET hello
COMMAND ${CMAKE_OBJCOPY} ARGS -S --set-section-flags .bss=alloc,contents -O binary hello hello.bin)
install(TARGETS hello RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/am-kernels)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/hello.bin DESTINATION ${CMAKE_INSTALL_DATADIR}/am-kernels)