-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
264 lines (233 loc) · 10.3 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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
# ===================== begin_copyright_notice ============================
#
# Copyright (C) 2023-2024 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
# ===================== end_copyright_notice ==============================
cmake_minimum_required(VERSION 3.13)
project(gits)
find_package(Python3 3.10 REQUIRED COMPONENTS Interpreter)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY TRUE)
option(WITH_VULKAN "Build Vulkan component" ON)
if(WITH_VULKAN)
add_definitions(-DWITH_VULKAN)
endif()
option(WITH_OPENCL "Build OpenCL component" ON)
if(WITH_OPENCL)
add_definitions(-DWITH_OPENCL)
endif()
option(WITH_LEVELZERO "Build LevelZero component" ON)
if(WITH_LEVELZERO)
add_definitions(-DWITH_LEVELZERO)
endif()
execute_process(COMMAND ${Python3_EXECUTABLE} -c "import mako" RESULT_VARIABLE MAKO_IMPORT OUTPUT_QUIET ERROR_QUIET)
if(NOT MAKO_IMPORT EQUAL 0)
message(FATAL_ERROR "Mako templates not installed. GITS requires Mako to generate files. Use 'pip install Mako' to install.")
endif()
execute_process(COMMAND ${Python3_EXECUTABLE} -c "import requests" RESULT_VARIABLE REQUESTS_IMPORT OUTPUT_QUIET ERROR_QUIET)
if(NOT REQUESTS_IMPORT EQUAL 0)
message(FATAL_ERROR "requests not installed. GITS requires requests to install dependencies. Use 'pip install requests' to install.")
endif()
execute_process(COMMAND ${Python3_EXECUTABLE} -c "import retrying" RESULT_VARIABLE RETRYING_IMPORT OUTPUT_QUIET ERROR_QUIET)
if(NOT RETRYING_IMPORT EQUAL 0)
message(FATAL_ERROR "retrying not installed. GITS requires retrying to install dependencies. Use 'pip install retrying' to install.")
endif()
option(WITH_OCLOC "Build Ocloc component" ON)
if(WITH_OCLOC)
add_definitions(-DWITH_OCLOC)
endif()
if(WIN32)
set(OpenGL_INSTALL_SUBDIR "FilesToCopyOGL" CACHE INTERNAL "")
set(OpenGLES_INSTALL_SUBDIR "FilesToCopyES" CACHE INTERNAL "")
set(OpenCL_INSTALL_SUBDIR "FilesToCopyOCL" CACHE INTERNAL "")
set(Vulkan_INSTALL_SUBDIR "FilesToCopyVulkan" CACHE INTERNAL "")
set(VulkanLayer_INSTALL_SUBDIR "VulkanLayer" CACHE INTERNAL "")
set(L0_INSTALL_SUBDIR "FilesToCopyL0" CACHE INTERNAL "")
elseif(UNIX)
set(OpenGL_INSTALL_SUBDIR "OpenGL" CACHE INTERNAL "")
set(OpenGLES_INSTALL_SUBDIR "OpenGL" CACHE INTERNAL "")
set(OpenCL_INSTALL_SUBDIR "OpenCL" CACHE INTERNAL "")
set(Vulkan_INSTALL_SUBDIR "Vulkan" CACHE INTERNAL "")
set(VulkanLayer_INSTALL_SUBDIR "VulkanLayer" CACHE INTERNAL "")
set(L0_INSTALL_SUBDIR "LevelZero" CACHE INTERNAL "")
else()
set(OpenGL_INSTALL_SUBDIR "." CACHE INTERNAL "")
set(OpenGLES_INSTALL_SUBDIR "." CACHE INTERNAL "")
set(OpenCL_INSTALL_SUBDIR "." CACHE INTERNAL "")
set(Vulkan_INSTALL_SUBDIR "." CACHE INTERNAL "")
set(VulkanLayer_INSTALL_SUBDIR "." CACHE INTERNAL "")
set(L0_INSTALL_SUBDIR "." CACHE INTERNAL "")
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
set(CLANG_COMPILER CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(UNIX AND NOT ARCH STREQUAL "-march=armv8-a")
add_definitions(-msse4.2)
endif()
if(NOT MSVC)
add_definitions(-Wall -Wno-unused-function -Wno-system-headers -Wno-write-strings -Wno-format -fno-strict-aliasing -fPIC -Doverride= "${ARCH}")
endif()
include(custom_functions)
if(UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual -Wno-unused-variable -Wno-conversion-null -Wno-pointer-arith -Wno-switch -Wno-deprecated-declarations -Werror")
elseif(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -DWIN32_LEAN_AND_MEAN -DNOMINMAX -D_SILENCE_CXX17_SHARED_PTR_UNIQUE_DEPRECATION_WARNING)
add_compile_options(/MP /W3 /wd4005 /wd4065 /wd4100 /wd4480 /wd4481 /wd4482 /wd4503 /wd4505 /wd4611 /wd4702 /wd4800 /wd4244 /wd4267 /wd4312 /bigobj)
add_compile_options("/MT$<$<CONFIG:Debug>:d>")
add_compile_options("$<$<NOT:$<CONFIG:Debug>>:/GS->")
add_link_options(/DYNAMICBASE:NO /LARGEADDRESSAWARE /FIXED:NO)
add_link_options("$<$<NOT:$<CONFIG:DEBUG>>:/OPT:REF>")
endif()
if(NOT MSVC AND NOT CLANG_COMPILER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--no-undefined")
endif()
if(NOT MSVC)
# libpng needs to be built as c
add_definitions(-fvisibility=hidden)
endif()
include(import_zlib)
include(import_libpng)
include(import_lua)
include(import_xxhash)
if (MSVC)
include(import_stackwalker)
endif()
include(import_clheaders)
include(import_murmurhash)
include(import_renderdoc)
include(import_json)
include(import_yamlcpp)
include(import_lz4)
include(import_zstd)
include_directories(common/include)
include_directories(OpenGL/common/include)
include_directories(OpenGL/GLIPlugin/include)
include_directories(OpenGL/recorder/include)
include_directories(player/include)
include_directories(recorder/include)
if(WITH_VULKAN)
include_directories(Vulkan/interceptor/include)
include_directories(Vulkan/common/include)
include_directories(Vulkan/recorder/include)
add_subdirectory(Vulkan)
endif()
if(WITH_OPENCL)
include_directories(OpenCL/interceptor/include)
include_directories(OpenCL/common/include)
include_directories(OpenCL/recorder/include)
add_subdirectory(OpenCL)
endif()
if(WITH_LEVELZERO)
include_directories(LevelZero/interceptor/include)
include_directories(LevelZero/common/include)
include_directories(LevelZero/recorder)
add_subdirectory(LevelZero)
if(WITH_OPENCL)
add_dependencies(L0_common OpenCL_codegen)
endif()
endif()
if(WITH_OCLOC)
include_directories(ocloc/interceptor/include)
include_directories(ocloc/common/include)
include_directories(ocloc/recorder)
add_subdirectory(ocloc)
endif()
add_subdirectory(common)
add_subdirectory(OpenGL)
add_subdirectory(player)
add_subdirectory(recorder)
if(ARCH AND NOT MSVC)
set_target_properties(gitsPlayer PROPERTIES LINK_FLAGS ${ARCH})
set_target_properties(GitsRecorder PROPERTIES LINK_FLAGS ${ARCH})
set_target_properties(OpenGL_interceptor PROPERTIES LINK_FLAGS ${ARCH})
if(WITH_OPENCL)
set_target_properties(OpenCL_interceptor PROPERTIES LINK_FLAGS ${ARCH})
endif()
endif()
if(WITH_VULKAN AND NOT MSVC)
set_target_properties(Vulkan_interceptor PROPERTIES LINK_FLAGS ${ARCH})
set_target_properties(Vulkan_layer PROPERTIES LINK_FLAGS ${ARCH})
endif()
if(WITH_LEVELZERO AND NOT MSVC)
set_target_properties(L0_interceptor PROPERTIES LINK_FLAGS ${ARCH})
endif()
if(WITH_OCLOC AND NOT MSVC)
set_target_properties(ocloc_interceptor PROPERTIES LINK_FLAGS ${ARCH})
endif()
install(DIRECTORY Scripts/Lua/ DESTINATION LuaScripts)
# CCode installation
install(DIRECTORY CCodeFiles/src/ DESTINATION CCode/CCodeSource)
install(FILES Scripts/install_dependencies.py DESTINATION CCode/Scripts/)
install(DIRECTORY third_party/patch/zlib DESTINATION CCode/third_party/patch)
install(DIRECTORY third_party/patch/libpng DESTINATION CCode/third_party/patch)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/custom_functions.cmake DESTINATION CCode/cmake)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/import_zlib.cmake DESTINATION CCode/cmake)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/import_libpng.cmake DESTINATION CCode/cmake)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/import_xxhash.cmake DESTINATION CCode/cmake)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/import_clheaders.cmake DESTINATION CCode/cmake)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/import_murmurhash.cmake DESTINATION CCode/cmake)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/import_lz4.cmake DESTINATION CCode/cmake)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/import_zstd.cmake DESTINATION CCode/cmake)
install(FILES CCodeFiles/CMakeLists.txt DESTINATION CCode)
if(WIN32)
install(FILES CCodeFiles/build_ccode.bat DESTINATION CCode)
elseif(UNIX)
install(FILES CCodeFiles/build.linux DESTINATION CCode)
endif()
if(WIN32)
if(WITH_VULKAN)
if("${CMAKE_GENERATOR_PLATFORM}" MATCHES "Win32")
set(PLATFORM Win32)
else()
set(PLATFORM x64)
endif()
set(INSTALL_GITS_VK_LAYER ${CMAKE_CURRENT_SOURCE_DIR}/Scripts/Installer/install_vulkan_layer.bat)
set(LAYER_DLL_PATH "Recorder\\\\${VulkanLayer_INSTALL_SUBDIR}")
install(CODE "execute_process(COMMAND cmd /c \"${INSTALL_GITS_VK_LAYER}\" \"${PLATFORM}\" \"\${CMAKE_INSTALL_PREFIX}\\\\${LAYER_DLL_PATH}\\\\\")")
endif()
endif()
if(WIN32)
set(PLATFORM "win32")
else()
if(${ARCH} STREQUAL "-m32")
set(PLATFORM "lnx_32")
elseif(${ARCH} STREQUAL "-m64")
set(PLATFORM "lnx_64")
else()
set(PLATFORM "lnx_arm")
endif()
endif()
set(CONFIG_GENERATOR_DIR "${CMAKE_SOURCE_DIR}/Scripts/ConfigGenerator")
set(GITS_CONFIG "gits_config.yml")
set(CONFIG_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/Config/${GITS_CONFIG}")
set(CONFIG_COMPUTE_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/Config/Compute/${GITS_CONFIG}")
set(CONFIG_GENERATOR "${CONFIG_GENERATOR_DIR}/gits_config_generator.py")
set(CONFIG_TEMPLATE "${CONFIG_GENERATOR_DIR}/gits_config.yml.mako")
if(SKIP_INSTALL_PATH)
install(CODE "execute_process(COMMAND \"${Python3_EXECUTABLE}\" \"${CONFIG_GENERATOR}\" --templatepath \"${CONFIG_TEMPLATE}\" \
--outputpath \"${CONFIG_OUTPUT}\" --platform ${PLATFORM} --installpath skip)")
install(CODE "execute_process(COMMAND \"${Python3_EXECUTABLE}\" \"${CONFIG_GENERATOR}\" --templatepath \"${CONFIG_TEMPLATE}\" \
--outputpath \"${CONFIG_COMPUTE_OUTPUT}\" --platform ${PLATFORM} --installpath skip --compute)")
else()
install(CODE "execute_process(COMMAND \"${Python3_EXECUTABLE}\" \"${CONFIG_GENERATOR}\" --templatepath \"${CONFIG_TEMPLATE}\" \
--outputpath \"${CONFIG_OUTPUT}\" --platform ${PLATFORM} --installpath \"\${CMAKE_INSTALL_PREFIX}\")")
install(CODE "execute_process(COMMAND \"${Python3_EXECUTABLE}\" \"${CONFIG_GENERATOR}\" --templatepath \"${CONFIG_TEMPLATE}\" \
--outputpath \"${CONFIG_COMPUTE_OUTPUT}\" --platform ${PLATFORM} --installpath \"\${CMAKE_INSTALL_PREFIX}\" --compute)")
endif(SKIP_INSTALL_PATH)
install(FILES ${CONFIG_OUTPUT} DESTINATION Recorder/${OpenGL_INSTALL_SUBDIR})
install(FILES ${CONFIG_OUTPUT} DESTINATION Recorder/${OpenGLES_INSTALL_SUBDIR})
if(WITH_OPENCL)
install(FILES ${CONFIG_COMPUTE_OUTPUT} DESTINATION Recorder/${OpenCL_INSTALL_SUBDIR})
endif()
if(WITH_VULKAN)
install(FILES ${CONFIG_OUTPUT} DESTINATION Recorder/${Vulkan_INSTALL_SUBDIR})
install(FILES ${CONFIG_OUTPUT} DESTINATION Recorder/${VulkanLayer_INSTALL_SUBDIR})
endif()
if(WITH_LEVELZERO)
install(FILES ${CONFIG_COMPUTE_OUTPUT} DESTINATION Recorder/${L0_INSTALL_SUBDIR})
endif()
install(FILES ${CONFIG_OUTPUT} DESTINATION Player)