-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
212 lines (179 loc) · 7.44 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#
# CMakeLists.txt
#
# Copyright (C) 2015, GreenSocs ltd.
#
# Developped by Frederic Konrad <[email protected]>
# and Guillaume Delbrgue <[email protected]>
#
cmake_minimum_required(VERSION 2.8)
include(ExternalProject)
project(NVDLA_VIRTUAL_PLATFORM)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
set(INCLUDE_DIRS include)
include_directories(${INCLUDE_DIRS})
if (AWS_FPGA_PRESENT)
set(AWS_FPGA_CFLAGS "-DAWS_FPGA_PRESENT=1")
else ()
set(AWS_FPGA_CFLAGS "-DAWS_FPGA_PRESENT=0")
endif ()
if (REGISTER_ACCESS_TRACE)
set(TRACE_CFLAGS "-DREGISTER_ACCESS_TRACE=1")
endif ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSC_INCLUDE_DYNAMIC_PROCESSES -Wall -Werror ${AWS_FPGA_CFLAGS} ${TRACE_CFLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSC_INCLUDE_DYNAMIC_PROCESSES -Wall -Werror -DDEBUG_LOG=1 ${AWS_FPGA_CFLAGS} ${TRACE_CFLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DSC_INCLUDE_DYNAMIC_PROCESSES -Wall -Werror ${AWS_FPGA_CFLAGS} ${TRACE_CFLAGS}")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
#REQUIRED LIBRARIES.
find_package(SystemC)
if(SystemC_FOUND)
include_directories(${SystemC_INCLUDE_DIRS})
else()
message( FATAL_ERROR "SystemC library not found." )
endif()
find_package(TLM)
if(TLM_FOUND)
include_directories(${TLM_INCLUDE_DIRS})
else()
message( FATAL_ERROR "TLM library not found." )
endif()
find_package(Lua REQUIRED)
if(LUA_FOUND)
include_directories(${LUA_INCLUDE_DIR})
else()
message( FATAL_ERROR "LUA library not found." )
endif()
find_package(NvdlaCmod)
if(NVDLA_CMOD_FOUND)
link_directories(${NVDLA_CMOD_LIBRARY_DIR})
else()
message( FATAL_ERROR "NVDLA CMOD library not found." )
endif()
if(AWS_FPGA_PRESENT)
find_package(AWSSDK)
if(AWSSDK_FOUND)
include_directories(${AWSSDK_INCLUDE_DIRS})
link_directories(${AWSSDK_LIBRARY_DIRS})
else()
message( FATAL_ERROR "AWSSDK library not found." )
endif()
endif()
add_subdirectory(libs/greenlib)
include_directories(libs/greenlib/greencontrol/include
libs/greenlib/greenmemory/include
libs/greenlib/greenscript/include
libs/greenlib/greensignalbus/include
libs/greenlib/greensocket/include
libs/greenlib/greenmessage/include
libs/greenlib/greenrouter/include
libs/greenlib/greenserialsocket/include
libs/greenlib/greensignalsocket/include
libs/greenlib/gsgpsocket/include
libs/greenlib/greenreg/include
libs/greenlib/include
)
link_directories(${CMAKE_SOURCE_DIR}/libs/greenlib/greenreg/lib
${CMAKE_SOURCE_DIR}/libs/greenlib/greencontrol/lib
${CMAKE_SOURCE_DIR}/libs/greenlib/greenmemory/lib
${CMAKE_SOURCE_DIR}/libs/greenlib/greenscript/lib
${CMAKE_SOURCE_DIR}/libs/greenlib/greensignalbus/lib
${CMAKE_SOURCE_DIR}/libs/greenlib/greensocket/lib
${CMAKE_SOURCE_DIR}/libs/greenlib/greenmessage/lib
${CMAKE_SOURCE_DIR}/libs/greenlib/greenrouter/lib
${CMAKE_SOURCE_DIR}/libs/greenlib/greenserialsocket/lib
${CMAKE_SOURCE_DIR}/libs/greenlib/greensignalsocket/lib
${CMAKE_SOURCE_DIR}/libs/greenlib/gsgpsocket/lib
)
set(GREENLIB_FOUND TRUE)
set(GREENLIB_LIBRARY_DIRS ${CMAKE_SOURCE_DIR}/libs/greenlib/greenreg/lib)
set(GREENLIB_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/greenlib/greencontrol/include)
set(GREENLIB_FOUND TRUE)
set(GREENLIB_LIBRARY_DIRS ${CMAKE_SOURCE_DIR}/libs/greenlib/greenreg/lib)
set(GREENLIB_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/greenlib/greencontrol/include)
add_subdirectory(libs/tlm2c libs/tlm2c.build/lib)
include_directories(libs/tlm2c/include)
link_directories(${CMAKE_SOURCE_DIR}/libs/tlm2c.build)
file(COPY libs/tlm2c/include DESTINATION libs/tlm2c.build/)
set(TLM2C_FOUND TRUE)
set(TLM2C_LIBRARY_DIRS ${CMAKE_SOURCE_DIR}/libs/tlm2c.build)
set(TLM2C_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/tlm2c/include)
add_subdirectory(libs/log libs/log.build/lib)
include_directories(libs/log/include)
link_directories(${CMAKE_SOURCE_DIR}/libs/log.build)
file(COPY libs/log/include DESTINATION libs/log.build/)
set(LOG_FOUND TRUE)
set(LOG_LIBRARY_DIRS ${CMAKE_SOURCE_DIR}/libs/log.build)
set(LOG_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/log/include)
add_subdirectory(models/cpu models/cpu.build)
include_directories(models/cpu/include)
link_directories(${CMAKE_SOURCE_DIR}/models/cpu.build)
set(SIMPLECPU_FOUND TRUE)
set(SIMPLECPU_LIBRARY_DIRS ${CMAKE_SOURCE_DIR}/models/cpu.build)
set(SIMPLECPU_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/models/cpu/include)
add_subdirectory(models/memory models/memory.build)
include_directories(models/memory/include)
link_directories(${CMAKE_SOURCE_DIR}/models/memory.build)
add_subdirectory(models/nvdla models/nvdla.build)
include_directories(models/nvdla/include)
link_directories(${CMAKE_SOURCE_DIR}/models/nvdla.build)
if(AWS_FPGA_PRESENT)
add_subdirectory(fpga/aws-fpga/fpga_sc_wrapper fpga/aws-fpga/fpga_sc_wrapper.build)
include_directories(fpga/aws-fpga/fpga_sc_wrapper/include)
link_directories(${CMAKE_SOURCE_DIR}/fpga/aws-fpga/fpga_sc_wrapper.build)
endif()
add_subdirectory(fpga/aws-fpga/cosim_sc_wrapper fpga/aws-fpga/cosim_sc_wrapper.build)
include_directories(fpga/aws-fpga/cosim_sc_wrapper/include)
link_directories(${CMAKE_SOURCE_DIR}/fpga/aws-fpga/cosim_sc_wrapper.build)
### QBOX ###
if (CMAKE_BUILD_TYPE MATCHES Debug)
set(QBOX_DEBUG_BUILD --enable-debug)
else ()
set(QBOX_DEBUG_BUILD --disable-debug-info)
endif ()
ExternalProject_Add(qbox
SOURCE_DIR ${CMAKE_SOURCE_DIR}/libs/qbox
INSTALL_DIR ${CMAKE_SOURCE_DIR}/libs/qbox.build
BINARY_DIR ${CMAKE_SOURCE_DIR}/libs/qbox.build
TMP_DIR ${CMAKE_SOURCE_DIR}/libs/qbox.build/tmp
STAMP_DIR ${CMAKE_SOURCE_DIR}/libs/qbox.build/stampdir
CONFIGURE_COMMAND ${CMAKE_SOURCE_DIR}/libs/qbox/configure --target-list=aarch64-softmmu --disable-xfsctl ${QBOX_DEBUG_BUILD} --library --qbox --nvdla --with-tlm2c=${CMAKE_SOURCE_DIR}/libs/tlm2c.build --prefix=${CMAKE_SOURCE_DIR}/libs/qbox.build --disable-pie --disable-werror --extra-cflags=-fPIC\ -fpic\ -ftls-model=initial-exec\ -DNVDLA_HW_VERSION=${NVDLA_HW_VERSION}\ -DNVDLA_HW_PROJECT=${NVDLA_HW_PROJECT}\ ${AWS_FPGA_CFLAGS}
PREFIX ${CMAKE_SOURCE_DIR}/libs/qbox.build
BUILD_COMMAND $(MAKE)
)
ExternalProject_Add_Step(qbox force-build
DEPENDEES update
DEPENDERS build
ALWAYS 1
)
add_dependencies(qbox tlm2c)
link_directories(${CMAKE_SOURCE_DIR}/libs/qbox.build/aarch64-softmmu)
install(FILES ${CMAKE_SOURCE_DIR}/libs/qbox.build/aarch64-softmmu/libqbox-nvdla${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION lib)
### Toplevel ###
add_executable(aarch64_toplevel src/aarch64_toplevel.cpp)
add_dependencies(aarch64_toplevel
simplecpu
qbox
nvdla
)
target_link_libraries(aarch64_toplevel ${SystemC_LIBRARIES}
${LUA_LIBRARIES}
qbox-nvdla
greenreg
greenscript
simplecpu
dl
tlm2c
log
nvdla
)
if(AWS_FPGA_PRESENT)
add_dependencies(aarch64_toplevel fpga_sc_wrapper)
target_link_libraries(aarch64_toplevel fpga_sc_wrapper)
set_target_properties(aarch64_toplevel PROPERTIES COMPILE_FLAGS "-std=c++11 -Wno-deprecated-declarations -DCONFIG_LOGLEVEL=4")
endif()
add_dependencies(aarch64_toplevel cosim_sc_wrapper)
target_link_libraries(aarch64_toplevel cosim_sc_wrapper)
set_target_properties(aarch64_toplevel PROPERTIES COMPILE_FLAGS "-std=c++11 -Wno-deprecated-declarations -DCONFIG_LOGLEVEL=4")
install(TARGETS aarch64_toplevel DESTINATION bin)