• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2018 The Amber Authors.
2# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16set(AMBER_SOURCES
17    acceleration_structure.cc
18    amber.cc
19    amberscript/parser.cc
20    buffer.cc
21    command.cc
22    command_data.cc
23    descriptor_set_and_binding_parser.cc
24    engine.cc
25    executor.cc
26    float16_helper.cc
27    format.cc
28    parser.cc
29    pipeline.cc
30    pipeline_data.cc
31    recipe.cc
32    result.cc
33    sampler.cc
34    script.cc
35    shader.cc
36    shader_compiler.cc
37    sleep.cc
38    tokenizer.cc
39    type.cc
40    type_parser.cc
41    value.cc
42    verifier.cc
43    virtual_file_store.cc
44    vkscript/command_parser.cc
45    vkscript/datum_type_parser.cc
46    vkscript/parser.cc
47    vkscript/section_parser.cc
48)
49
50if (${Vulkan_FOUND})
51  add_subdirectory(vulkan)
52  list(APPEND AMBER_SOURCES vulkan_engine_config.cc)
53endif()
54if (${Dawn_FOUND})
55  add_subdirectory(dawn)
56  list(APPEND AMBER_SOURCES dawn_engine_config.cc)
57endif()
58
59if (${AMBER_ENABLE_DXC})
60  list(APPEND AMBER_SOURCES dxc_helper.cc)
61endif()
62
63if (${AMBER_ENABLE_CLSPV})
64  list(APPEND AMBER_SOURCES clspv_helper.cc)
65endif()
66
67add_library(libamber ${AMBER_SOURCES})
68amber_default_compile_options(libamber)
69target_include_directories(libamber PRIVATE
70  "${CMAKE_BINARY_DIR}"
71  ${SPIRV-Headers_SOURCE_DIR}/include)
72set_target_properties(libamber PROPERTIES OUTPUT_NAME "amber")
73
74if (${AMBER_ENABLE_DXC})
75  target_include_directories(libamber PRIVATE
76    "${PROJECT_SOURCE_DIR}/third_party/dxc/include"
77    "${CMAKE_BINARY_DIR}/third_party/dxc/include"
78  )
79
80  add_dependencies(libamber dxcompiler)
81  target_link_libraries(libamber
82    dxcompiler
83    LLVMDxcSupport
84    LLVMHLSL
85    LLVMOption
86    LLVMSupport
87  )
88
89  if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
90    target_compile_options(libamber PRIVATE
91      -fms-extensions
92      -Wno-language-extension-token
93      -fexceptions
94    )
95  endif()
96endif()
97
98if (${AMBER_ENABLE_CLSPV})
99  target_include_directories(libamber PRIVATE
100    "${clspv_SOURCE_DIR}/clspv/include"
101  )
102
103  target_link_libraries(libamber
104    clspv_core
105    clspv_passes
106  )
107endif()
108
109if (${AMBER_ENABLE_SPIRV_TOOLS})
110  target_link_libraries(libamber SPIRV-Tools)
111endif()
112
113if (${AMBER_ENABLE_SHADERC})
114  target_link_libraries(libamber shaderc SPIRV)
115endif()
116
117if (NOT MSVC AND NOT ANDROID AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "QNX")
118  target_link_libraries(libamber pthread)
119endif()
120
121if (${Vulkan_FOUND})
122  target_link_libraries(libamber libamberenginevulkan)
123  target_include_directories(libamber PRIVATE "${VulkanHeaders_INCLUDE_DIR}")
124
125  if (${VULKAN_CTS_HEADER} AND DEFINED AMBER_CTS_INL_DIR)
126    target_include_directories(libamber PRIVATE "${AMBER_CTS_INL_DIR}")
127  endif()
128endif()
129if (${Dawn_FOUND})
130  target_link_libraries(libamber libamberenginedawn)
131endif()
132
133if (${AMBER_ENABLE_TESTS})
134  set(TEST_SRCS
135    amberscript/parser_attach_test.cc
136    amberscript/parser_bind_test.cc
137    amberscript/parser_buffer_test.cc
138    amberscript/parser_clear_color_test.cc
139    amberscript/parser_clear_depth_test.cc
140    amberscript/parser_clear_stencil_test.cc
141    amberscript/parser_clear_test.cc
142    amberscript/parser_compile_options_test.cc
143    amberscript/parser_copy_test.cc
144    amberscript/parser_depth_test.cc
145    amberscript/parser_device_feature_test.cc
146    amberscript/parser_device_property_test.cc
147    amberscript/parser_expect_test.cc
148    amberscript/parser_extension_test.cc
149    amberscript/parser_framebuffer_test.cc
150    amberscript/parser_image_test.cc
151    amberscript/parser_pipeline_test.cc
152    amberscript/parser_pipeline_set_test.cc
153    amberscript/parser_raytracing_test.cc
154    amberscript/parser_repeat_test.cc
155    amberscript/parser_run_test.cc
156    amberscript/parser_run_timed_execution_test.cc
157    amberscript/parser_sampler_test.cc
158    amberscript/parser_set_test.cc
159    amberscript/parser_shader_opt_test.cc
160    amberscript/parser_shader_test.cc
161    amberscript/parser_stencil_test.cc
162    amberscript/parser_blend_test.cc
163    amberscript/parser_struct_test.cc
164    amberscript/parser_subgroup_size_control_test.cc
165    amberscript/parser_test.cc
166    amberscript/parser_viewport_test.cc
167    buffer_test.cc
168    command_data_test.cc
169    descriptor_set_and_binding_parser_test.cc
170    executor_test.cc
171    float16_helper_test.cc
172    format_test.cc
173    pipeline_test.cc
174    result_test.cc
175    script_test.cc
176    shader_compiler_test.cc
177    tokenizer_test.cc
178    type_parser_test.cc
179    type_test.cc
180    verifier_test.cc
181    virtual_file_store_test.cc
182    vkscript/command_parser_test.cc
183    vkscript/datum_type_parser_test.cc
184    vkscript/parser_test.cc
185    vkscript/section_parser_test.cc
186    ../samples/ppm.cc
187    ../samples/ppm_test.cc
188  )
189
190  if (${Vulkan_FOUND})
191    list(APPEND TEST_SRCS
192            vulkan/vertex_buffer_test.cc
193            vulkan/pipeline_test.cc)
194  endif()
195
196  if (${Dawn_FOUND})
197    list(APPEND TEST_SRCS dawn/pipeline_info_test.cc)
198  endif()
199
200  add_executable(amber_unittests ${TEST_SRCS})
201
202  if (NOT MSVC)
203    target_compile_options(amber_unittests PRIVATE
204      -Wno-global-constructors
205      -Wno-weak-vtables
206    )
207  endif()
208
209  target_include_directories(amber_unittests PRIVATE
210      ${gmock_SOURCE_DIR}/include)
211  target_link_libraries(amber_unittests libamber gmock_main)
212  amber_default_compile_options(amber_unittests)
213  add_test(NAME amber_unittests COMMAND amber_unittests)
214
215  if (${Vulkan_FOUND})
216    target_include_directories(amber_unittests PRIVATE "${VulkanHeaders_INCLUDE_DIR}" "${CMAKE_BINARY_DIR}")
217  endif()
218
219  if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
220    # vulkan/vulkan.h defines VK_NULL_HANDLE as 0u and that also serves as a null pointer.
221    # Disable Clang's warning that will alwaays fire on that.  This is required to build
222    # with XCode 10.
223    target_compile_options(amber_unittests PRIVATE -Wno-zero-as-null-pointer-constant)
224  endif()
225endif()
226