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