# Copyright 2026 Michael Hope <michaelh@juju.nz>
# SPDX-License-Identifier: MIT

find_program(CLANG_FORMAT clang-format REQUIRED)

add_custom_command(
  OUTPUT z80v1-run.h
  COMMAND
    ${Python3_EXECUTABLE} ${TOP}/tools/gendispatch.py
    --opcodes=${TOP}/third_party/opcode-table/opcode-table.json
    --out=z80v1-run.h &&
    ${CLANG_FORMAT} -i z80v1-run.h
  DEPENDS
    ${TOP}/tools/gendispatch.py
    ${TOP}/third_party/opcode-table/opcode-table.json
  VERBATIM
)

add_library(z80v1 INTERFACE attributes.h z80v1.h z80v1-run.h)
target_include_directories(z80v1 INTERFACE
  ${CMAKE_CURRENT_SOURCE_DIR}
  ${CMAKE_CURRENT_BINARY_DIR}
)

add_library(board INTERFACE board.h)
target_include_directories(board INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
