-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
163 lines (140 loc) · 5.48 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
#
# 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})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSC_INCLUDE_DYNAMIC_PROCESSES -Wall -Werror")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSC_INCLUDE_DYNAMIC_PROCESSES -Wall -Werror -DDEBUG_LOG=1")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DSC_INCLUDE_DYNAMIC_PROCESSES -Wall -Werror")
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()
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)
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)
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)
### 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 --extra-cflags=-fPIC\ -fpic\ -ftls-model=initial-exec\ -DNVDLA_HW_VERSION=${NVDLA_HW_VERSION}
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
)
install(TARGETS aarch64_toplevel DESTINATION bin)