43 lines
1.3 KiB
CMake
43 lines
1.3 KiB
CMake
cmake_minimum_required(VERSION 3.22)
|
|
|
|
project(am-kernels)
|
|
set(CMAKE_C_STANDARD 11)
|
|
enable_language(C ASM)
|
|
include(CheckPIESupported)
|
|
include(GNUInstallDirs)
|
|
|
|
if(${ARCH} STREQUAL "native")
|
|
include(CTest)
|
|
endif()
|
|
|
|
find_package(am-${ARCH})
|
|
find_package(klib)
|
|
|
|
check_pie_supported()
|
|
|
|
# -- Helper functions
|
|
macro(create_binary target_name)
|
|
if(NOT ${ARCH} STREQUAL "native")
|
|
add_custom_command(
|
|
TARGET ${target_name} POST_BUILD
|
|
COMMAND ${CMAKE_OBJCOPY} -S --set-section-flags .bss=alloc,contents -O binary ${target_name} ${target_name}.bin
|
|
COMMENT "Creating binary file ${target_name}.bin"
|
|
)
|
|
endif()
|
|
endmacro(create_binary)
|
|
|
|
macro(install_target_and_binary target_name)
|
|
if(NOT ${ARCH} STREQUAL "native")
|
|
install(TARGETS ${target_name} RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/am-kernels)
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${target_name}.bin DESTINATION ${CMAKE_INSTALL_DATADIR}/am-kernels)
|
|
else()
|
|
install(TARGETS ${target_name})
|
|
add_test(NAME ${target_name}_test COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${target_name})
|
|
endif()
|
|
endmacro(install_target_and_binary)
|
|
|
|
add_subdirectory(tests/cpu-tests)
|
|
# add_subdirectory(tests/alu-tests)
|
|
add_subdirectory(tests/am-tests)
|
|
add_subdirectory(benchmarks/microbench)
|
|
add_subdirectory(kernels)
|