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
15include_directories("${PROJECT_SOURCE_DIR}/include")
16
17set(AMBER_SOURCES
18    amber.cc
19    config_helper.cc
20    log.cc
21    ppm.cc
22    timestamp.cc
23    ${CMAKE_BINARY_DIR}/src/build-versions.h.fake
24)
25
26set(AMBER_EXTRA_LIBS "")
27
28if (${AMBER_ENABLE_LODEPNG})
29  set(AMBER_SOURCES ${AMBER_SOURCES} png.cc)
30  list(APPEND AMBER_EXTRA_LIBS "lodepng")
31endif()
32
33if (${Vulkan_FOUND})
34  set(AMBER_SOURCES ${AMBER_SOURCES} config_helper_vulkan.cc)
35  list(APPEND AMBER_EXTRA_LIBS ${VULKAN_LIB})
36endif()
37
38if (${Dawn_FOUND})
39  set(AMBER_SOURCES ${AMBER_SOURCES} config_helper_dawn.cc)
40  list(APPEND AMBER_EXTRA_LIBS Dawn::dawn_native Dawn::dawn)
41  if (APPLE)
42    add_definitions(-DAMBER_DAWN_METAL=1)
43    find_library(METAL_LIB Metal)
44    list(APPEND AMBER_EXTRA_LIBS ${METAL_LIB})
45  else()
46    add_definitions(-DAMBER_DAWN_METAL=0)
47  endif()
48endif()
49
50add_executable(amber ${AMBER_SOURCES})
51target_include_directories(amber PRIVATE "${CMAKE_BINARY_DIR}")
52
53set_target_properties(amber PROPERTIES OUTPUT_NAME "amber")
54target_link_libraries(amber libamber ${AMBER_EXTRA_LIBS})
55amber_default_compile_options(amber)
56
57add_custom_command(
58    OUTPUT ${CMAKE_BINARY_DIR}/src/build-versions.h.fake
59    COMMAND
60      ${PYTHON_EXECUTABLE}
61        ${PROJECT_SOURCE_DIR}/tools/update_build_version.py
62        ${CMAKE_BINARY_DIR}
63        ${CMAKE_CURRENT_SOURCE_DIR}
64        ${PROJECT_SOURCE_DIR}/third_party
65    WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
66    COMMENT "Update build-versions.h in the build directory"
67)
68
69set(IMAGE_DIFF_SOURCES
70    image_diff.cc
71)
72add_executable(image_diff ${IMAGE_DIFF_SOURCES})
73target_include_directories(image_diff PRIVATE "${CMAKE_BINARY_DIR}")
74target_link_libraries(image_diff libamber "lodepng")
75amber_default_compile_options(image_diff)
76set_target_properties(image_diff PROPERTIES OUTPUT_NAME "image_diff")
77