• 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}")
127endif()
128if (${Dawn_FOUND})
129  target_link_libraries(libamber libamberenginedawn)
130endif()
131
132if (${AMBER_ENABLE_TESTS})
133  set(TEST_SRCS
134    amberscript/parser_attach_test.cc
135    amberscript/parser_bind_test.cc
136    amberscript/parser_buffer_test.cc
137    amberscript/parser_clear_color_test.cc
138    amberscript/parser_clear_depth_test.cc
139    amberscript/parser_clear_stencil_test.cc
140    amberscript/parser_clear_test.cc
141    amberscript/parser_compile_options_test.cc
142    amberscript/parser_copy_test.cc
143    amberscript/parser_debug_test.cc
144    amberscript/parser_depth_test.cc
145    amberscript/parser_device_feature_test.cc
146    amberscript/parser_expect_test.cc
147    amberscript/parser_extension_test.cc
148    amberscript/parser_framebuffer_test.cc
149    amberscript/parser_image_test.cc
150    amberscript/parser_pipeline_test.cc
151    amberscript/parser_pipeline_set_test.cc
152    amberscript/parser_repeat_test.cc
153    amberscript/parser_run_test.cc
154    amberscript/parser_sampler_test.cc
155    amberscript/parser_set_test.cc
156    amberscript/parser_shader_opt_test.cc
157    amberscript/parser_shader_test.cc
158    amberscript/parser_stencil_test.cc
159    amberscript/parser_struct_test.cc
160    amberscript/parser_subgroup_size_control_test.cc
161    amberscript/parser_test.cc
162    buffer_test.cc
163    command_data_test.cc
164    descriptor_set_and_binding_parser_test.cc
165    executor_test.cc
166    float16_helper_test.cc
167    format_test.cc
168    pipeline_test.cc
169    result_test.cc
170    script_test.cc
171    shader_compiler_test.cc
172    tokenizer_test.cc
173    type_parser_test.cc
174    type_test.cc
175    verifier_test.cc
176    virtual_file_store_test.cc
177    vkscript/command_parser_test.cc
178    vkscript/datum_type_parser_test.cc
179    vkscript/parser_test.cc
180    vkscript/section_parser_test.cc
181    ../samples/ppm.cc
182    ../samples/ppm_test.cc
183  )
184
185  if (${Vulkan_FOUND})
186    list(APPEND TEST_SRCS
187            vulkan/vertex_buffer_test.cc
188            vulkan/pipeline_test.cc)
189  endif()
190
191  if (${Dawn_FOUND})
192    list(APPEND TEST_SRCS dawn/pipeline_info_test.cc)
193  endif()
194
195  add_executable(amber_unittests ${TEST_SRCS})
196
197  if (NOT MSVC)
198    target_compile_options(amber_unittests PRIVATE
199      -Wno-global-constructors
200      -Wno-weak-vtables
201    )
202  endif()
203
204  target_include_directories(amber_unittests PRIVATE
205      ${gmock_SOURCE_DIR}/include)
206  target_link_libraries(amber_unittests libamber gmock_main)
207  amber_default_compile_options(amber_unittests)
208  add_test(NAME amber_unittests COMMAND amber_unittests)
209
210  if (${Vulkan_FOUND})
211    target_include_directories(amber_unittests PRIVATE "${VulkanHeaders_INCLUDE_DIR}" "${CMAKE_BINARY_DIR}")
212  endif()
213
214  if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
215    # vulkan/vulkan.h defines VK_NULL_HANDLE as 0u and that also serves as a null pointer.
216    # Disable Clang's warning that will alwaays fire on that.  This is required to build
217    # with XCode 10.
218    target_compile_options(amber_unittests PRIVATE -Wno-zero-as-null-pointer-constant)
219  endif()
220endif()
221