-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
107 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
# Options | ||
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF ) | ||
option(CMAKE_BUILD_TYPE "Build type" Debug ) | ||
option(STATIC_LINKING "Link statically" TRUE ) | ||
|
||
option(X86 "Build for x86" OFF ) | ||
option(RISCV "Build for RISC-V" OFF ) | ||
|
||
|
||
add_library(target-riscv INTERFACE) | ||
target_compile_features(target-riscv INTERFACE c_std_11) | ||
|
||
add_library(target-x86 INTERFACE) | ||
target_compile_features(target-x86 INTERFACE c_std_11) | ||
|
||
target_link_options(target-x86 INTERFACE -static) | ||
target_link_options(target-riscv INTERFACE -static) | ||
|
||
target_compile_options(target-x86 INTERFACE -march=native) | ||
target_link_options(target-x86 INTERFACE -march=native) | ||
|
||
|
||
set(WRAP_SPECS_FILE "htif_wrap.specs") | ||
set(SPECS_FILE "htif_nano.specs") | ||
set(LIBGLOSS_DIR "$ENV{RISCV}/riscv64-unknown-elf/lib/") | ||
|
||
target_compile_options(target-riscv INTERFACE -fno-common -fno-builtin-printf) | ||
target_compile_options(target-riscv INTERFACE -mcmodel=medany -march=rv64gcv_zfh -mabi=lp64d) | ||
target_compile_options(target-riscv INTERFACE -Wl,-Map=output.map -specs=${SPECS_FILE} -specs=${WRAP_SPECS_FILE} -T ${CMAKE_SOURCE_DIR}/htif.ld) | ||
target_link_options(target-x86 INTERFACE -fno-common -fno-builtin-printf) | ||
target_link_options(target-riscv INTERFACE -mcmodel=medany -march=rv64gcv_zfh -mabi=lp64d) | ||
target_link_options(target-riscv INTERFACE -Wl,-Map=output.map -specs=${SPECS_FILE} -specs=${WRAP_SPECS_FILE} -T ${CMAKE_SOURCE_DIR}/htif.ld) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
cmake_minimum_required(VERSION 3.10) | ||
|
||
project(test LANGUAGES C) | ||
|
||
|
||
add_executable(test src/main.c) | ||
target_include_directories(test PUBLIC inc) | ||
|
||
target_compile_features(test INTERFACE c_std_11) | ||
|
||
if (X86) | ||
message("test: building for x86") | ||
target_link_libraries(test PUBLIC target-x86) | ||
|
||
elseif (RISCV) | ||
message("test: building for RISC-V") | ||
# CMake toolchain definition for RISC-V GCC toolchain | ||
set(CMAKE_SYSTEM_NAME "Generic" CACHE STRING "") | ||
set(CMAKE_SYSTEM_PROCESSOR "riscv" CACHE STRING "") | ||
|
||
set(TOOLCHAIN_PREFIX "riscv64-unknown-elf-") | ||
|
||
set(CMAKE_C_COMPILER "${TOOLCHAIN_PREFIX}gcc") | ||
set(CMAKE_ASM_COMPILER "${TOOLCHAIN_PREFIX}gcc") | ||
set(CMAKE_CXX_COMPILER "${TOOLCHAIN_PREFIX}g++") | ||
set(CMAKE_AR "${TOOLCHAIN_PREFIX}ar") | ||
set(CMAKE_LINKER "{TOOLCHAIN_PREFIX}ld") | ||
set(CMAKE_OBJCOPY "${TOOLCHAIN_PREFIX}objcopy") | ||
set(CMAKE_SIZE "${TOOLCHAIN_PREFIX}size") | ||
set(CMAKE_STRIP "${TOOLCHAIN_PREFIX}ld") | ||
|
||
target_link_libraries(test PUBLIC target-riscv) | ||
endif () | ||
|
||
add_compile_options(-O3 -Wall -Wextra) | ||
|
||
target_compile_options(test PRIVATE -u _printf_float) | ||
|
||
add_subdirectory(../ ./build/) | ||
|
||
add_subdirectory(../nn/ ./build/nn) | ||
target_link_libraries(test PUBLIC nn) | ||
|
||
target_link_libraries(test PUBLIC m) | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.