build: add cmake as build system
This commit is contained in:
parent
bb725d6f82
commit
2f559823a6
4 changed files with 73 additions and 1 deletions
16
CMakeLists.txt
Normal file
16
CMakeLists.txt
Normal file
|
@ -0,0 +1,16 @@
|
|||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
project(am-kernels)
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
enable_language(C ASM)
|
||||
|
||||
include(CheckPIESupported)
|
||||
check_pie_supported()
|
||||
|
||||
if(${PLATFORM} MATCHES "native")
|
||||
set(ARCH "native")
|
||||
else()
|
||||
set(ARCH ${ISA}-${PLATFORM})
|
||||
endif()
|
||||
|
||||
add_subdirectory(tests/cpu-tests)
|
3
tests/cpu-tests/CMakeLists.txt
Normal file
3
tests/cpu-tests/CMakeLists.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
|
||||
include_directories(include)
|
||||
add_subdirectory(tests)
|
|
@ -15,7 +15,7 @@ all: $(addprefix Makefile., $(ALL))
|
|||
$(ALL): %: Makefile.%
|
||||
|
||||
Makefile.%: tests/%.c latest
|
||||
@/bin/echo -e "NAME = $*\nSRCS = $<\ninclude $${AM_HOME}/Makefile" > $@
|
||||
@echo -e "NAME = $*\nSRCS = $<\ninclude $${AM_HOME}/Makefile" > $@
|
||||
@if make -s -f $@ ARCH=$(ARCH) $(MAKECMDGOALS); then \
|
||||
printf "[%14s] $(COLOR_GREEN)PASS$(COLOR_NONE)\n" $* >> $(RESULT); \
|
||||
else \
|
||||
|
|
53
tests/cpu-tests/tests/CMakeLists.txt
Normal file
53
tests/cpu-tests/tests/CMakeLists.txt
Normal file
|
@ -0,0 +1,53 @@
|
|||
find_package(am-${ARCH})
|
||||
find_package(klib)
|
||||
|
||||
set(SOURCES
|
||||
add.c
|
||||
add-longlong.c
|
||||
bit.c
|
||||
bubble-sort.c
|
||||
crc32.c
|
||||
div.c
|
||||
dummy.c
|
||||
fact.c
|
||||
fib.c
|
||||
goldbach.c
|
||||
hello-str.c
|
||||
if-else.c
|
||||
leap-year.c
|
||||
load-store.c
|
||||
matrix-mul.c
|
||||
max.c
|
||||
mersenne.c
|
||||
min3.c
|
||||
mov-c.c
|
||||
movsx.c
|
||||
mul-longlong.c
|
||||
pascal.c
|
||||
prime.c
|
||||
quick-sort.c
|
||||
recursion.c
|
||||
select-sort.c
|
||||
shift.c
|
||||
shuixianhua.c
|
||||
string.c
|
||||
sub-longlong.c
|
||||
sum.c
|
||||
switch.c
|
||||
to-lower-case.c
|
||||
unalign.c
|
||||
wanshu.c)
|
||||
|
||||
foreach(SOURCE IN LISTS SOURCES)
|
||||
get_filename_component(SOURCE_NAME ${SOURCE} NAME_WLE)
|
||||
add_executable(${SOURCE_NAME}
|
||||
${SOURCE})
|
||||
target_link_libraries(${SOURCE_NAME} PRIVATE am-${ARCH})
|
||||
|
||||
# -- Extract binary file from ELF
|
||||
add_custom_command(TARGET ${SOURCE_NAME}
|
||||
COMMAND ${CMAKE_OBJCOPY} ARGS -S --set-section-flags .bss=alloc,contents -O binary ${SOURCE_NAME} ${SOURCE_NAME}.bin)
|
||||
|
||||
install(TARGETS ${SOURCE_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_DATADIR}/elf)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${SOURCE_NAME}.bin DESTINATION ${CMAKE_INSTALL_DATADIR}/binary)
|
||||
endforeach()
|
Loading…
Reference in a new issue