• 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    descriptor_set_and_binding_parser.cc
22    engine.cc
23    executor.cc
24    format.cc
25    parser.cc
26    pipeline.cc
27    pipeline_data.cc
28    recipe.cc
29    result.cc
30    sleep.cc
31    script.cc
32    shader.cc
33    shader_compiler.cc
34    tokenizer.cc
35    type.cc
36    type_parser.cc
37    value.cc
38    verifier.cc
39    vkscript/command_parser.cc
40    vkscript/datum_type_parser.cc
41    vkscript/parser.cc
42    vkscript/section_parser.cc
43)
44
45if (${Vulkan_FOUND})
46  add_subdirectory(vulkan)
47  list(APPEND AMBER_SOURCES vulkan_engine_config.cc)
48endif()
49if (${Dawn_FOUND})
50  add_subdirectory(dawn)
51  list(APPEND AMBER_SOURCES dawn_engine_config.cc)
52endif()
53
54if (${AMBER_ENABLE_DXC})
55  list(APPEND AMBER_SOURCES dxc_helper.cc)
56endif()
57
58if (${AMBER_ENABLE_CLSPV})
59  list(APPEND AMBER_SOURCES clspv_helper.cc)
60endif()
61
62add_library(libamber ${AMBER_SOURCES})
63amber_default_compile_options(libamber)
64target_include_directories(libamber PRIVATE "${CMAKE_BINARY_DIR}")
65set_target_properties(libamber PROPERTIES OUTPUT_NAME "amber")
66
67if (${AMBER_ENABLE_DXC})
68  target_include_directories(libamber PRIVATE
69    "${PROJECT_SOURCE_DIR}/third_party/dxc/include"
70    "${CMAKE_BINARY_DIR}/third_party/dxc/include"
71  )
72
73  add_dependencies(libamber dxcompiler)
74  target_link_libraries(libamber
75    dxcompiler
76    LLVMDxcSupport
77    LLVMOption
78    LLVMHLSL
79    LLVMScalarOpts
80  )
81endif()
82
83if (${AMBER_ENABLE_CLSPV})
84  target_include_directories(libamber PRIVATE
85    "${PROJECT_SOURCE_DIR}/third_party/clspv/include"
86  )
87
88  target_link_libraries(libamber
89    clspv_core
90    clspv_passes
91  )
92endif()
93
94if (${AMBER_ENABLE_SPIRV_TOOLS})
95  target_link_libraries(libamber SPIRV-Tools)
96endif()
97
98if (${AMBER_ENABLE_SHADERC})
99  target_link_libraries(libamber shaderc SPIRV)
100endif()
101
102if (NOT MSVC AND NOT ANDROID)
103  target_link_libraries(libamber pthread)
104endif()
105
106if (${Vulkan_FOUND})
107  target_link_libraries(libamber libamberenginevulkan)
108endif()
109if (${Dawn_FOUND})
110  target_link_libraries(libamber libamberenginedawn)
111endif()
112
113if (${AMBER_ENABLE_TESTS})
114  set(TEST_SRCS
115    amberscript/parser_attach_test.cc
116    amberscript/parser_bind_test.cc
117    amberscript/parser_buffer_test.cc
118    amberscript/parser_clear_color_test.cc
119    amberscript/parser_clear_test.cc
120    amberscript/parser_compile_options_test.cc
121    amberscript/parser_copy_test.cc
122    amberscript/parser_device_feature_test.cc
123    amberscript/parser_expect_test.cc
124    amberscript/parser_extension_test.cc
125    amberscript/parser_framebuffer_test.cc
126    amberscript/parser_pipeline_test.cc
127    amberscript/parser_pipeline_set_test.cc
128    amberscript/parser_repeat_test.cc
129    amberscript/parser_run_test.cc
130    amberscript/parser_set_test.cc
131    amberscript/parser_shader_opt_test.cc
132    amberscript/parser_shader_test.cc
133    amberscript/parser_struct_test.cc
134    amberscript/parser_test.cc
135    buffer_test.cc
136    command_data_test.cc
137    descriptor_set_and_binding_parser_test.cc
138    executor_test.cc
139    format_test.cc
140    pipeline_test.cc
141    result_test.cc
142    script_test.cc
143    shader_compiler_test.cc
144    tokenizer_test.cc
145    type_parser_test.cc
146    type_test.cc
147    verifier_test.cc
148    vkscript/command_parser_test.cc
149    vkscript/datum_type_parser_test.cc
150    vkscript/parser_test.cc
151    vkscript/section_parser_test.cc
152    ../samples/ppm.cc
153    ../samples/ppm_test.cc
154  )
155
156  if (${Vulkan_FOUND})
157    list(APPEND TEST_SRCS vulkan/vertex_buffer_test.cc)
158  endif()
159
160  if (${Dawn_FOUND})
161    list(APPEND TEST_SRCS dawn/pipeline_info_test.cc)
162  endif()
163
164  add_executable(amber_unittests ${TEST_SRCS})
165
166  if (NOT MSVC)
167    target_compile_options(amber_unittests PRIVATE
168      -Wno-global-constructors
169      -Wno-weak-vtables
170    )
171  endif()
172
173  target_include_directories(amber_unittests PRIVATE
174      ${gmock_SOURCE_DIR}/include)
175  target_link_libraries(amber_unittests libamber gmock_main)
176  amber_default_compile_options(amber_unittests)
177  add_test(NAME amber_unittests COMMAND amber_unittests)
178
179  if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
180    # vulkan/vulkan.h defines VK_NULL_HANDLE as 0u and that also serves as a null pointer.
181    # Disable Clang's warning that will alwaays fire on that.  This is required to build
182    # with XCode 10.
183    target_compile_options(amber_unittests PRIVATE -Wno-zero-as-null-pointer-constant)
184  endif()
185endif()
186