forked from GPUOpen-Drivers/spvgen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
137 lines (119 loc) · 5.29 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
##
#######################################################################################################################
#
# Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
#######################################################################################################################
cmake_minimum_required(VERSION 3.5)
PROJECT(spvgen VERSION 1 LANGUAGES C CXX)
option(SPVGEN_ENABLE_WERROR "Build with -Werror enabled" OFF)
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fPIC")
endif ()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
if("${XGL_LLPC_PATH}" STREQUAL "")
set(XGL_LLPC_PATH ${PROJECT_SOURCE_DIR}/../llpc/llpc)
endif()
add_definitions(-DVFX_INSIDE_SPVGEN=1)
add_definitions(-DNV_EXTENSIONS)
add_definitions(-DAMD_EXTENSIONS)
add_definitions(-DENABLE_HLSL)
# These two directories only exist after the user does "cd external && python fetch_external_sources.py".
# You cannot build spvgen without them, but we do not want the cmake stage to fail when they are not
# present, as spvgen is not built as part of the "all" target.
if(EXISTS ${PROJECT_SOURCE_DIR}/../glslang/CMakeLists.txt)
add_subdirectory(../glslang external/glslang)
elseif(EXISTS ${PROJECT_SOURCE_DIR}/external/glslang/CMakeLists.txt)
add_subdirectory(external/glslang)
endif()
if(EXISTS ${PROJECT_SOURCE_DIR}/../SPIRV-tools/CMakeLists.txt)
set(SPIRV_WERROR ${SPVGEN_ENABLE_WERROR} CACHE BOOL "${PROJECT_NAME} override." FORCE)
add_subdirectory(../SPIRV-tools external/SPIRV-tools)
elseif(EXISTS ${PROJECT_SOURCE_DIR}/external/SPIRV-tools/CMakeLists.txt)
set(SPIRV_WERROR ${SPVGEN_ENABLE_WERROR} CACHE BOOL "${PROJECT_NAME} override." FORCE)
add_subdirectory(external/SPIRV-tools)
endif()
if(EXISTS ${PROJECT_SOURCE_DIR}/../SPIRV-cross/CMakeLists.txt)
add_subdirectory(../SPIRV-cross external/SPIRV-cross)
elseif(EXISTS ${PROJECT_SOURCE_DIR}/external/SPIRV-cross/CMakeLists.txt)
add_subdirectory(external/SPIRV-cross)
endif()
# vkgcDefs.h is included in llpc/tool/vfx/vfx.h
# llpc.h is included in llpc/llpc/tool/vfx/vfx.h
if(EXISTS ${XGL_VKGC_PATH}/tool/vfx/vfx.h)
set(XGL_VFX_PATH ${XGL_VKGC_PATH}/tool/vfx)
set(XGL_LLPC_INC_DIR ${XGL_VKGC_PATH}/include)
elseif(EXISTS ${XGL_LLPC_PATH}/../tool/vfx/vfx.h)
set(XGL_VFX_PATH ${XGL_LLPC_PATH}/../tool/vfx)
set(XGL_LLPC_INC_DIR ${XGL_LLPC_PATH}/../include)
else()
set(XGL_VFX_PATH ${XGL_LLPC_PATH}/tool/vfx)
set(XGL_LLPC_INC_DIR ${XGL_LLPC_PATH}/include)
endif()
include_directories(
include
external/glslang
external/glslang/SPIRV
external/SPIRV-tools/include
external/SPIRV-cross
external/llpc/include
${XGL_LLPC_INC_DIR}
${XGL_VFX_PATH}
)
if(EXISTS ${XGL_VFX_PATH}/vfxVkSection.cpp)
add_definitions(-DVFX_SUPPORT_VK_PIPELINE=1)
add_definitions(-DVFX_SUPPORT_RENDER_DOCOUMENT=1)
set(SPVGEN_SOURCE_FILES
source/spvgen.cpp
${XGL_VFX_PATH}/vfxParser.cpp
${XGL_VFX_PATH}/vfxPipelineDoc.cpp
${XGL_VFX_PATH}/vfxRenderDoc.cpp
${XGL_VFX_PATH}/vfxSection.cpp
${XGL_VFX_PATH}/vfxEnumsConverter.cpp
${XGL_VFX_PATH}/vfxVkSection.cpp
${XGL_VFX_PATH}/vfxRenderSection.cpp
)
else()
set(SPVGEN_SOURCE_FILES
source/spvgen.cpp
${XGL_VFX_PATH}/vfxParser.cpp
${XGL_VFX_PATH}/vfxPipelineDoc.cpp
${XGL_VFX_PATH}/vfxRenderDoc.cpp
${XGL_VFX_PATH}/vfxSection.cpp
${XGL_VFX_PATH}/vfxEnumsConverter.cpp
)
endif()
# Build object library
add_library(spvgen_base OBJECT ${SPVGEN_SOURCE_FILES})
target_link_libraries(spvgen_base glslang HLSL OGLCompiler SPIRV SPIRV-Tools SPIRV-Tools-opt spirv-cross-c khronos_spirv_interface khronos_vulkan_interface)
# Touch an empty source file
set(EMPTY_SOURCE_FILES ${CMAKE_CURRENT_BINARY_DIR}/empty.cpp)
add_custom_command(
OUTPUT ${EMPTY_SOURCE_FILES}
COMMAND ${CMAKE_COMMAND} -E touch ${EMPTY_SOURCE_FILES}
COMMENT "Touching ${EMPTY_SOURCE_FILES}"
)
# Build static library
add_library(spvgen_static STATIC ${EMPTY_SOURCE_FILES})
target_link_libraries(spvgen_static spvgen_base)
# Build shared library
add_library(spvgen SHARED ${EMPTY_SOURCE_FILES})
target_link_libraries(spvgen spvgen_base)