add first version of cmake
This commit is contained in:
58
benchmarks/dhrystone/CMakeLists.txt
Normal file
58
benchmarks/dhrystone/CMakeLists.txt
Normal file
@ -0,0 +1,58 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
project(dhrystone C)
|
||||
|
||||
# Include BSP libwrap
|
||||
include(${BSP_BASE}/libwrap/CMakeLists.txt)
|
||||
|
||||
# Source files
|
||||
set(SOURCES
|
||||
dhry_1.c
|
||||
dhry_2.c
|
||||
dhry_stubs.c
|
||||
)
|
||||
|
||||
# Create executable
|
||||
add_executable(dhrystone ${SOURCES})
|
||||
|
||||
# Include directories
|
||||
target_include_directories(dhrystone PRIVATE
|
||||
${BSP_BASE}/include
|
||||
${BSP_BASE}/drivers
|
||||
${BSP_BASE}/env
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
# Link with libwrap
|
||||
target_link_libraries(dhrystone PRIVATE
|
||||
LIBWRAP_TGC
|
||||
)
|
||||
|
||||
# Add compile definitions
|
||||
target_compile_definitions(dhrystone PRIVATE
|
||||
BOARD_${BOARD}
|
||||
)
|
||||
|
||||
# Set compile options
|
||||
target_compile_options(dhrystone PRIVATE
|
||||
-march=${RISCV_ARCH}_zicsr_zifencei
|
||||
-mabi=${RISCV_ABI}
|
||||
-mcmodel=medany
|
||||
-ffunction-sections
|
||||
-fdata-sections
|
||||
-O2 # Optimization level for benchmarking
|
||||
-DTIME # Enable time measurement
|
||||
-DNOENUM # Disable enum usage as per dhrystone requirements
|
||||
)
|
||||
|
||||
# Set linker options
|
||||
target_link_options(dhrystone PRIVATE
|
||||
-T${BSP_BASE}/env/${BOARD}/link.ld
|
||||
-nostartfiles
|
||||
-Wl,--gc-sections
|
||||
${LIBWRAP_TGC_LDFLAGS}
|
||||
)
|
||||
|
||||
# Install target
|
||||
install(TARGETS dhrystone
|
||||
RUNTIME DESTINATION bin
|
||||
)
|
Reference in New Issue
Block a user