-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
78 lines (63 loc) · 1.9 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
cmake_minimum_required(VERSION 3.14)
#**********************
# Setup XMOS toolchain
#**********************
set(CMAKE_C_COMPILER "xcc")
set(CMAKE_AR "xmosar")
set(CMAKE_C_COMPILER_AR "xmosar")
set(CMAKE_RANLIB "")
set(CMAKE_C_COMPILER_FORCED TRUE)
set(CMAKE_ASM_COMPILER_FORCED TRUE)
set(CMAKE_C_FLAGS "" CACHE STRING "C Compiler Base Flags" FORCE)
set(CMAKE_EXE_LINKER_FLAGS "" CACHE INTERNAL "" FORCE)
enable_language(C ASM)
#**********************
# Setup project
#**********************
project(hello_world VERSION 1.0.0)
#**********************
# Disable in-source build.
#**********************
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "In-source build is not allowed! Please specify a build folder.\n\tex:cmake -B build")
endif()
#**********************
# install
#**********************
set(INSTALL_DIR "${PROJECT_SOURCE_DIR}/bin")
#**********************
# Build flags
#**********************
set(BUILD_FLAGS
"-target=XCORE-AI-EXPLORER"
"-mcmodel=large"
"-fxscope"
"${CMAKE_CURRENT_SOURCE_DIR}/config.xscope"
"-Wno-xcore-fptrgroup"
"-Wno-unknown-pragmas"
"-report"
"-DBARE_METAL"
"-DNDEBUG"
"-march=xs3a"
"-Os"
)
add_executable(hello_world)
target_compile_options(hello_world PRIVATE ${BUILD_FLAGS})
target_link_options(hello_world PRIVATE ${BUILD_FLAGS})
set_target_properties(hello_world PROPERTIES OUTPUT_NAME hello_world.xe)
#**********************
# targets
#**********************
include("${CMAKE_CURRENT_SOURCE_DIR}/../../lib_dispatch.cmake")
set(LIB_DISPATCH_SOURCES ${LIB_DISPATCH_METAL_SOURCES})
target_sources(hello_world
PRIVATE ${LIB_DISPATCH_SOURCES}
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/main.c"
PRIVATE ${HELLO_WORLD_SOURCES}
)
target_include_directories(hello_world
PRIVATE ${LIB_DISPATCH_INCLUDES}
PRIVATE ${HELLO_WORLD_INCLUDES}
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src"
)
install(TARGETS hello_world DESTINATION ${INSTALL_DIR})