forked from ROCm/ROCclr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
227 lines (195 loc) · 7.09 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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
project(vdi)
cmake_minimum_required(VERSION 3.5)
#example command:
#cmake -DOPENCL_DIR=/path to/opencl ..
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
set(USE_COMGR_LIBRARY "yes")
add_definitions(-DUSE_COMGR_LIBRARY -DCOMGR_DYN_DLL)
add_definitions(-DBSD_LIBELF)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options("-Wno-ignored-attributes")
endif()
find_package(amd_comgr REQUIRED CONFIG
PATHS
/opt/rocm/
PATH_SUFFIXES
cmake/amd_comgr
lib/cmake/amd_comgr
)
MESSAGE(STATUS "Code Object Manager found at ${amd_comgr_DIR}.")
find_path(COMGR_INCLUDE
NAMES amd_comgr.h
PATH_SUFFIXES include
PATHS /opt/rocm
)
find_library( OpenCL REQUIRED CONFIG
PATHS
/opt/rocm
)
if( NOT OPENCL_DIR )
find_path(OPENCL_INCLUDE_DIR
NAMES OpenCL/cl.h CL/cl.h
PATH_SUFFIXES include opencl/include inc include/x86_64 include/x64
PATHS /opt/rocm
DOC "OpenCL include header OpenCL/cl.h or CL/cl.h"
)
if( NOT OPENCL_INCLUDE_DIR )
unset(OPENCL_INCLUDE_DIR CACHE)
set(OPENCL_INCLUDE_DIR "" CACHE PATH "" FORCE )
endif()
MESSAGE(STATUS "Opencl found at ${OPENCL_INCLUDE_DIR}.")
endif()
find_package(ROCT REQUIRED)
find_package(ROCR REQUIRED)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC")
add_definitions(-DLINUX -D__x86_64__ -D__AMD64__ -DUNIX_OS -DqLittleEndian -DOPENCL_MAJOR=2 -DOPENCL_MINOR=1 -DWITH_AQL -DWITH_ONLINE_COMPILER -DATI_OS_LINUX -DATI_ARCH_X86 -DLITTLEENDIAN_CPU -DATI_BITS_64 -DATI_COMP_GCC -DWITH_TARGET_AMDGCN -DOPENCL_EXPORTS -DCL_USE_DEPRECATED_OPENCL_1_0_APIS -DCL_USE_DEPRECATED_OPENCL_1_1_APIS -DCL_USE_DEPRECATED_OPENCL_1_2_APIS -DCL_USE_DEPRECATED_OPENCL_2_0_APIS -DVEGA10_ONLY=false -DWITH_LIGHTNING_COMPILER)
add_definitions(-DOPENCL_C_MAJOR=2 -DOPENCL_C_MINOR=0)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bsymbolic -Wl,--unresolved-symbols=report-all")
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
if(CMAKE_BUILD_TYPE MATCHES "^Debug$")
add_definitions(-DDEBUG)
endif()
include_directories(${ROCR_INCLUDES})
if (DEFINED LLVM_INCLUDES AND NOT ${LLVM_INCLUDES} STREQUAL "")
include_directories(${LLVM_INCLUDES})
endif() # if (DEFINED LLVM_INCLUDES AND NOT ${LLVM_INCLUDES} STREQUAL "")
include_directories(${CMAKE_SOURCE_DIR})
include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${CMAKE_SOURCE_DIR}/device/rocm)
include_directories(${OPENCL_DIR})
include_directories(${OPENCL_DIR}/amdocl)
include_directories(${OPENCL_DIR}/khronos)
include_directories(${OPENCL_DIR}/khronos/headers)
include_directories(${OPENCL_DIR}/khronos/headers/opencl2.2)
include_directories(${OPENCL_INCLUDE_DIR})
include_directories(${COMGR_INCLUDE})
include_directories(${CMAKE_SOURCE_DIR}/compiler/lib)
include_directories(${CMAKE_SOURCE_DIR}/compiler/lib/include)
include_directories(${CMAKE_SOURCE_DIR}/compiler/lib/backends/common)
include_directories(${CMAKE_SOURCE_DIR}/elf/utils/common)
include_directories(${CMAKE_SOURCE_DIR}/elf/utils/libelf)
option(BUILD_PAL "Build PAL backend" OFF)
if (BUILD_PAL)
add_definitions(-DWITH_PAL_DEVICE)
add_subdirectory(device/pal)
add_definitions(-DAMD_LIBELF)
add_subdirectory(compiler/sc/HSAIL)
else ()
add_definitions(-DWITH_HSA_DEVICE)
add_subdirectory(device/rocm)
endif()
#find_package(amd_comgr REQUIRED CONFIG)
include_directories("$<TARGET_PROPERTY:amd_comgr,INTERFACE_INCLUDE_DIRECTORIES>")
set(COMGR_CPP device/comgrctx.cpp)
add_subdirectory( elf/utils/libelf "${CMAKE_CURRENT_BINARY_DIR}/libelf" )
add_library(oclruntime OBJECT
thread/thread.cpp
thread/monitor.cpp
thread/semaphore.cpp
utils/flags.cpp
utils/debug.cpp
device/appprofile.cpp
device/device.cpp
device/hwdebug.cpp
device/blitcl.cpp
device/blit.cpp
device/devkernel.cpp
device/devwavelimiter.cpp
device/devprogram.cpp
platform/activity.cpp
platform/kernel.cpp
platform/context.cpp
platform/command.cpp
platform/ndrange.cpp
platform/runtime.cpp
platform/object.cpp
platform/memory.cpp
platform/program.cpp
platform/commandqueue.cpp
platform/agent.cpp
os/os_win32.cpp
os/alloc.cpp
os/os.cpp
os/os_posix.cpp
compiler/lib/utils/options.cpp
elf/elf.cpp
elf/elf_utils.cpp
#${CMAKE_SOURCE_DIR}/compiler/tools/caching/cache.cpp
${COMGR_CPP}
)
set_target_properties(oclruntime PROPERTIES POSITION_INDEPENDENT_CODE ON)
add_library(amdvdi_static STATIC
$<TARGET_OBJECTS:oclruntime>
$<TARGET_OBJECTS:oclelf_obj>
)
set_target_properties(amdvdi_static PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_link_libraries(amdvdi_static PUBLIC Threads::Threads)
target_link_libraries(amdvdi_static PUBLIC dl ${ROCT_LIBRARIES} ${ROCR_LIBRARIES} )
if (BUILD_PAL)
target_sources(amdvdi_static PRIVATE $<TARGET_OBJECTS:vdipal>)
target_link_libraries(amdvdi_static PRIVATE amdhsaloader)
target_link_libraries(amdvdi_static PRIVATE pal)
export(TARGETS amdvdi_static vdipal amdhsaloader amdhsacode pal addrlib vam metrohash cwpack gpuopen ddCore mpack rapidjson
FILE "${CMAKE_CURRENT_BINARY_DIR}/amdvdi_staticTargets.cmake"
)
else()
target_sources(amdvdi_static PRIVATE $<TARGET_OBJECTS:oclrocm>)
export(TARGETS amdvdi_static
FILE "${CMAKE_CURRENT_BINARY_DIR}/amdvdi_staticTargets.cmake"
)
endif()
if (UNIX)
set(VDI_DEFAULT_INSTALL_PREFIX "/opt/rocm/vdi")
endif()
#comment out as it's not available in cmake 3.5
#if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
if(NOT CMAKE_INSTALL_PREFIX)
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH "Installation path for vdi" FORCE)
#elseif(CMAKE_BUILD_TYPE MATCHES Release)
else()
set(CMAKE_INSTALL_PREFIX ${VDI_DEFAULT_INSTALL_PREFIX} CACHE PATH "Installation path for vdi" FORCE)
# message(FATAL_ERROR "Invalid CMAKE_BUILD_TYPE specified. Valid values are Debug and Release")
endif()
#endif()
endif()
message("cmake install path ${CMAKE_INSTALL_PREFIX}")
install( TARGETS amdvdi_static ARCHIVE DESTINATION lib LIBRARY DESTINATION lib COMPONENT applications)
FILE(GLOB headerfiles "${CMAKE_CURRENT_SOURCE_DIR}/*.h*")
INSTALL (
FILES ${headerfiles}
DESTINATION include)
INSTALL (
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include"
DESTINATION include
FILES_MATCHING PATTERN "*.h*")
INSTALL (
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/elf"
DESTINATION include
FILES_MATCHING PATTERN "*.h*")
INSTALL (
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/compiler"
DESTINATION include
FILES_MATCHING PATTERN "*.h*")
INSTALL (
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/utils"
DESTINATION include
FILES_MATCHING PATTERN "*.h*")
INSTALL (
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/platform"
DESTINATION include
FILES_MATCHING PATTERN "*.h*")
INSTALL (
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/thread"
DESTINATION include
FILES_MATCHING PATTERN "*.h*")
INSTALL (
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/os"
DESTINATION include
FILES_MATCHING PATTERN "*.h*")
INSTALL (
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/device"
DESTINATION include
FILES_MATCHING PATTERN "*.h*")